Unverified Commit b57303ae authored by Ioannis Tsafaras's avatar Ioannis Tsafaras Committed by Avraam Tsantekidis

Inventory test WIP

parent b37c7423
......@@ -94,14 +94,14 @@ class Manager:
if __name__ == "__main__":
response = {u'ips': [{u'floating_network_id': u'2216',
u'floating_ip_address': u'83.212.118.6',
u'id': u'686825'}],
u'nodes': {u'master': {u'id': 666355,
u'name': u'lambda-master'},
u'slaves': [{u'id': 666356, u'name': u'lambda-node1'}]},
u'vpn': {u'type': u'MAC_FILTERED', u'id': u'143499'},
u'subnet': {u'cidr': u'192.168.0.0/24', u'gateway_ip': u'192.168.0.1', u'id': u'142564'}}
response = {
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'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'}}
manager = Manager(response)
manager.create_inventory()
......
from fokia.ansible_manager import Manager
from mock import patch
test_provisioner_response = \
{"masters": [{u'addresses': {}, u'links': [
{u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/servers/664664',
u'rel': u'self'},
{u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/servers/664664',
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': 664664,
u'security_groups': [{u'name': u'default'}],
u'attachments': [],
u'user_id': u'19e4daba-20e2-4d57-a6aa-92ba1c982fd9',
u'accessIPv4': u'', u'accessIPv6': u'',
u'progress': 0, u'config_drive': u'',
u'status': u'BUILD',
u'updated': u'2015-07-08T10:15:38.936455+00:00',
u'hostId': u'',
u'SNF:fqdn': u'snf-661243.vm.okeanos.grnet.gr',
u'deleted': False, u'key_name': None,
u'name': u'to mikro debian sto livadi',
u'adminPass': u'X9yqjSTAFO',
u'tenant_id': u'6ff62e8e-0ce9-41f7-ad99-13a18ecada5f',
u'created': u'2015-07-08T10:15:37.837229+00:00',
u'SNF:task_state': u'BUILDING',
u'volumes': [50369], u'diagnostics': [],
u'metadata': {u'os': u'debian',
u'users': u'root ckaner'},
u'SNF:port_forwarding': {}}],
"slaves": [{u'addresses': {}, u'links': [
{
u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/servers/664664',
u'rel': u'self'},
{
u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/servers/664664',
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': 664664,
u'security_groups': [{u'name': u'default'}],
u'attachments': [],
u'user_id': u'19e4daba-20e2-4d57-a6aa-92ba1c982fd9',
u'accessIPv4': u'', u'accessIPv6': u'',
u'progress': 0, u'config_drive': u'',
u'status': u'BUILD',
u'updated': u'2015-07-08T10:15:38.936455+00:00',
u'hostId': u'',
u'SNF:fqdn': u'snf-661526.vm.okeanos.grnet.gr',
u'deleted': False, u'key_name': None,
u'name': u'to mikro debian sto livadi',
u'adminPass': u'X9yqjSTAFO',
u'tenant_id': u'6ff62e8e-0ce9-41f7-ad99-13a18ecada5f',
u'created': u'2015-07-08T10:15:37.837229+00:00',
u'SNF:task_state': u'BUILDING',
u'volumes': [50369], u'diagnostics': [],
u'metadata': {u'os': u'debian',
u'users': u'root ckaner'},
u'SNF:port_forwarding': {}},
{u'addresses': {}, u'links': [
{
u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/servers/664664',
u'rel': u'self'},
{
u'href': u'https://cyclades.okeanos.grnet.gr/compute/v2.0/servers/664664',
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': 664664,
u'security_groups': [{u'name': u'default'}],
u'attachments': [],
u'user_id': u'19e4daba-20e2-4d57-a6aa-92ba1c982fd9',
u'accessIPv4': u'',
u'accessIPv6': u'', u'progress': 0,
u'config_drive': u'', u'status': u'BUILD',
u'updated': u'2015-07-08T10:15:38.936455+00:00',
u'hostId': u'',
u'SNF:fqdn': u'snf-661527.vm.okeanos.grnet.gr',
u'deleted': False, u'key_name': None,
u'name': u'to mikro debian sto livadi',
u'adminPass': u'X9yqjSTAFO',
u'tenant_id': u'6ff62e8e-0ce9-41f7-ad99-13a18ecada5f',
u'created': u'2015-07-08T10:15:37.837229+00:00',
u'SNF:task_state': u'BUILDING',
u'volumes': [50369], u'diagnostics': [],
u'metadata': {u'os': u'debian',
u'users': u'root ckaner'},
u'SNF:port_forwarding': {}}]}
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'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'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():
......@@ -141,9 +19,9 @@ def test_playbook_run():
cb.AggregateStats.return_value = "c"
manager = Manager(test_provisioner_response)
manager.create_inventory()
manager.run_playbook(playbook_file="../ansible/playbooks/test.yml", tags=["touch"])
manager.run_playbook(playbook_file="../ansible/playbooks/testinventory.yml", tags=["touch"])
assert pb.call_args[1]['inventory'].groups[0].name == 'masters'
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].hosts[
......
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