From 8d86b0dbfba90e77f615e704cd39f9042fe4fbf1 Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Wed, 1 Nov 2017 16:59:56 +0000 Subject: [PATCH] Add per-network bind ips to inventory This adds the per-node per-network ips for each network so we can e.g set the bind ips for services deployed via ansible. Change-Id: I6085df4741d944875afbe02d71b9e9a85c406024 --- tripleo_validations/inventory.py | 4 +++ tripleo_validations/tests/test_inventory.py | 30 ++++++++++++++------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/tripleo_validations/inventory.py b/tripleo_validations/inventory.py index 167190bcc..5c0b2a0ce 100644 --- a/tripleo_validations/inventory.py +++ b/tripleo_validations/inventory.py @@ -170,6 +170,10 @@ class TripleoInventory(object): ret[name]['vars'] = { 'deploy_server_id': role_node_id_map[ 'server_ids'][role][idx]} + # Add variable for IP on each network + for net in role_net_ip_map[role]: + ret[name]['vars']["%s_ip" % net] = \ + role_net_ip_map[role][net][idx] children.append(role) ret[role] = { diff --git a/tripleo_validations/tests/test_inventory.py b/tripleo_validations/tests/test_inventory.py index 2b9d9df4a..baa356315 100644 --- a/tripleo_validations/tests/test_inventory.py +++ b/tripleo_validations/tests/test_inventory.py @@ -157,11 +157,14 @@ class TestInventory(base.TestCase): def test_inventory_list(self): expected = {'c-0': {'hosts': ['x.x.x.1'], - 'vars': {'deploy_server_id': 'a'}}, + 'vars': {'deploy_server_id': 'a', + 'ctlplane_ip': 'x.x.x.1'}}, 'c-1': {'hosts': ['x.x.x.2'], - 'vars': {'deploy_server_id': 'b'}}, + 'vars': {'deploy_server_id': 'b', + 'ctlplane_ip': 'x.x.x.2'}}, 'c-2': {'hosts': ['x.x.x.3'], - 'vars': {'deploy_server_id': 'c'}}, + 'vars': {'deploy_server_id': 'c', + 'ctlplane_ip': 'x.x.x.3'}}, 'Compute': { 'children': ['cp-0'], 'vars': {'ansible_ssh_user': 'heat-admin', @@ -173,9 +176,11 @@ class TestInventory(base.TestCase): 'bootstrap_server_id': 'a', 'role_name': 'Controller'}}, 'cp-0': {'hosts': ['y.y.y.1'], - 'vars': {'deploy_server_id': 'd'}}, + 'vars': {'deploy_server_id': 'd', + 'ctlplane_ip': 'y.y.y.1'}}, 'cs-0': {'hosts': ['z.z.z.1'], - 'vars': {'deploy_server_id': 'e'}}, + 'vars': {'deploy_server_id': 'e', + 'ctlplane_ip': 'z.z.z.1'}}, 'CustomRole': { 'children': ['cs-0'], 'vars': {'ansible_ssh_user': 'heat-admin', @@ -213,11 +218,14 @@ class TestInventory(base.TestCase): self.inventory.stack_outputs = self.outputs expected = {'c-0': {'hosts': ['x.x.x.1'], - 'vars': {'deploy_server_id': 'a'}}, + 'vars': {'deploy_server_id': 'a', + 'ctlplane_ip': 'x.x.x.1'}}, 'c-1': {'hosts': ['x.x.x.2'], - 'vars': {'deploy_server_id': 'b'}}, + 'vars': {'deploy_server_id': 'b', + 'ctlplane_ip': 'x.x.x.2'}}, 'c-2': {'hosts': ['x.x.x.3'], - 'vars': {'deploy_server_id': 'c'}}, + 'vars': {'deploy_server_id': 'c', + 'ctlplane_ip': 'x.x.x.3'}}, 'Compute': { 'children': ['cp-0'], 'vars': {'ansible_ssh_user': 'my-custom-admin', @@ -229,9 +237,11 @@ class TestInventory(base.TestCase): 'bootstrap_server_id': 'a', 'role_name': 'Controller'}}, 'cp-0': {'hosts': ['y.y.y.1'], - 'vars': {'deploy_server_id': 'd'}}, + 'vars': {'deploy_server_id': 'd', + 'ctlplane_ip': 'y.y.y.1'}}, 'cs-0': {'hosts': ['z.z.z.1'], - 'vars': {'deploy_server_id': 'e'}}, + 'vars': {'deploy_server_id': 'e', + 'ctlplane_ip': 'z.z.z.1'}}, 'CustomRole': { 'children': ['cs-0'], 'vars': {'ansible_ssh_user': 'my-custom-admin',