From: Sage Weil Date: Thu, 31 Oct 2019 19:26:05 +0000 (-0500) Subject: mgr/ssh: service[-instance] [start|stop] X-Git-Tag: v15.1.0~1055^2~8 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=72b4b7282475fe4cffe7f91b64a36e0619156375;p=ceph-ci.git mgr/ssh: service[-instance] [start|stop] Note that 'reload' is meaningless for ssh orch... Signed-off-by: Sage Weil --- diff --git a/doc/mgr/orchestrator_cli.rst b/doc/mgr/orchestrator_cli.rst index deca9f0fe64..cc21093efc5 100644 --- a/doc/mgr/orchestrator_cli.rst +++ b/doc/mgr/orchestrator_cli.rst @@ -296,7 +296,7 @@ This is an overview of the current implementation status of the orchestrators. device {ident,fault}-(on,off} ⚪ ⚪ ⚪ ⚪ device ls ✔️ ✔️ ✔️ ✔️ service ls ⚪ ✔️ ✔️ ✔ - service-instance status ⚪ ⚪ ⚪ ⚪ + service-instance status ⚪ ⚪ ⚪ ✔ iscsi {stop,start,reload} ⚪ ⚪ ⚪ ⚪ iscsi add ⚪ ⚪ ⚪ ⚪ iscsi rm ⚪ ⚪ ⚪ ⚪ diff --git a/src/pybind/mgr/ssh/module.py b/src/pybind/mgr/ssh/module.py index ba80a12df1d..5beafa25926 100644 --- a/src/pybind/mgr/ssh/module.py +++ b/src/pybind/mgr/ssh/module.py @@ -500,6 +500,45 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator): node_name=node_name) return orchestrator.TrivialReadCompletion(result) + def service_action(self, action, service_type, + service_name=None, + service_id=None): + self.log.debug('service_action action %s type %s name %s id %s' % ( + action, service_type, service_name, service_id)) + if action == 'reload': + return orchestrator.TrivialReadCompletion( + ["Reload is a no-op"]) + daemons = self._get_services( + service_type, + service_name=service_name, + service_id=service_id) + results = [] + for d in daemons: + results.append(self._worker_pool.apply_async( + self._service_action, (d.service_type, d.service_instance, + d.nodename, action))) + if not results: + n = service_name + if n: + n += '-*' + raise OrchestratorError('Unable to find %s.%s%s daemon(s)' % ( + service_type, service_id, n)) + return SSHWriteCompletion(results) + + def _service_action(self, service_type, service_id, host, action): + actions = { + 'start': ['reset-failed', 'start'], + 'stop': ['stop'], + } + name = '%s.%s' % (service_type, service_id) + for a in actions[action]: + out, code = self._run_ceph_daemon( + host, name, 'unit', + ['--name', name, a]) + self.log.debug('_service_action code %s out %s' % (code, out)) + return "{} {} from host '{}'".format(action, name, host) + + def get_inventory(self, node_filter=None, refresh=False): """ Return the storage inventory of nodes matching the given filter.