diff --git a/tripleoclient/tests/test_utils.py b/tripleoclient/tests/test_utils.py index 03ff7009e..76398ea19 100644 --- a/tripleoclient/tests/test_utils.py +++ b/tripleoclient/tests/test_utils.py @@ -792,6 +792,59 @@ class TestWaitForStackUtil(TestCase): utils.check_ceph_ansible(res_reg.get('resource_registry', {}), 'DeployOvercloud') + def test_check_deployed_ceph_stage(self): + + env = { + 'resource_registry': { + 'OS::Tripleo::Services::CephMon': '/path/cephadm/ceph-mon.yml', + 'OS::TripleO::Services::CephMgr': '/path/cephadm/ceph-mgr.yml', + 'OS::TripleO::Services::CephMon': '/path/cephadm/ceph-mon.yml', + 'OS::TripleO::Services::CephOSD': '/path/cephadm/ceph-osd.yml', + 'OS::TripleO::Services::CephMds': '/path/cephadm/ceph-mds.yml', + 'OS::TripleO::Services::CephNfs': '/path/cephadm/ceph-nfs.yml', + 'OS::TripleO::Services::CephRgw': '/path/cephadm/ceph-rgw.yml', + }, + 'parameter_defaults': { + 'DeployedCeph': True + } + } + + utils.check_deployed_ceph_stage(env) + + def test_check_deployed_ceph_stage_fail(self): + + env = { + 'resource_registry': { + 'OS::Tripleo::Services::CephMon': '/path/cephadm/ceph-mon.yml', + 'OS::TripleO::Services::CephMgr': '/path/cephadm/ceph-mgr.yml', + 'OS::TripleO::Services::CephMon': '/path/cephadm/ceph-mon.yml', + 'OS::TripleO::Services::CephOSD': '/path/cephadm/ceph-osd.yml', + 'OS::TripleO::Services::CephMds': '/path/cephadm/ceph-mds.yml', + 'OS::TripleO::Services::CephNfs': '/path/cephadm/ceph-nfs.yml', + 'OS::TripleO::Services::CephRgw': '/path/cephadm/ceph-rgw.yml', + }, + 'parameter_defaults': { + 'DeployedCeph': False + } + } + + with self.assertRaises(exceptions.InvalidConfiguration): + utils.check_deployed_ceph_stage(env) + + def test_check_deployed_ceph_stage_external(self): + + env = { + 'resource_registry': { + 'OS::Tripleo::Services::CephExternal': '/path/cephadm/ceph-client.yml', # noqa E501 + }, + 'parameter_defaults': { + 'DeployedCeph': False + } + } + + with self.assertRaises(exceptions.InvalidConfiguration): + utils.check_deployed_ceph_stage(env) + def test_check_swift_and_rgw(self): stack_reg = { 'OS::TripleO::Services::SwiftProxy': 'OS::Heat::None', diff --git a/tripleoclient/utils.py b/tripleoclient/utils.py index 7e31f879f..07039a673 100644 --- a/tripleoclient/utils.py +++ b/tripleoclient/utils.py @@ -1077,6 +1077,51 @@ def check_ceph_ansible(resource_registry, stage): 'file.') +def check_deployed_ceph_stage(environment): + """Raises an exception if Ceph is being deployed without DeployedCeph:True. + + If Ceph is not being deployed or DeployedCeph is true, then return + nothing, so the program that calls this function can continue without + error. This function also looks for the external Ceph Heat resource to + make sure in this scenario an error is not raised regardless of the + DeployedCeph boolean value. + """ + + resource_registry = environment.get('resource_registry', {}) + + if not resource_registry: + return + + ceph_external = environment.get('resource_registry', {}).get( + 'OS::TripleO::Services::CephExternal', 'OS::Heat::None') + + if ceph_external != "OS::Heat::None": + return + + # it's not an external Ceph cluster, let's evaluate the DeployedCeph param + # and the Ceph resources provided + deployed_ceph = environment.get('parameter_defaults', + {}).get('DeployedCeph', False) + + # for each ceph resource, if the path contains cephadm and the DeployedCeph + # boolean is not True, raise an exception and guide the operator through + # the right path of deploying ceph + + for name, path in resource_registry.items(): + if 'Ceph' in name and 'cephadm' in path and not deployed_ceph: + raise exceptions.InvalidConfiguration('Ceph deployment is not ' + 'available anymore during ' + 'overcloud deploy. If you ' + 'want to deploy Ceph, ' + 'please see "openstack ' + ' overcloud ceph deploy ' + '--help" to deploy ceph ' + ' before deploying the ' + 'overcloud and then include ' + 'the cephadm environment ' + 'file.') + + def check_ceph_fsid_matches_env_files(old_env, environment): """Check CephClusterFSID against proposed env files diff --git a/tripleoclient/v1/overcloud_deploy.py b/tripleoclient/v1/overcloud_deploy.py index c9bb9e64e..0861845bc 100644 --- a/tripleoclient/v1/overcloud_deploy.py +++ b/tripleoclient/v1/overcloud_deploy.py @@ -355,6 +355,9 @@ class DeployOvercloud(command.Command): # warning if necessary self._check_limit_skiplist_warning(env) + # check if we're trying to deploy ceph during the overcloud deployment + utils.check_deployed_ceph_stage(env) + old_stack_env = utils.get_saved_stack_env( self.working_dir, parsed_args.stack) if old_stack_env: diff --git a/tripleoclient/v1/tripleo_deploy.py b/tripleoclient/v1/tripleo_deploy.py index 95d37fdd3..fb7c0e830 100644 --- a/tripleoclient/v1/tripleo_deploy.py +++ b/tripleoclient/v1/tripleo_deploy.py @@ -758,6 +758,9 @@ class Deploy(command.Command): environments, self.tht_render, parsed_args.templates, cleanup=parsed_args.cleanup) + # check if we're trying to deploy ceph during the overcloud deployment + utils.check_deployed_ceph_stage(env) + roles_data = utils.fetch_roles_file( roles_file_path, parsed_args.templates)