]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/orch: break out apply_$type() in orchestrator.py interface
authorSage Weil <sage@redhat.com>
Thu, 13 Feb 2020 14:17:58 +0000 (08:17 -0600)
committerSage Weil <sage@redhat.com>
Thu, 13 Feb 2020 15:43:38 +0000 (09:43 -0600)
Also clean up the method descriptions.

Signed-off-by: Sage Weil <sage@redhat.com>
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/tests/test_cephadm.py
src/pybind/mgr/orchestrator.py
src/pybind/mgr/orchestrator_cli/module.py
src/pybind/mgr/rook/module.py

index 53cb3596eec2c928ce060a6989069f8c7308f6ac..cea6c6b3b4c32f4043c56c99526b743bbd491b6a 100644 (file)
@@ -1490,19 +1490,6 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin):
             return self._remove_daemon(args)
         return self._get_daemons(daemon_type=service_type).then(_filter)
 
-    def service_apply(self, spec):
-        if spec.service_type == 'mgr':
-            return self.update_mgrs(spec)
-        if spec.service_type == 'mon':
-            return self.update_mons(spec)
-        if spec.service_type == 'mds':
-            return self.update_mds(spec)
-        if spec.service_type == 'rgw':
-            return self.update_rgw(spec)
-        if spec.service_type == 'rbd-mirror':
-            return self.update_rbd_mirror(spec)
-        raise NotImplementedError()
-
     def get_inventory(self, node_filter=None, refresh=False):
         """
         Return the storage inventory of nodes matching the given filter.
@@ -1899,7 +1886,7 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin):
 
         return self._get_daemons('mon').then(add_mons)
 
-    def update_mons(self, spec):
+    def apply_mon(self, spec):
         # type: (orchestrator.ServiceSpec) -> orchestrator.Completion
         """
         Adjust the number of cluster managers.
@@ -1975,7 +1962,7 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin):
         return self._add_new_daemon('mgr', daemons, spec, self._create_mgr)
 
     @with_daemons('mgr')
-    def update_mgrs(self, spec, daemons):
+    def apply_mgr(self, spec, daemons):
         # type: (orchestrator.ServiceSpec, List[orchestrator.DaemonDescription]) -> orchestrator.Completion
         """
         Adjust the number of cluster managers.
@@ -2071,7 +2058,7 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin):
 
         return self._get_daemons('mds').then(_add_mds)
 
-    def update_mds(self, spec):
+    def apply_mds(self, spec):
         # type: (orchestrator.ServiceSpec) -> AsyncCompletion
         spec = NodeAssignment(spec=spec, get_hosts_func=self._get_hosts, service_type='mds').load()
 
@@ -2122,7 +2109,7 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin):
         })
         return self._create_daemon('rgw', rgw_id, host, keyring=keyring)
 
-    def update_rgw(self, spec):
+    def apply_rgw(self, spec):
         spec = NodeAssignment(spec=spec, get_hosts_func=self._get_hosts, service_type='rgw').load()
         return self._update_service('rgw', self.add_rgw, spec)
 
@@ -2147,7 +2134,7 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin):
         return self._create_daemon('rbd-mirror', daemon_id, host,
                                    keyring=keyring)
 
-    def update_rbd_mirror(self, spec):
+    def apply_rbd_mirror(self, spec):
         spec = NodeAssignment(spec=spec, get_hosts_func=self._get_hosts, service_type='rbd-mirror').load()
         return self._update_service('rbd-mirror', self.add_rbd_mirror, spec)
 
index e201c5b29b9fe58f11e95904654bd1f1f129e22e..929edf3c5990426e9f82f28bb22f13752d311fbb 100644 (file)
@@ -110,7 +110,7 @@ class TestCephadm(object):
     def test_mon_update(self, _send_command, _get_connection, cephadm_module):
         with self._with_host(cephadm_module, 'test'):
             ps = PlacementSpec(hosts=['test:0.0.0.0=a'], count=1)
-            c = cephadm_module.update_mons(ServiceSpec(placement=ps))
+            c = cephadm_module.apply_mon(ServiceSpec(placement=ps))
             assert wait(cephadm_module, c) == ["Deployed mon.a on host 'test'"]
 
     @mock.patch("cephadm.module.CephadmOrchestrator._run_cephadm", _run_cephadm('[]'))
@@ -120,7 +120,7 @@ class TestCephadm(object):
     def test_mgr_update(self, _send_command, _get_connection, cephadm_module):
         with self._with_host(cephadm_module, 'test'):
             ps = PlacementSpec(hosts=['test:0.0.0.0=a'], count=1)
-            c = cephadm_module.update_mgrs(ServiceSpec(placement=ps))
+            c = cephadm_module.apply_mgr(ServiceSpec(placement=ps))
             [out] = wait(cephadm_module, c)
             match_glob(out, "Deployed mgr.* on host 'test'")
 
@@ -193,7 +193,7 @@ class TestCephadm(object):
                 match_glob(out, "Deployed rgw.realm.zone1.host1.* on host 'host1'")
 
                 ps = PlacementSpec(hosts=['host1', 'host2'], count=2)
-                c = cephadm_module.update_rgw(RGWSpec('realm', 'zone1', placement=ps))
+                c = cephadm_module.apply_rgw(RGWSpec('realm', 'zone1', placement=ps))
                 [out] = wait(cephadm_module, c)
                 match_glob(out, "Deployed rgw.realm.zone1.host2.* on host 'host2'")
 
@@ -217,7 +217,7 @@ class TestCephadm(object):
 
                 with pytest.raises(OrchestratorError):
                     ps = PlacementSpec(hosts=['host1', 'host2'], count=2)
-                    c = cephadm_module.update_rgw(RGWSpec('realm', 'zone1', placement=ps))
+                    c = cephadm_module.apply_rgw(RGWSpec('realm', 'zone1', placement=ps))
                     [out] = wait(cephadm_module, c)
 
 
index 08868c7f8ce04368aa877d0f8fd7d3c2cee90f78..6a6ae9959612f0dcba45a9bc8b16431ec826e24e 100644 (file)
@@ -922,15 +922,6 @@ class Orchestrator(object):
         #assert action in ["start", "stop", "reload, "restart", "redeploy"]
         raise NotImplementedError()
 
-    def service_apply(self, spec):
-        # type: (ServiceSpec) -> Completion
-        """
-        Create or update a service.
-
-        :pram spec: a ServiceSpec (or derivative type)
-        """
-        raise NotImplementedError()
-
     def create_osds(self, drive_groups):
         # type: (List[DriveGroupSpec]) -> Completion
         """
@@ -962,32 +953,62 @@ class Orchestrator(object):
 
     def add_mon(self, spec):
         # type: (ServiceSpec) -> Completion
-        """Create a new mon daemon"""
+        """Create mon daemon(s)"""
+        raise NotImplementedError()
+
+    def apply_mon(self, spec):
+        # type: (ServiceSpec) -> Completion
+        """Update mon cluster"""
         raise NotImplementedError()
 
     def add_mgr(self, spec):
         # type: (ServiceSpec) -> Completion
-        """Create a new mgr daemon"""
+        """Create mgr daemon(s)"""
+        raise NotImplementedError()
+
+    def apply_mgr(self, spec):
+        # type: (ServiceSpec) -> Completion
+        """Update mgr cluster"""
         raise NotImplementedError()
 
     def add_mds(self, spec):
         # type: (ServiceSpec) -> Completion
-        """Create a new MDS cluster"""
+        """Create MDS daemon(s)"""
+        raise NotImplementedError()
+
+    def apply_mds(self, spec):
+        # type: (ServiceSpec) -> Completion
+        """Update MDS cluster"""
         raise NotImplementedError()
 
     def add_rbd_mirror(self, spec):
         # type: (ServiceSpec) -> Completion
-        """Create rbd-mirror cluster"""
+        """Create rbd-mirror daemon(s)"""
+        raise NotImplementedError()
+
+    def apply_rbd_mirror(self, spec):
+        # type: (ServiceSpec) -> Completion
+        """Update rbd-mirror cluster"""
         raise NotImplementedError()
 
     def add_nfs(self, spec):
         # type: (NFSServiceSpec) -> Completion
-        """Create a new MDS cluster"""
+        """Create NFS daemon(s)"""
+        raise NotImplementedError()
+
+    def apply_nfs(self, spec):
+        # type: (NFSServiceSpec) -> Completion
+        """Update NFS cluster"""
         raise NotImplementedError()
 
     def add_rgw(self, spec):
         # type: (RGWSpec) -> Completion
-        """Create a new MDS zone"""
+        """Create RGW daemon(s)"""
+        raise NotImplementedError()
+
+    def apply_rgw(self, spec):
+        # type: (RGWSpec) -> Completion
+        """Update RGW cluster"""
         raise NotImplementedError()
 
     def upgrade_check(self, image, version):
index 66031bf9cf19fbe528d285d53bb7014bc3e35f47..09762d21b660a23d2a2807db1a95b3d2dec92405 100644 (file)
@@ -574,7 +574,7 @@ Usage:
 
         spec = orchestrator.ServiceSpec(placement=placement)
 
-        completion = self.service_apply(spec)
+        completion = self.apply_mgr(spec)
         self._orchestrator_wait([completion])
         orchestrator.raise_if_exception(completion)
         return HandleCommandResult(stdout=completion.result_str())
@@ -594,7 +594,7 @@ Usage:
 
         spec = orchestrator.ServiceSpec(placement=placement)
 
-        completion = self.service_apply(spec)
+        completion = self.apply_mon(spec)
         self._orchestrator_wait([completion])
         orchestrator.raise_if_exception(completion)
         return HandleCommandResult(stdout=completion.result_str())
@@ -614,7 +614,7 @@ Usage:
             fs_name,
             placement=placement)
 
-        completion = self.service_apply(spec)
+        completion = self.apply_mds(spec)
         self._orchestrator_wait([completion])
         orchestrator.raise_if_exception(completion)
         return HandleCommandResult(stdout=completion.result_str())
@@ -628,7 +628,7 @@ Usage:
     def _apply_rbd_mirror(self, num, label=None, hosts=[]):
         spec = orchestrator.ServiceSpec(
             placement=orchestrator.PlacementSpec(hosts=hosts, count=num, label=label))
-        completion = self.service_apply(spec)
+        completion = self.apply_rbd_mirror(spec)
         self._orchestrator_wait([completion])
         orchestrator.raise_if_exception(completion)
         return HandleCommandResult(stdout=completion.result_str())
@@ -646,7 +646,7 @@ Usage:
             rgw_realm=realm_name,
             rgw_zone=zone_name,
             placement=orchestrator.PlacementSpec(hosts=hosts, label=label, count=num))
-        completion = self.service_apply(spec)
+        completion = self.apply_rgw(spec)
         self._orchestrator_wait([completion])
         orchestrator.raise_if_exception(completion)
         return HandleCommandResult(stdout=completion.result_str())
@@ -664,7 +664,7 @@ Usage:
             svc_id,
             placement=orchestrator.PlacementSpec(label=label, hosts=hosts, count=num),
         )
-        completion = self.service_apply(spec)
+        completion = self.apply_nfs(spec)
         self._orchestrator_wait([completion])
         return HandleCommandResult(stdout=completion.result_str())
 
index 37ff39b18740ab22a2624b9078c63a073d111b72..f5f4a2fa63efee6ee79397d8fd1c3f2655edb38f 100644 (file)
@@ -340,17 +340,7 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator):
                 'NFS', service_name, lambda: self.rook_cluster.rm_service('cephnfses', service_name)
             )
 
-    def service_apply(self, spec):
-        if spec.service_type == 'mon':
-            return self.update_mons(spec)
-        if spec.service_type == 'mgr':
-            raise NotImplementedError()
-        if spec.service_type == 'mds':
-            return self.update_mds(spec)
-        if spec.service_type == 'nfs':
-            return self.update_nfs(spec)
-
-    def update_mons(self, spec):
+    def apply_mon(self, spec):
         # type: (orchestrator.ServiceSpec) -> RookCompletion
         if spec.placement.hosts or spec.placement.label:
             raise RuntimeError("Host list or label is not supported by rook.")
@@ -361,7 +351,7 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator):
             mgr=self
         )
 
-    def update_mds(self, spec):
+    def apply_mds(self, spec):
         # type: (orchestrator.ServiceSpec) -> RookCompletion
         num = spec.count
         return write_completion(
@@ -370,7 +360,7 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator):
             mgr=self
         )
 
-    def update_nfs(self, spec):
+    def apply_nfs(self, spec):
         # type: (orchestrator.NFSServiceSpec) -> RookCompletion
         num = spec.count
         return write_completion(