Handle nested inventory groups in export_storage_ips
This is causing an exception to be raised in OSPdO during FFU as it will try to run ceph export on any stack with ceph-ansible enabled. Resolves: rhbz#2226845 Change-Id: I69e8ca7c18951a6fe7753b44636767d47efc7a6b
This commit is contained in:
parent
534fe49d29
commit
2e31655f5b
@ -174,10 +174,14 @@ def export_storage_ips(stack, config_download_dir=constants.DEFAULT_WORK_DIR,
|
||||
_('Could not read file %s') % file)
|
||||
LOG.error(e)
|
||||
mon_ips = []
|
||||
for mon_role in inventory_data['mons']['children'].keys():
|
||||
for hostname in inventory_data[mon_role]['hosts']:
|
||||
ip = inventory_data[mon_role]['hosts'][hostname][ceph_net_key]
|
||||
|
||||
def get_mon_ips(group):
|
||||
for hostname in inventory_data[group].get('hosts', {}):
|
||||
ip = inventory_data[group]['hosts'][hostname][ceph_net_key]
|
||||
mon_ips.append(ip)
|
||||
for child in inventory_data[group].get('children', {}):
|
||||
get_mon_ips(child)
|
||||
get_mon_ips('mons')
|
||||
|
||||
return mon_ips
|
||||
|
||||
|
@ -30,24 +30,9 @@ class TestExport(TestCase):
|
||||
|
||||
self.mock_open = mock.mock_open(read_data='{"an_key":"an_value"}')
|
||||
|
||||
ceph_inv = {
|
||||
'DistributedComputeHCI': {
|
||||
'hosts': {
|
||||
'dcn0-distributedcomputehci-0': {
|
||||
'foo_ip': '192.168.24.42'
|
||||
},
|
||||
'dcn0-distributedcomputehci-1': {
|
||||
'foo_ip': '192.168.8.8'
|
||||
}
|
||||
}
|
||||
},
|
||||
'mons': {
|
||||
'children': {
|
||||
'DistributedComputeHCI': {}
|
||||
}
|
||||
}
|
||||
}
|
||||
self.mock_open_ceph_inv = mock.mock_open(read_data=str(ceph_inv))
|
||||
self.mock_open_ceph_inv = mock.mock_open(read_data=str(
|
||||
self._get_test_inventory()
|
||||
))
|
||||
|
||||
ceph_global = {
|
||||
'service_net_map': {
|
||||
@ -65,6 +50,25 @@ class TestExport(TestCase):
|
||||
}
|
||||
self.mock_open_ceph_all = mock.mock_open(read_data=str(ceph_all))
|
||||
|
||||
def _get_test_inventory(self):
|
||||
return {
|
||||
'DistributedComputeHCI': {
|
||||
'hosts': {
|
||||
'dcn0-distributedcomputehci-0': {
|
||||
'foo_ip': '192.168.24.42'
|
||||
},
|
||||
'dcn0-distributedcomputehci-1': {
|
||||
'foo_ip': '192.168.8.8'
|
||||
}
|
||||
}
|
||||
},
|
||||
'mons': {
|
||||
'children': {
|
||||
'DistributedComputeHCI': {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def _get_stack_saved_output_item(self, output_key, working_dir):
|
||||
outputs = {
|
||||
'EndpointMap': dict(em_key='em_value'),
|
||||
@ -245,3 +249,32 @@ class TestExport(TestCase):
|
||||
self.assertEqual(data, expected)
|
||||
self.mock_open_ceph_all.assert_called_once_with(
|
||||
'/foo/dcn0/ceph-ansible/group_vars/all.yml', 'r')
|
||||
|
||||
|
||||
class TestExportNestedInventory(TestExport):
|
||||
def _get_test_inventory(self):
|
||||
return {
|
||||
'DistributedComputeHCI': {
|
||||
'hosts': {
|
||||
'dcn0-distributedcomputehci-0': {
|
||||
'foo_ip': '192.168.24.42'
|
||||
},
|
||||
'dcn0-distributedcomputehci-1': {
|
||||
'foo_ip': '192.168.8.8'
|
||||
}
|
||||
}
|
||||
},
|
||||
'stackfoo_mons': {
|
||||
'children': {
|
||||
'DistributedComputeHCI': {}
|
||||
}
|
||||
},
|
||||
'mons': {
|
||||
'children': {
|
||||
'stackfoo_mons': {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def test_export_storage_ips(self):
|
||||
return super().test_export_storage_ips()
|
||||
|
Loading…
Reference in New Issue
Block a user