]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/orch: dump service spec by name 33951/head
authorMichael Fritch <mfritch@suse.com>
Fri, 13 Mar 2020 13:48:44 +0000 (07:48 -0600)
committerMichael Fritch <mfritch@suse.com>
Fri, 13 Mar 2020 15:25:41 +0000 (09:25 -0600)
add optional arg to allow a dump by name:
`ceph orch spec dump [svc_name]`

Signed-off-by: Michael Fritch <mfritch@suse.com>
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/orchestrator/_interface.py
src/pybind/mgr/orchestrator/module.py

index 2b71674dba0508edef9d454be6c6394bdb385e5e..439e43aca40a38b9967f544c42eac4a3ad9fb8fc 100644 (file)
@@ -162,11 +162,13 @@ class SpecStore():
             del self.spec_created[service_name]
             self.mgr.set_store(SPEC_STORE_PREFIX + service_name, None)
 
-    def find(self, service_name):
-        # type: (str) -> List[ServiceSpec]
+    def find(self, service_name=None):
+        # type: (Optional[str]) -> List[ServiceSpec]
         specs = []
         for sn, spec in self.specs.items():
-            if sn == service_name or sn.startswith(service_name + '.'):
+            if not service_name or \
+                    sn == service_name or \
+                    sn.startswith(service_name + '.'):
                 specs.append(spec)
         return specs
 
@@ -3042,12 +3044,12 @@ receivers:
         """
         return trivial_result(self.rm_util.report)
 
-    def list_specs(self) -> orchestrator.Completion:
+    def list_specs(self, service_name=None) -> orchestrator.Completion:
         """
         Loads all entries from the service_spec mon_store root.
         """
         specs = list()
-        for service_name, spec in self.spec_store.specs.items():
+        for spec in self.spec_store.find(service_name=service_name):
             specs.append('---')
             specs.append(yaml.safe_dump(spec.to_json()))
         return trivial_result(specs)
index c1eae587370e69610158f0451dd326e70d0ab08c..11c0a5c8b404eceae9f06fcf68b240d73d1435a9 100644 (file)
@@ -859,8 +859,8 @@ class Orchestrator(object):
         """
         raise NotImplementedError()
 
-    def list_specs(self):
-        # type: () -> Completion
+    def list_specs(self, service_name=None):
+        # type: (Optional[str]) -> Completion
         """
         Lists saved service specs
         """
index 280b31e21bc56570bd537b6135ce623ad31ea17d..bb0114db66a46dcc71348699f5354039585dea2a 100644 (file)
@@ -740,9 +740,10 @@ Usage:
 
     @_cli_write_command(
         'orch spec dump',
+        'name=service_name,type=CephString,req=false',
         desc='List all Service specs')
-    def _get_service_specs(self):
-        completion = self.list_specs()
+    def _get_service_specs(self, service_name=None):
+        completion = self.list_specs(service_name=service_name)
         self._orchestrator_wait([completion])
         raise_if_exception(completion)
         specs = completion.result_str()