From a9b5fa6303beccdc739f886a7978c7e3ca5b9515 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 6 Nov 2019 08:59:37 -0600 Subject: [PATCH] mgr/ssh: implement blink_device_light On my test box I get as far as NO_SUPPORT(153): SCSI VPD page 0x83 is not supported because my hardware doesn't support this. The same command works on another box that does. Signed-off-by: Sage Weil --- doc/mgr/orchestrator_cli.rst | 2 +- src/pybind/mgr/ssh/module.py | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/doc/mgr/orchestrator_cli.rst b/doc/mgr/orchestrator_cli.rst index 80cf9d3d2d154..8151ff8aa8800 100644 --- a/doc/mgr/orchestrator_cli.rst +++ b/doc/mgr/orchestrator_cli.rst @@ -302,7 +302,7 @@ This is an overview of the current implementation status of the orchestrators. osd create ✔ ✔ ⚪ ✔ osd device {ident,fault}-{on,off} ⚪ ⚪ ⚪ ⚪ osd rm ✔ ⚪ ⚪ ✔ - device {ident,fault}-(on,off} ⚪ ⚪ ⚪ ⚪ + device {ident,fault}-(on,off} ⚪ ⚪ ⚪ ✔ device ls ✔ ✔ ✔ ✔ service ls ⚪ ✔ ✔ ✔ service-instance status ⚪ ⚪ ⚪ ✔ diff --git a/src/pybind/mgr/ssh/module.py b/src/pybind/mgr/ssh/module.py index 336a9b75b0426..b7db09e9c832c 100644 --- a/src/pybind/mgr/ssh/module.py +++ b/src/pybind/mgr/ssh/module.py @@ -649,6 +649,33 @@ class SSHOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): return SSHReadCompletion(results) + @log_exceptions + def blink_device_light(self, ident_fault, on, locs): + def blink(host, dev, ident_fault, on): + cmd = [ + 'lsmcli', + 'local-disk-%s-led-%s' % ( + ident_fault, + 'on' if on else 'off'), + '--path', '/dev/' + dev, + ] + out, code = self._run_ceph_daemon(host, 'osd', 'shell', ['--'] + cmd, + error_ok=True) + if code: + raise RuntimeError( + 'Unable to affect %s light for %s:%s. Command: %s' % ( + ident_fault, host, dev, ' '.join(cmd))) + return "Set %s light for %s:%s %s" % ( + ident_fault, host, dev, 'on' if on else 'off') + + results = [] + for loc in locs: + results.append( + self._worker_pool.apply_async( + blink, + (loc.host, loc.dev, ident_fault, on))) + return SSHWriteCompletion(results) + @log_exceptions def _create_osd(self, host, drive_group): # get bootstrap key -- 2.39.5