From: Sage Weil Date: Tue, 11 Feb 2020 16:21:00 +0000 (-0600) Subject: mgr/orch: add 'orch service rm' X-Git-Tag: v15.1.1~443^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=b94673a03b671d3a07e9079f1368026837b4436a;p=ceph-ci.git mgr/orch: add 'orch service rm' Signed-off-by: Sage Weil --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 022a7a02e06..e1cf1eebd27 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -1469,6 +1469,25 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): return self._remove_daemon(args) return self._get_daemons().then(_filter) + def remove_service(self, service_type, service_name): + if service_name: + prefix = service_name + '.' + else: + prefix = '' + def _filter(daemons): + args = [] + for d in daemons: + if d.daemon_type == service_type and \ + d.daemon_id.startswith(prefix): + args.append( + ('%s.%s' % (d.daemon_type, d.daemon_id), d.nodename) + ) + if not args: + raise OrchestratorError('Unable to find daemons in %s.%s* service' % ( + service_type, prefix)) + return self._remove_daemon(args) + return self._get_daemons(daemon_type=service_type).then(_filter) + def get_inventory(self, node_filter=None, refresh=False): """ Return the storage inventory of nodes matching the given filter. diff --git a/src/pybind/mgr/orchestrator.py b/src/pybind/mgr/orchestrator.py index 8cf66e7dfea..ae8e45a1c19 100644 --- a/src/pybind/mgr/orchestrator.py +++ b/src/pybind/mgr/orchestrator.py @@ -887,6 +887,15 @@ class Orchestrator(object): """ raise NotImplementedError() + def remove_service(self, service_type, service_name=None): + # type: (str, Optional[str]) -> Completion + """ + Remove a service (a collection of daemons). + + :return: None + """ + raise NotImplementedError() + def service_action(self, action, service_type, service_name): # type: (str, str, str) -> Completion """ diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index 7224629f8f4..93542f2f799 100644 --- a/src/pybind/mgr/orchestrator_cli/module.py +++ b/src/pybind/mgr/orchestrator_cli/module.py @@ -634,6 +634,21 @@ Usage: orchestrator.raise_if_exception(completion) return HandleCommandResult(stdout=completion.result_str()) + @orchestrator._cli_write_command( + 'orch service rm', + "name=name,type=CephString", + 'Remove a service') + def _service_rm(self, name): + if '.' in name: + (service_type, service_name) = name.split('.') + else: + service_type = name; + service_name = None + completion = self.remove_service(service_type, service_name) + self._orchestrator_wait([completion]) + orchestrator.raise_if_exception(completion) + return HandleCommandResult(stdout=completion.result_str()) + @orchestrator._cli_write_command( 'orch mgr update', "name=num,type=CephInt,req=false "