From: Sage Weil Date: Tue, 18 Feb 2020 19:06:51 +0000 (-0600) Subject: mgr/orch,cephadm: implement 'device zap' X-Git-Tag: v15.1.1~355^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=b98fdc715fe1345b3752f26699f319b671e6bd36;p=ceph-ci.git mgr/orch,cephadm: implement 'device zap' Signed-off-by: Sage Weil --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 297641abb31..599ef8b5e5c 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -1621,6 +1621,16 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): inventory.Devices(dls))) return trivial_result(result) + def zap_device(self, host, path): + out, err, code = self._run_cephadm( + host, 'osd', 'ceph-volume', + ['--', 'lvm', 'zap', '--destroy', path], + error_ok=True) + self.cache.invalidate_host_devices(host) + if code: + raise OrchestratorError('Zap failed: %s' % '\n'.join(out + err)) + return trivial_result('\n'.join(out + err)) + def blink_device_light(self, ident_fault, on, locs): @async_map_completion def blink(host, dev, path): diff --git a/src/pybind/mgr/orchestrator/_interface.py b/src/pybind/mgr/orchestrator/_interface.py index 761b6115a4e..2f04de54e00 100644 --- a/src/pybind/mgr/orchestrator/_interface.py +++ b/src/pybind/mgr/orchestrator/_interface.py @@ -988,6 +988,11 @@ class Orchestrator(object): """ raise NotImplementedError() + def zap_device(self, host, path): + # type: (str, str) -> Completion + """Zap/Erase a device (DESTROYS DATA)""" + raise NotImplementedError() + def add_mon(self, spec): # type: (ServiceSpec) -> Completion """Create mon daemon(s)""" diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py index 974332dd046..7e889a63884 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -292,6 +292,20 @@ class OrchestratorCli(OrchestratorClientMixin, MgrModule): out.append(table.get_string()) return HandleCommandResult(stdout='\n'.join(out)) + @_cli_write_command( + 'orch device zap', + 'name=host,type=CephString ' + 'name=path,type=CephString ' + 'name=force,type=CephBool,req=false', + 'Zap (erase!) a device so it can be re-used') + def _zap_device(self, host, path, force=False): + if not force: + raise OrchestratorError('must pass --force to PERMANENTLY ERASE DEVICE DATA') + completion = self.zap_device(host, path) + self._orchestrator_wait([completion]) + raise_if_exception(completion) + return HandleCommandResult(stdout=completion.result_str()) + @_cli_read_command( 'orch ls', "name=service_type,type=CephString,req=false "