From 4549cbcf53b71133d9740a9badc12def7f0f8dd8 Mon Sep 17 00:00:00 2001 From: Matthew Oliver Date: Fri, 15 May 2020 10:56:14 +1000 Subject: [PATCH] cephadm: Make ceph-iscsi api user and password mandatory The api user and password is required in order to use the API so let's make these mandatory. The `ceph orch daemon add iscsi` now has them mandatory: ceph orch daemon add iscsi If your using apply with a yaml file, the validate_add in the spec now checks for these too. Signed-off-by: Matthew Oliver (cherry picked from commit a36165b8dacaae3ab673a3e79f831a0de659341b) --- src/pybind/mgr/cephadm/tests/test_cephadm.py | 6 ++++-- src/pybind/mgr/orchestrator/module.py | 12 ++++++++++++ src/python-common/ceph/deployment/service_spec.py | 10 ++++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/pybind/mgr/cephadm/tests/test_cephadm.py b/src/pybind/mgr/cephadm/tests/test_cephadm.py index 07a9cdb538d84..f3e582867c4f8 100644 --- a/src/pybind/mgr/cephadm/tests/test_cephadm.py +++ b/src/pybind/mgr/cephadm/tests/test_cephadm.py @@ -453,7 +453,8 @@ class TestCephadm(object): def test_iscsi(self, cephadm_module): with self._with_host(cephadm_module, 'test'): ps = PlacementSpec(hosts=['test'], count=1) - spec = IscsiServiceSpec('name', pool='pool', placement=ps) + spec = IscsiServiceSpec('name', pool='pool', api_user='user', + api_password='password', placement=ps) c = cephadm_module.add_iscsi(spec) [out] = wait(cephadm_module, c) match_glob(out, "Deployed iscsi.name.* on host 'test'") @@ -504,7 +505,8 @@ class TestCephadm(object): ) ), CephadmOrchestrator.apply_rgw), (NFSServiceSpec('name', pool='pool', namespace='namespace'), CephadmOrchestrator.apply_nfs), - (IscsiServiceSpec('name', pool='pool'), CephadmOrchestrator.apply_iscsi), + (IscsiServiceSpec('name', pool='pool', api_user='user', api_password='password'), + CephadmOrchestrator.apply_iscsi), ] ) @mock.patch("cephadm.module.CephadmOrchestrator._run_cephadm", _run_cephadm('{}')) diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py index 5434bc4d3c3fd..6a076429cd54b 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -893,11 +893,15 @@ Usage: @_cli_write_command( 'orch daemon add iscsi', 'name=pool,type=CephString ' + 'name=api_user,type=CephString ' + 'name=api_password,type=CephString ' 'name=trusted_ip_list,type=CephString,req=false ' 'name=placement,type=CephString,req=false', 'Start iscsi daemon(s)') def _iscsi_add(self, pool: str, + api_user: str, + api_password: str, trusted_ip_list: Optional[str] = None, placement: Optional[str] = None, inbuf: Optional[str] = None) -> HandleCommandResult: @@ -907,6 +911,8 @@ Usage: spec = IscsiServiceSpec( service_id='iscsi', pool=pool, + api_user=api_user, + api_password=api_password, trusted_ip_list=trusted_ip_list, placement=PlacementSpec.from_string(placement), ) @@ -1096,12 +1102,16 @@ Usage: @_cli_write_command( 'orch apply iscsi', 'name=pool,type=CephString ' + 'name=api_user,type=CephString ' + 'name=api_password,type=CephString ' 'name=trusted_ip_list,type=CephString,req=false ' 'name=placement,type=CephString,req=false ' 'name=unmanaged,type=CephBool,req=false', 'Scale an iSCSI service') def _apply_iscsi(self, pool: str, + api_user: str, + api_password: str, trusted_ip_list: Optional[str] = None, placement: Optional[str] = None, unmanaged: bool = False, @@ -1112,6 +1122,8 @@ Usage: spec = IscsiServiceSpec( service_id='iscsi', pool=pool, + api_user=api_user, + api_password=api_password, trusted_ip_list=trusted_ip_list, placement=PlacementSpec.from_string(placement), unmanaged=unmanaged, diff --git a/src/python-common/ceph/deployment/service_spec.py b/src/python-common/ceph/deployment/service_spec.py index c6195ddf0c560..9e05293d8f30e 100644 --- a/src/python-common/ceph/deployment/service_spec.py +++ b/src/python-common/ceph/deployment/service_spec.py @@ -600,9 +600,15 @@ class IscsiServiceSpec(ServiceSpec): if not self.api_secure and self.ssl_cert and self.ssl_key: self.api_secure = True - def validate_add(self): - servicespec_validate_add(self) + def validate(self): + super(IscsiServiceSpec, self).validate() if not self.pool: raise ServiceSpecValidationError( 'Cannot add ISCSI: No Pool specified') + if not self.api_user: + raise ServiceSpecValidationError( + 'Cannot add ISCSI: No Api user specified') + if not self.api_password: + raise ServiceSpecValidationError( + 'Cannot add ISCSI: No Api password specified') -- 2.39.5