Use ceph_mon_network to find Ceph monitor IPs for export
When 'openstack overcloud export ceph' is run, do not assume the storage_ip will be set. Instead, find the ceph_mon_network name in the service_net_map, e.g. 'storage' or 'ctlplane', and then use that network name to get the IP from the inventory. Closes-Bug: #1922788 Change-Id: I962bed846b2cae7206c76f883f9294d366031245
This commit is contained in:
parent
446667a851
commit
1e69013691
|
@ -122,7 +122,22 @@ def export_stack(heat, stack, should_filter=False,
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
def export_storage_ips(stack, config_download_dir=constants.DEFAULT_WORK_DIR):
|
def export_ceph_net_key(stack, config_download_dir=constants.DEFAULT_WORK_DIR):
|
||||||
|
file = os.path.join(config_download_dir, stack, "global_vars.yaml")
|
||||||
|
with open(file, 'r') as ff:
|
||||||
|
try:
|
||||||
|
global_data = yaml.safe_load(ff)
|
||||||
|
except Exception as e:
|
||||||
|
LOG.error(
|
||||||
|
_('Could not read file %s') % file)
|
||||||
|
LOG.error(e)
|
||||||
|
return str(global_data['service_net_map']['ceph_mon_network']) + '_ip'
|
||||||
|
|
||||||
|
|
||||||
|
def export_storage_ips(stack, config_download_dir=constants.DEFAULT_WORK_DIR,
|
||||||
|
ceph_net_key=''):
|
||||||
|
if len(ceph_net_key) == 0:
|
||||||
|
ceph_net_key = export_ceph_net_key(stack, config_download_dir)
|
||||||
inventory_file = "ceph-ansible/inventory.yml"
|
inventory_file = "ceph-ansible/inventory.yml"
|
||||||
file = os.path.join(config_download_dir, stack, inventory_file)
|
file = os.path.join(config_download_dir, stack, inventory_file)
|
||||||
with open(file, 'r') as ff:
|
with open(file, 'r') as ff:
|
||||||
|
@ -135,7 +150,7 @@ def export_storage_ips(stack, config_download_dir=constants.DEFAULT_WORK_DIR):
|
||||||
mon_ips = []
|
mon_ips = []
|
||||||
for mon_role in inventory_data['mons']['children'].keys():
|
for mon_role in inventory_data['mons']['children'].keys():
|
||||||
for hostname in inventory_data[mon_role]['hosts']:
|
for hostname in inventory_data[mon_role]['hosts']:
|
||||||
ip = inventory_data[mon_role]['hosts'][hostname]['storage_ip']
|
ip = inventory_data[mon_role]['hosts'][hostname][ceph_net_key]
|
||||||
mon_ips.append(ip)
|
mon_ips.append(ip)
|
||||||
|
|
||||||
return mon_ips
|
return mon_ips
|
||||||
|
|
|
@ -43,7 +43,10 @@ class TestExport(TestCase):
|
||||||
'DistributedComputeHCI': {
|
'DistributedComputeHCI': {
|
||||||
'hosts': {
|
'hosts': {
|
||||||
'dcn0-distributedcomputehci-0': {
|
'dcn0-distributedcomputehci-0': {
|
||||||
'storage_ip': '192.168.24.42'
|
'foo_ip': '192.168.24.42'
|
||||||
|
},
|
||||||
|
'dcn0-distributedcomputehci-1': {
|
||||||
|
'foo_ip': '192.168.8.8'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -55,6 +58,13 @@ class TestExport(TestCase):
|
||||||
}
|
}
|
||||||
self.mock_open_ceph_inv = mock.mock_open(read_data=str(ceph_inv))
|
self.mock_open_ceph_inv = mock.mock_open(read_data=str(ceph_inv))
|
||||||
|
|
||||||
|
ceph_global = {
|
||||||
|
'service_net_map': {
|
||||||
|
'ceph_mon_network': 'storage'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.mock_open_ceph_global = mock.mock_open(read_data=str(ceph_global))
|
||||||
|
|
||||||
ceph_all = {
|
ceph_all = {
|
||||||
'cluster': 'dcn0',
|
'cluster': 'dcn0',
|
||||||
'fsid': 'a5a22d37-e01f-4fa0-a440-c72585c7487f',
|
'fsid': 'a5a22d37-e01f-4fa0-a440-c72585c7487f',
|
||||||
|
@ -155,11 +165,20 @@ class TestExport(TestCase):
|
||||||
|
|
||||||
self.assertEqual(mock_passwords, data)
|
self.assertEqual(mock_passwords, data)
|
||||||
|
|
||||||
|
def test_export_ceph_net_key(self):
|
||||||
|
with mock.patch('six.moves.builtins.open', self.mock_open_ceph_global):
|
||||||
|
mon_key = export.export_ceph_net_key('dcn0',
|
||||||
|
config_download_dir='/foo')
|
||||||
|
self.assertEqual(mon_key, 'storage_ip')
|
||||||
|
self.mock_open_ceph_global.assert_called_once_with(
|
||||||
|
'/foo/dcn0/global_vars.yaml', 'r')
|
||||||
|
|
||||||
def test_export_storage_ips(self):
|
def test_export_storage_ips(self):
|
||||||
with mock.patch('six.moves.builtins.open', self.mock_open_ceph_inv):
|
with mock.patch('six.moves.builtins.open', self.mock_open_ceph_inv):
|
||||||
storage_ips = export.export_storage_ips('dcn0',
|
storage_ips = export.export_storage_ips('dcn0',
|
||||||
config_download_dir='/foo')
|
config_download_dir='/foo',
|
||||||
self.assertEqual(storage_ips, ['192.168.24.42'])
|
ceph_net_key='foo_ip')
|
||||||
|
self.assertEqual(storage_ips, ['192.168.24.42', '192.168.8.8'])
|
||||||
self.mock_open_ceph_inv.assert_called_once_with(
|
self.mock_open_ceph_inv.assert_called_once_with(
|
||||||
'/foo/dcn0/ceph-ansible/inventory.yml', 'r')
|
'/foo/dcn0/ceph-ansible/inventory.yml', 'r')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue