Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
okeanos-LoD
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
itminedu
okeanos-LoD
Commits
749dd946
Unverified
Commit
749dd946
authored
Jul 23, 2015
by
Avraam Tsantekidis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed tests and minor addition to ssl cert path
parent
de831ae2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
107 additions
and
57 deletions
+107
-57
.gitignore
.gitignore
+1
-0
core/fokia/provisioner.py
core/fokia/provisioner.py
+5
-0
core/requirements.txt
core/requirements.txt
+3
-1
core/tests/test_ansible_manager.py
core/tests/test_ansible_manager.py
+16
-13
core/tests/test_provisioner.py
core/tests/test_provisioner.py
+82
-43
No files found.
.gitignore
View file @
749dd946
...
...
@@ -62,3 +62,4 @@ target/
MANIFEST
old_kamaki
*.idea
coverage.xml
core/fokia/provisioner.py
View file @
749dd946
...
...
@@ -17,8 +17,13 @@ from Crypto.PublicKey import RSA
from
base64
import
b64encode
if
not
defaults
.
CACERTS_DEFAULT_PATH
:
from
ssl
import
get_default_verify_paths
CA_CERTS_PATH
=
get_default_verify_paths
().
cafile
if
not
CA_CERTS_PATH
:
raise
https
.
patch_with_certs
(
CA_CERTS_PATH
)
storage_templates
=
[
'drdb'
,
'ext_vlmc'
]
...
...
core/requirements.txt
View file @
749dd946
kamaki
\ No newline at end of file
kamaki
ansible
crypto
\ No newline at end of file
core/tests/test_ansible_manager.py
View file @
749dd946
...
...
@@ -2,34 +2,37 @@ from fokia.ansible_manager import Manager
from
mock
import
patch
test_provisioner_response
=
{
u
'ips'
:
[{
u
'floating_network_id'
:
u
'2186'
,
u
'floating_ip_address'
:
u
'83.212.116.49'
,
u
'id'
:
u
'688160'
}],
u
'ips'
:
[{
u
'floating_network_id'
:
u
'2186'
,
u
'floating_ip_address'
:
u
'83.212.116.49'
,
u
'id'
:
u
'688160'
}],
u
'nodes'
:
{
u
'master'
:
{
'internal_ip'
:
u
'192.168.0.2'
,
u
'adminPass'
:
u
'0igc3vbnSx'
,
u
'id'
:
666976
,
u
'name'
:
u
'test_vm'
},
u
'slaves'
:
[{
'internal_ip'
:
u
'192.168.0.3'
,
u
'id'
:
666977
,
u
'name'
:
u
'lambda-node1'
}]},
u
'master'
:
{
'internal_ip'
:
u
'192.168.0.2'
,
u
'adminPass'
:
u
'0igc3vbnSx'
,
u
'id'
:
666976
,
u
'name'
:
u
'test_vm'
},
u
'slaves'
:
[{
'internal_ip'
:
u
'192.168.0.3'
,
u
'id'
:
666977
,
u
'name'
:
u
'lambda-node1'
}]},
u
'vpn'
:
{
u
'type'
:
u
'MAC_FILTERED'
,
u
'id'
:
u
'143713'
},
'pk'
:
'Dummy pk'
,
u
'subnet'
:
{
u
'cidr'
:
u
'192.168.0.0/24'
,
u
'gateway_ip'
:
u
'192.168.0.1'
,
u
'id'
:
u
'142761'
}}
def
test_playbook_run
():
with
patch
(
'fokia.ansible_manager.PlayBook'
)
as
pb
,
patch
(
'fokia.ansible_manager.callbacks'
)
as
cb
,
patch
(
'fokia.ansible_manager.utils'
)
as
ut
:
with
patch
(
'fokia.ansible_manager.PlayBook'
)
as
pb
,
\
patch
(
'fokia.ansible_manager.callbacks'
)
as
cb
,
\
patch
(
'fokia.ansible_manager.utils'
)
as
ut
:
cb
.
PlaybookCallbacks
.
return_value
=
"a"
cb
.
PlaybookRunnerCallbacks
.
return_value
=
"b"
cb
.
AggregateStats
.
return_value
=
"c"
manager
=
Manager
(
test_provisioner_response
)
manager
.
create_inventory
()
manager
.
run_playbook
(
playbook_file
=
"../ansible/playbooks/testinventory.yml"
,
tags
=
[
"touch"
])
manager
.
run_playbook
(
playbook_file
=
"../ansible/playbooks/testinventory.yml"
,
tags
=
[
"touch"
])
assert
pb
.
call_args
[
1
][
'inventory'
].
groups
[
0
].
name
==
'master'
assert
pb
.
call_args
[
1
][
'inventory'
].
groups
[
1
].
name
==
'slaves'
assert
pb
.
call_args
[
1
][
'inventory'
].
groups
[
0
].
name
==
'all'
assert
pb
.
call_args
[
1
][
'inventory'
].
groups
[
1
].
name
==
'master'
assert
pb
.
call_args
[
1
][
'inventory'
].
groups
[
2
].
name
==
'slaves'
assert
pb
.
call_args
[
1
][
'inventory'
].
groups
[
0
].
hosts
[
0
].
name
==
u
'snf-661243.vm.okeanos.grnet.gr'
assert
pb
.
call_args
[
1
][
'inventory'
].
groups
[
1
].
hosts
[
0
].
name
==
u
'snf-66
152
6.vm.okeanos.grnet.gr'
assert
pb
.
call_args
[
1
][
'inventory'
].
groups
[
1
].
hosts
[
1
].
name
==
u
'snf-661527.vm.okeanos.grnet.gr
'
0
].
name
==
u
'snf-66
697
6.vm.okeanos.grnet.gr'
assert
pb
.
call_args
[
1
][
'inventory'
].
groups
[
2
].
hosts
[
0
].
name
==
u
'snf-666977.local
'
if
__name__
==
"__main__"
:
...
...
core/tests/test_provisioner.py
View file @
749dd946
...
...
@@ -124,44 +124,74 @@ test_projects = [{u'creation_date': u'2015-06-09T09:46:44.327826+00:00',
u
'state'
:
u
'active'
,
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_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
'2186'
,
u
'user_id'
:
u
'9819231a-e9e2-40f7-93f1-e2e4cb50cc33'
,
u
'deleted'
:
False
,
u
'tenant_id'
:
u
'9819231a-e9e2-40f7-93f1-e2e4cb50cc33'
,
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
'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'
:
{}}
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
():
with
mock
.
patch
(
'fokia.provisioner.astakos'
),
\
...
...
@@ -173,10 +203,14 @@ def test_find_flavor():
provisioner
.
cyclades
.
list_flavors
.
return_value
=
test_flavors
provisioner
.
create_vm
(
vm_name
=
"tost"
,
project_name
=
"lambda.grnet.gr"
,
project_mode
=
"supahpower"
,
image_name
=
"archlinux"
)
provisioner
.
cyclades
.
create_server
.
assert_called_with
(
name
=
'tost'
,
image_id
=
u
'0035ac89-a86e-4108-93e8-93e294b74a3d'
,
flavor_id
=
3
,
project_id
=
u
'6ff62e8e-0ce9-41f7-ad99-13a18ecada5f'
,
networks
=
[],
personality
=
[])
project_mode
=
"supahpower"
,
image_name
=
"archlinux"
,
net_id
=
"12345"
)
provisioner
.
cyclades
.
create_server
.
assert_called_with
(
flavor_id
=
3
,
image_id
=
u
'c6f5adce-21ad-4ce3-8591-acfe7eb73c02'
,
name
=
'tost'
,
networks
=
[{
u
'uuid'
:
'12345'
}],
personality
=
[],
project_id
=
u
'6ff62e8e-0ce9-41f7-ad99-13a18ecada5f'
)
def
test_check_all_resources
():
with
mock
.
patch
(
'fokia.provisioner.astakos'
),
\
...
...
@@ -185,14 +219,16 @@ def test_check_all_resources():
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
)
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'
),
\
...
...
@@ -200,7 +236,8 @@ def test_create_vpn():
mock
.
patch
(
'fokia.provisioner.cyclades'
):
provisioner
=
Provisioner
(
"lambda"
)
provisioner
.
network_client
.
create_network
=
test_ip
provisioner
.
reserve_ip
()
provisioner
.
reserve_ip
(
'6ff62e8e-0ce9-41f7-ad99-13a18ecada5f'
)
def
test_create_vm
():
with
mock
.
patch
(
'fokia.provisioner.astakos'
),
\
...
...
@@ -209,6 +246,7 @@ def test_create_vm():
provisioner
=
Provisioner
(
"lambda"
)
provisioner
.
cyclades
.
create_server
=
test_vm
def
test_connect_vm
():
with
mock
.
patch
(
'fokia.provisioner.astakos'
),
\
mock
.
patch
(
'fokia.provisioner.KamakiConfig'
),
\
...
...
@@ -216,5 +254,6 @@ def test_connect_vm():
provisioner
=
Provisioner
(
"lambda"
)
provisioner
.
network_client
.
create_port
=
True
if
__name__
==
"__main__"
:
test_find_flavor
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment