]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: Make ceph-iscsi api user and password mandatory 35097/head
authorMatthew Oliver <moliver@suse.com>
Fri, 15 May 2020 00:56:14 +0000 (10:56 +1000)
committerMatthew Oliver <moliver@suse.com>
Tue, 19 May 2020 00:17:40 +0000 (00:17 +0000)
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>
src/pybind/mgr/cephadm/tests/test_cephadm.py
src/pybind/mgr/orchestrator/module.py
src/python-common/ceph/deployment/service_spec.py

index ad79a8f28263d880b9a98ccb85331cad595544ea..a2358ae2da28709073d9b378e7c7e156b4786042 100644 (file)
@@ -442,7 +442,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'")
@@ -473,7 +474,8 @@ class TestCephadm(object):
             (ServiceSpec('mds', service_id='fsname'), CephadmOrchestrator.apply_mds),
             (RGWSpec(rgw_realm='realm', rgw_zone='zone'), 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 958005221483b4425451a314a09b744a2f443b26..d64e302bc39908f54fd58e44738812c13bb9a1c5 100644 (file)
@@ -777,11 +777,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:
@@ -791,6 +795,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),
         )
@@ -980,12 +986,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,
@@ -996,6 +1006,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')