Merge "cephadm support for 'openstack overcloud export ceph'" into stable/wallaby
This commit is contained in:
commit
559cc8cbba
tripleoclient
@ -184,12 +184,17 @@ def export_storage_ips(stack, config_download_dir=constants.DEFAULT_WORK_DIR,
|
|||||||
|
|
||||||
def export_ceph(stack, cephx,
|
def export_ceph(stack, cephx,
|
||||||
config_download_dir=constants.DEFAULT_WORK_DIR,
|
config_download_dir=constants.DEFAULT_WORK_DIR,
|
||||||
mon_ips=[]):
|
mon_ips=[], config_download_files=[]):
|
||||||
# Return a map of ceph data for a list item in CephExternalMultiConfig
|
# Return a map of ceph data for a list item in CephExternalMultiConfig
|
||||||
# by parsing files within the config_download_dir of a certain stack
|
# by parsing files within the config_download_dir of a certain stack
|
||||||
|
|
||||||
|
if len(config_download_files) == 0:
|
||||||
|
config_download_files = os.listdir(os.path.join(
|
||||||
|
config_download_dir, stack))
|
||||||
|
if 'ceph-ansible' in config_download_files:
|
||||||
if len(mon_ips) == 0:
|
if len(mon_ips) == 0:
|
||||||
mon_ips = export_storage_ips(stack, config_download_dir)
|
mon_ips = export_storage_ips(stack, config_download_dir)
|
||||||
|
external_cluster_mon_ips = str(','.join(mon_ips))
|
||||||
|
|
||||||
# Use ceph-ansible group_vars/all.yml to get remaining values
|
# Use ceph-ansible group_vars/all.yml to get remaining values
|
||||||
ceph_ansible_all = "ceph-ansible/group_vars/all.yml"
|
ceph_ansible_all = "ceph-ansible/group_vars/all.yml"
|
||||||
@ -197,28 +202,45 @@ def export_ceph(stack, cephx,
|
|||||||
with open(file, 'r') as ff:
|
with open(file, 'r') as ff:
|
||||||
try:
|
try:
|
||||||
ceph_data = yaml.safe_load(ff)
|
ceph_data = yaml.safe_load(ff)
|
||||||
except Exception as e:
|
except yaml.MarkedYAMLError as e:
|
||||||
LOG.error(
|
LOG.error(
|
||||||
_('Could not read file %s') % file)
|
_('Could not read file %s') % file)
|
||||||
LOG.error(e)
|
LOG.error(e)
|
||||||
|
cluster = ceph_data['cluster']
|
||||||
|
fsid = ceph_data['fsid']
|
||||||
|
|
||||||
|
if 'cephadm' in config_download_files:
|
||||||
|
ceph_client = "cephadm/ceph_client.yml"
|
||||||
|
file = os.path.join(config_download_dir, stack, ceph_client)
|
||||||
|
with open(file, 'r') as ff:
|
||||||
|
try:
|
||||||
|
ceph_data = yaml.safe_load(ff)
|
||||||
|
except yaml.MarkedYAMLError as e:
|
||||||
|
LOG.error(
|
||||||
|
_('Could not read file %s') % file)
|
||||||
|
LOG.error(e)
|
||||||
|
external_cluster_mon_ips = ceph_data['external_cluster_mon_ips']
|
||||||
|
cluster = ceph_data['tripleo_ceph_client_cluster']
|
||||||
|
fsid = ceph_data['tripleo_ceph_client_fsid']
|
||||||
|
|
||||||
|
# set cephx_keys
|
||||||
for key in ceph_data['keys']:
|
for key in ceph_data['keys']:
|
||||||
if key['name'] == 'client.' + str(cephx):
|
if key['name'] == 'client.' + str(cephx):
|
||||||
cephx_keys = [key]
|
cephx_keys = [key]
|
||||||
|
# set ceph_conf_overrides
|
||||||
ceph_conf_overrides = {}
|
ceph_conf_overrides = {}
|
||||||
ceph_conf_overrides['client'] = {}
|
ceph_conf_overrides['client'] = {}
|
||||||
ceph_conf_overrides['client']['keyring'] = '/etc/ceph/' \
|
ceph_conf_overrides['client']['keyring'] = '/etc/ceph/' \
|
||||||
+ ceph_data['cluster'] \
|
+ cluster \
|
||||||
+ '.client.' + cephx \
|
+ '.client.' + cephx \
|
||||||
+ '.keyring'
|
+ '.keyring'
|
||||||
# Combine extracted data into one map to return
|
# Combine extracted data into one map to return
|
||||||
data = {}
|
data = {}
|
||||||
data['external_cluster_mon_ips'] = str(','.join(mon_ips))
|
data['external_cluster_mon_ips'] = external_cluster_mon_ips
|
||||||
data['keys'] = cephx_keys
|
data['keys'] = cephx_keys
|
||||||
data['ceph_conf_overrides'] = ceph_conf_overrides
|
data['ceph_conf_overrides'] = ceph_conf_overrides
|
||||||
data['cluster'] = ceph_data['cluster']
|
data['cluster'] = cluster
|
||||||
data['fsid'] = ceph_data['fsid']
|
data['fsid'] = fsid
|
||||||
data['dashboard_enabled'] = False
|
data['dashboard_enabled'] = False
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
@ -238,7 +238,8 @@ class TestExport(TestCase):
|
|||||||
with mock.patch('builtins.open', self.mock_open_ceph_all):
|
with mock.patch('builtins.open', self.mock_open_ceph_all):
|
||||||
data = export.export_ceph('dcn0', 'openstack',
|
data = export.export_ceph('dcn0', 'openstack',
|
||||||
config_download_dir='/foo',
|
config_download_dir='/foo',
|
||||||
mon_ips=['192.168.24.42'])
|
mon_ips=['192.168.24.42'],
|
||||||
|
config_download_files=['ceph-ansible'])
|
||||||
self.assertEqual(data, expected)
|
self.assertEqual(data, expected)
|
||||||
self.mock_open_ceph_all.assert_called_once_with(
|
self.mock_open_ceph_all.assert_called_once_with(
|
||||||
'/foo/dcn0/ceph-ansible/group_vars/all.yml', 'r')
|
'/foo/dcn0/ceph-ansible/group_vars/all.yml', 'r')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user