Browse Source

Merge "Add tripleo_role_networks to inventory role group vars"

tags/12.1.0
Zuul Gerrit Code Review 2 weeks ago
parent
commit
24e6ee25f8
3 changed files with 83 additions and 62 deletions
  1. +6
    -6
      tripleo_common/inventory.py
  2. +36
    -36
      tripleo_common/tests/test_inventories.py
  3. +41
    -20
      tripleo_common/tests/test_inventory.py

+ 6
- 6
tripleo_common/inventory.py View File

@@ -250,10 +250,6 @@ class TripleoInventory(object):
hosts[name].update({
'deploy_server_id': role_node_id_map[
'server_ids'][role][idx]})
# Add variable for listing enabled networks in the node
hosts[name].update({
'enabled_networks':
[str(net) for net in role_net_ip_map[role]]})
# Add variable for IP on each network
for net in role_net_ip_map[role]:
hosts[name].update({
@@ -265,8 +261,6 @@ class TripleoInventory(object):
"%s_hostname" % net:
role_net_hostname_map[role][net][idx]})

networks.update(hosts[name]['enabled_networks'])

children.append(role)

if self.hosts_format_dict:
@@ -275,6 +269,11 @@ class TripleoInventory(object):
hosts_format = [h for h in hosts.keys()]
hosts_format.sort()

role_networks = sorted([
str(net) for net in role_net_ip_map[role]
])
networks.update(role_networks)

ret[role] = {
'hosts': hosts_format,
'vars': {
@@ -282,6 +281,7 @@ class TripleoInventory(object):
'bootstrap_server_id': role_node_id_map.get(
'bootstrap_server_id'),
'tripleo_role_name': role,
'tripleo_role_networks': role_networks,
'serial': self.serial,
}



+ 36
- 36
tripleo_common/tests/test_inventories.py View File

@@ -85,6 +85,15 @@ class TestInventories(base.TestCase):
],
"vars": {
"tripleo_role_name": "Controller",
"tripleo_role_networks": [
"management",
"storage",
"ctlplane",
"external",
"internal_api",
"storage_mgmt",
"tenant"
],
"serial": "1",
"ansible_ssh_user": "heat-admin",
}
@@ -129,15 +138,6 @@ class TestInventories(base.TestCase):
"tenant_ip": "192.168.24.12",
"internal_api_ip": "192.168.24.12",
"management_ip": "192.168.24.12",
"enabled_networks": [
"management",
"storage",
"ctlplane",
"external",
"internal_api",
"storage_mgmt",
"tenant"
],
"ansible_host": "192.168.24.12"
}
}
@@ -179,6 +179,15 @@ class TestInventories(base.TestCase):
],
"vars": {
"tripleo_role_name": "DistributedComputeHCI",
"tripleo_role_networks": [
"management",
"storage",
"ctlplane",
"external",
"internal_api",
"storage_mgmt",
"tenant"
],
"serial": "1",
"ansible_ssh_user": "heat-admin",
}
@@ -223,15 +232,6 @@ class TestInventories(base.TestCase):
"tenant_ip": "192.168.24.13",
"internal_api_ip": "192.168.24.13",
"management_ip": "192.168.24.13",
"enabled_networks": [
"management",
"storage",
"ctlplane",
"external",
"internal_api",
"storage_mgmt",
"tenant"
],
"ansible_host": "192.168.24.13"
}
}
@@ -281,20 +281,20 @@ class TestInventories(base.TestCase):
"tenant_ip": "192.168.24.12",
"internal_api_ip": "192.168.24.12",
"management_ip": "192.168.24.12",
"enabled_networks": [
"management",
"storage",
"ctlplane",
"external",
"internal_api",
"storage_mgmt",
"tenant"
],
"ansible_host": "192.168.24.12"
}
},
"vars": {
"tripleo_role_name": "Controller",
"tripleo_role_networks": [
"management",
"storage",
"ctlplane",
"external",
"internal_api",
"storage_mgmt",
"tenant"
],
"serial": "1",
"ansible_ssh_user": "heat-admin",
}
@@ -353,20 +353,20 @@ class TestInventories(base.TestCase):
"tenant_ip": "192.168.24.13",
"internal_api_ip": "192.168.24.13",
"management_ip": "192.168.24.13",
"enabled_networks": [
"management",
"storage",
"ctlplane",
"external",
"internal_api",
"storage_mgmt",
"tenant"
],
"ansible_host": "192.168.24.13"
}
},
"vars": {
"tripleo_role_name": "DistributedComputeHCI",
"tripleo_role_networks": [
"management",
"storage",
"ctlplane",
"external",
"internal_api",
"storage_mgmt",
"tenant"
],
"serial": "1",
"ansible_ssh_user": "heat-admin",
}


+ 41
- 20
tripleo_common/tests/test_inventory.py View File

@@ -77,7 +77,10 @@ class TestInventory(base.TestCase):
'Controller': {
'ctlplane': ['c-0.ctlplane.localdomain',
'c-1.ctlplane.localdomain',
'c-2.ctlplane.localdomain']},
'c-2.ctlplane.localdomain'],
'internal_api': ['c-0.internal_api.localdomain',
'c-1.internal_api.localdomain',
'c-2.internal_api.localdomain']},
'Compute': {
'ctlplane': ['cp-0.ctlplane.localdomain']},
'CustomRole': {
@@ -87,7 +90,10 @@ class TestInventory(base.TestCase):
'Controller': {
'ctlplane': ['x.x.x.1',
'x.x.x.2',
'x.x.x.3']},
'x.x.x.3'],
'internal_api': ['x.x.x.4',
'x.x.x.5',
'x.x.x.6']},
'Compute': {
'ctlplane': ['y.y.y.1']},
'CustomRole': {
@@ -190,20 +196,23 @@ class TestInventory(base.TestCase):
'vars': {'ansible_ssh_user': ansible_ssh_user,
'bootstrap_server_id': 'a',
'serial': 1,
'tripleo_role_name': 'Compute'}},
'tripleo_role_name': 'Compute',
'tripleo_role_networks': ['ctlplane']}},
'Controller': {
'hosts': ['c-0', 'c-1', 'c-2'],
'vars': {'ansible_ssh_user': ansible_ssh_user,
'bootstrap_server_id': 'a',
'serial': 1,
'tripleo_role_name': 'Controller'}},
'tripleo_role_name': 'Controller',
'tripleo_role_networks': ['ctlplane',
'internal_api']}},
'CustomRole': {
'hosts': ['cs-0'],
'vars': {'ansible_ssh_user': ansible_ssh_user,
'bootstrap_server_id': 'a',
'serial': 1,
'tripleo_role_name': 'CustomRole'}},
'tripleo_role_name': 'CustomRole',
'tripleo_role_networks': ['ctlplane']}},
'overcloud': {
'children': ['Compute', 'Controller', 'CustomRole'],
'vars': {
@@ -273,21 +282,25 @@ class TestInventory(base.TestCase):
'ansible_ssh_user': ansible_ssh_user,
'bootstrap_server_id': 'a',
'serial': 1,
'tripleo_role_name': 'Compute'}},
'tripleo_role_name': 'Compute',
'tripleo_role_networks': ['ctlplane']}},
'Controller': {
'hosts': ['c-0', 'c-1', 'c-2'],
'vars': {'ansible_python_interpreter': 'foo',
'ansible_ssh_user': ansible_ssh_user,
'bootstrap_server_id': 'a',
'serial': 1,
'tripleo_role_name': 'Controller'}},
'tripleo_role_name': 'Controller',
'tripleo_role_networks': ['ctlplane',
'internal_api']}},
'CustomRole': {
'hosts': ['cs-0'],
'vars': {'ansible_python_interpreter': 'foo',
'ansible_ssh_user': ansible_ssh_user,
'bootstrap_server_id': 'a',
'serial': 1,
'tripleo_role_name': 'CustomRole'}},
'tripleo_role_name': 'CustomRole',
'tripleo_role_networks': ['ctlplane']}},
'overcloud': {
'children': ['Compute', 'Controller', 'CustomRole'],
'vars': {
@@ -370,48 +383,56 @@ class TestInventory(base.TestCase):
'ansible_host': 'y.y.y.1',
'ctlplane_ip': 'y.y.y.1',
'deploy_server_id': 'd',
'enabled_networks': ['ctlplane'],
'ctlplane_hostname': 'cp-0.ctlplane.localdomain'}},
'vars': {'ansible_ssh_user': ansible_ssh_user,
'bootstrap_server_id': 'a',
'serial': 1,
'tripleo_role_name': 'Compute'}},
'tripleo_role_name': 'Compute',
'tripleo_role_networks': ['ctlplane']}},
'Controller': {
'hosts': {
'c-0': {
'ansible_host': 'x.x.x.1',
'ctlplane_ip': 'x.x.x.1',
'deploy_server_id': 'a',
'enabled_networks': ['ctlplane'],
'ctlplane_hostname': 'c-0.ctlplane.localdomain'},
'ctlplane_hostname': 'c-0.ctlplane.localdomain',
'internal_api_hostname':
'c-0.internal_api.localdomain',
'internal_api_ip': 'x.x.x.4'},
'c-1': {
'ansible_host': 'x.x.x.2',
'ctlplane_ip': 'x.x.x.2',
'deploy_server_id': 'b',
'enabled_networks': ['ctlplane'],
'ctlplane_hostname': 'c-1.ctlplane.localdomain'},
'ctlplane_hostname': 'c-1.ctlplane.localdomain',
'internal_api_hostname':
'c-1.internal_api.localdomain',
'internal_api_ip': 'x.x.x.5'},
'c-2': {
'ansible_host': 'x.x.x.3',
'ctlplane_ip': 'x.x.x.3',
'deploy_server_id': 'c',
'enabled_networks': ['ctlplane'],
'ctlplane_hostname': 'c-2.ctlplane.localdomain'}},
'ctlplane_hostname': 'c-2.ctlplane.localdomain',
'internal_api_hostname':
'c-2.internal_api.localdomain',
'internal_api_ip': 'x.x.x.6'}},
'vars': {'ansible_ssh_user': ansible_ssh_user,
'bootstrap_server_id': 'a',
'serial': 1,
'tripleo_role_name': 'Controller'}},
'tripleo_role_name': 'Controller',
'tripleo_role_networks': ['ctlplane',
'internal_api']}},
'CustomRole': {
'hosts': {
'cs-0': {
'ansible_host': 'z.z.z.1',
'ctlplane_ip': 'z.z.z.1',
'deploy_server_id': 'e',
'enabled_networks': ['ctlplane'],
'ctlplane_hostname': 'cs-0.ctlplane.localdomain'}},
'vars': {'ansible_ssh_user': ansible_ssh_user,
'bootstrap_server_id': 'a',
'serial': 1,
'tripleo_role_name': 'CustomRole'}},
'tripleo_role_name': 'CustomRole',
'tripleo_role_networks': ['ctlplane']}},
'overcloud': {'children': {'Compute': {},
'Controller': {},
'CustomRole': {}},


Loading…
Cancel
Save