Commit 8f3fdcf4 authored by Makis Tsantekidis's avatar Makis Tsantekidis

Merge pull request #31 from efikalti/fixes

Create cluster using kamaki python api
parents bac90107 e883afed
...@@ -59,5 +59,5 @@ docs/_build/ ...@@ -59,5 +59,5 @@ docs/_build/
# PyBuilder # PyBuilder
target/ target/
ansible/hosts
MANIFEST MANIFEST
old_kamaki
#
# config file for ansible
# https://raw.githubusercontent.com/ansible/ansible/devel/examples/ansible.cfg
#
[defaults]
remote_user = root
hostfile = hosts
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division,
print_function, unicode_literals)
import os
"""
This module contains the definitions of returned errors.
"""
# Definitions of return value errors
error_syntax_clustersize = -1
error_syntax_cpu_master = -2
error_syntax_ram_master = -3
error_syntax_disk_master = -4
error_syntax_cpu_slave = -5
error_syntax_ram_slave = -6
error_syntax_disk_slave = -7
error_syntax_logging_level = -8
error_syntax_disk_template = -9
error_quotas_cyclades_disk = -10
error_quotas_cpu = -11
error_quotas_ram = -12
error_quotas_cluster_size = -13
error_quotas_network = -14
error_flavor_id = -15
error_image_id = -16
error_syntax_token = -17
error_ready_reroute = -18
error_no_arguments = -19
error_fatal = -20
error_user_quota = -22
error_flavor_list = -23
error_get_list_servers = -24
error_get_list_projects = -25
error_get_network_quota = -28
error_create_network = -29
error_get_ip = -30
error_create_server = -31
error_syntax_auth_token = -32
error_ansible_playbook = -34
error_ssh_client = -35
error_cluster_not_exist = -69
error_cluster_corrupt = -70
error_proj_id = -71
error_multiple_entries = -72
error_project_quota = -73
error_authentication = -99
This diff is collapsed.
File mode changed from 100644 to 100755
...@@ -124,6 +124,44 @@ test_projects = [{u'creation_date': u'2015-06-09T09:46:44.327826+00:00', ...@@ -124,6 +124,44 @@ test_projects = [{u'creation_date': u'2015-06-09T09:46:44.327826+00:00',
u'state': u'active', u'state': u'active',
u'system_project': False}] u'system_project': False}]
test_quotas = { '6ff62e8e-0ce9-41f7-ad99-13a18ecada5f':
{'cyclades.disk':
{'project_limit': 1288490188800, 'project_pending': 0, 'project_usage': 64424509440, 'usage': 0, 'limit': 322122547200, 'pending': 0},
'cyclades.vm':
{'project_limit': 60, 'project_pending': 0, 'project_usage': 2, 'usage': 0, 'limit': 15, 'pending': 0},
'pithos.diskspace':
{'project_limit': 429496729600, 'project_pending': 0, 'project_usage': 0, 'usage': 0, 'limit': 107374182400, 'pending': 0},
'cyclades.ram':
{'project_limit': 128849018880, 'project_pending': 0, 'project_usage': 12884901888, 'usage': 0, 'limit': 32212254720, 'pending': 0},
'cyclades.cpu':
{'project_limit': 120, 'project_pending': 0, 'project_usage': 12, 'usage': 0, 'limit': 30, 'pending': 0},
'cyclades.floating_ip':
{'project_limit': 10, 'project_pending': 0, 'project_usage': 6, 'usage': 3, 'limit': 4, 'pending': 0},
'cyclades.network.private':
{'project_limit': 10, 'project_pending': 0, 'project_usage': 7, 'usage': 0, 'limit': 4, 'pending': 0},
'astakos.pending_app':
{'project_limit': 0, 'project_pending': 0, 'project_usage': 0, 'usage': 0, 'limit': 0, 'pending': 0}} }
test_ip = {u'floating_network_id':
u'2186', u'user_id':
u'9819231a-e9e2-40f7-93f1-e2e4cb50cc33',
u'deleted': False, u'tenant_id':
u'9819231a-e9e2-40f7-93f1-e2e4cb50cc33',
u'instance_id': None, u'fixed_ip_address': None,
u'floating_ip_address':
u'83.212.116.58',
u'port_id': None,
u'id': u'684011'}
test_vm = {u'addresses': {}, u'links': [{u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/servers/665007', u'rel': u'self'},
{u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/servers/665007', u'rel': u'bookmark'}], u'image':
{u'id': u'0e399015-8723-4c78-8198-75bdf693cdde', u'links': [
{u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/images/0e399015-8723-4c78-8198-75bdf693cdde', u'rel': u'self'},
{u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/images/0e399015-8723-4c78-8198-75bdf693cdde', u'rel': u'bookmark'},
{u'href': u'https://cyclades.okeanos.grnet.gr/image/v1.0/images/0e399015-8723-4c78-8198-75bdf693cdde', u'rel': u'alternate'}]},
u'suspended': False, u'flavor': {u'id': 3, u'links': [{u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/flavors/3', u'rel': u'self'},
{u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/flavors/3', u'rel': u'bookmark'}]}, u'id': 665007, u'security_groups': [
{u'name': u'default'}], u'attachments': [], u'user_id': u'9819231a-e9e2-40f7-93f1-e2e4cb50cc33', u'accessIPv4': u'', u'accessIPv6': u'', u'progress': 0, u'config_drive': u'', u'status': u'BUILD', u'updated': u'2015-07-10T07:13:25.973280+00:00', u'hostId': u'', u'SNF:fqdn': u'snf-665007.vm.okeanos.grnet.gr', u'deleted': False, u'key_name': None, u'name': u'to mikro debian sto livadi', u'adminPass': u'q0WVXWIjc4', u'tenant_id': u'6ff62e8e-0ce9-41f7-ad99-13a18ecada5f', u'created': u'2015-07-10T07:13:24.862714+00:00', u'SNF:task_state': u'BUILDING', u'volumes': [50722], u'diagnostics': [], u'metadata': {u'os': u'debian', u'users': u'root ckaner'}, u'SNF:port_forwarding': {}}
def test_find_flavor(): def test_find_flavor():
with mock.patch('fokia.provisioner.astakos'), \ with mock.patch('fokia.provisioner.astakos'), \
...@@ -140,6 +178,43 @@ def test_find_flavor(): ...@@ -140,6 +178,43 @@ def test_find_flavor():
name='tost', image_id=u'0035ac89-a86e-4108-93e8-93e294b74a3d', flavor_id=3, name='tost', image_id=u'0035ac89-a86e-4108-93e8-93e294b74a3d', flavor_id=3,
project_id=u'6ff62e8e-0ce9-41f7-ad99-13a18ecada5f', networks=[], personality=[]) project_id=u'6ff62e8e-0ce9-41f7-ad99-13a18ecada5f', networks=[], personality=[])
def test_check_all_resources():
with mock.patch('fokia.provisioner.astakos'), \
mock.patch('fokia.provisioner.KamakiConfig'), \
mock.patch('fokia.provisioner.cyclades'):
provisioner = Provisioner("lambda")
provisioner.astakos.get_projects.return_value = test_projects
provisioner.astakos.get_quotas.return_value = test_quotas
provisioner.check_all_resources(test_quotas, project_id=u'6ff62e8e-0ce9-41f7-ad99-13a18ecada5f',
slaves=2,
cluster_size=3,
vcpus=12,
ram=4096*3,
disk=180,
ip_request=1,
network_request=1)
def test_create_vpn():
with mock.patch('fokia.provisioner.astakos'), \
mock.patch('fokia.provisioner.KamakiConfig'), \
mock.patch('fokia.provisioner.cyclades'):
provisioner = Provisioner("lambda")
provisioner.network_client.create_network = test_ip
provisioner.reserve_ip()
def test_create_vm():
with mock.patch('fokia.provisioner.astakos'), \
mock.patch('fokia.provisioner.KamakiConfig'), \
mock.patch('fokia.provisioner.cyclades'):
provisioner = Provisioner("lambda")
provisioner.cyclades.create_server = test_vm
def test_connect_vm():
with mock.patch('fokia.provisioner.astakos'), \
mock.patch('fokia.provisioner.KamakiConfig'), \
mock.patch('fokia.provisioner.cyclades'):
provisioner = Provisioner("lambda")
provisioner.network_client.create_port = True
if __name__ == "__main__": if __name__ == "__main__":
test_find_flavor() test_find_flavor()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment