This is needed when removing mons.
Signed-off-by: Sage Weil <sage@redhat.com>
daemon_type=daemon_type,
daemon_id=daemon_id).then(_proc_daemons)
- def remove_daemons(self, names):
- # type: (List[str]) -> orchestrator.Completion
+ def remove_daemons(self, names, force):
+ # type: (List[str], bool) -> orchestrator.Completion
def _filter(daemons):
args = []
for d in daemons:
for name in names:
if d.name() == name:
args.append(
- ('%s.%s' % (d.daemon_type, d.daemon_id), d.nodename)
+ ('%s.%s' % (d.daemon_type, d.daemon_id),
+ d.nodename,
+ force)
)
if not args:
raise OrchestratorError('Unable to find daemon(s) %s' % (names))
'Reconfigured' if reconfig else 'Deployed', name, host)
@async_map_completion
- def _remove_daemon(self, name, host):
+ def _remove_daemon(self, name, host, force=False):
"""
Remove a daemon
"""
+ self.log.debug('_remove_daemon %s on %s force=%s' % (name, host, force))
+ args = ['--name', name]
+ if force:
+ args.extend(['--force'])
out, err, code = self._run_cephadm(
- host, name, 'rm-daemon',
- ['--name', name])
+ host, name, 'rm-daemon', args)
self.log.debug('_remove_daemon code %s out %s' % (code, out))
if not code and host in self.daemon_cache:
# remove item from cache
with self._with_host(cephadm_module, 'test'):
c = cephadm_module.list_daemons(refresh=True)
wait(cephadm_module, c)
- c = cephadm_module.remove_daemons(['osd.0'])
+ c = cephadm_module.remove_daemons(['osd.0'], False)
out = wait(cephadm_module, c)
assert out == ["Removed osd.0 from host 'test'"]
with self._with_host(cephadm_module, 'test'):
c = cephadm_module.list_daemons(refresh=True)
wait(cephadm_module, c)
- c = cephadm_module.remove_daemons(['rgw.myrgw.myhost.myid'])
+ c = cephadm_module.remove_daemons(['rgw.myrgw.myhost.myid'], False)
out = wait(cephadm_module, c)
assert out == ["Removed rgw.myrgw.myhost.myid from host 'test'"]
"""
raise NotImplementedError()
- def remove_daemons(self, names):
- # type: (List[str]) -> Completion
+ def remove_daemons(self, names, force):
+ # type: (List[str], bool) -> Completion
"""
Remove specific daemon(s).
@orchestrator._cli_write_command(
'orch daemon rm',
- "name=names,type=CephString,n=N",
+ "name=names,type=CephString,n=N "
+ 'name=force,type=CephBool,req=false',
'Remove specific daemon(s)')
- def _daemon_rm(self, names):
+ def _daemon_rm(self, names, force=False):
for name in names:
if '.' not in name:
raise orchestrator.OrchestratorError('%s is not a valid daemon name' % name)
- completion = self.remove_daemons(names)
+ completion = self.remove_daemons(names, force)
self._orchestrator_wait([completion])
orchestrator.raise_if_exception(completion)
return HandleCommandResult(stdout=completion.result_str())