]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: Make ceph-iscsi api user and password mandatory
authorMatthew Oliver <moliver@suse.com>
Fri, 15 May 2020 00:56:14 +0000 (10:56 +1000)
committerSebastian Wagner <sebastian.wagner@suse.com>
Tue, 2 Jun 2020 12:58:27 +0000 (14:58 +0200)
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 <pool> <api_user> <api_password>

If your using apply with a yaml file, the validate_add in the spec now
checks for these too.

Signed-off-by: Matthew Oliver <moliver@suse.com>
(cherry picked from commit a36165b8dacaae3ab673a3e79f831a0de659341b)

src/pybind/mgr/cephadm/tests/test_cephadm.py
src/pybind/mgr/orchestrator/module.py
src/python-common/ceph/deployment/service_spec.py

index 07a9cdb538d849a64ae5b90f79dafcc3653fdef1..f3e582867c4f81a97ae0df623dba4529ff220596 100644 (file)
@@ -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('{}'))
index 5434bc4d3c3fd0ddc8ff840c42dc7f2e980abbc9..6a076429cd54beb3df95ff53fd20bb25db75b3ae 100644 (file)
@@ -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,
index c6195ddf0c560f5e5c22ae969526446938ff36e2..9e05293d8f30e2b712359571afc52a227daf766b 100644 (file)
@@ -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')