mgr/orch,cephadm: add 'host set-addr'

Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2020-02-05 21:35:07 -06:00
parent 5276871e15
commit d3b9a2252c
3 changed files with 31 additions and 0 deletions

View File

@ -1173,6 +1173,16 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin):
self.event.set() # refresh stray health check
return "Removed host '{}'".format(host)
@async_completion
def update_host_addr(self, host, addr):
if host not in self.inventory:
raise OrchestratorError('host %s not registered' % host)
self.inventory[host]['addr'] = addr
self._save_inventory()
self._reset_con(host)
self.event.set() # refresh stray health check
return "Updated host '{}' addr to '{}'".format(host, addr)
@trivial_completion
def get_hosts(self):
"""

View File

@ -784,6 +784,16 @@ class Orchestrator(object):
"""
raise NotImplementedError()
def update_host_addr(self, host, addr):
# type: (str, str) -> Completion
"""
Update a host's address
:param host: hostname
:param addr: address (dns name or IP)
"""
raise NotImplementedError()
def get_hosts(self):
# type: () -> Completion
"""

View File

@ -178,6 +178,17 @@ class OrchestratorCli(orchestrator.OrchestratorClientMixin, MgrModule):
orchestrator.raise_if_exception(completion)
return HandleCommandResult(stdout=completion.result_str())
@orchestrator._cli_write_command(
'orchestrator host set-addr',
'name=host,type=CephString '
'name=addr,type=CephString',
'Update a host address')
def _update_set_addr(self, host, addr):
completion = self.update_host_addr(host, addr)
self._orchestrator_wait([completion])
orchestrator.raise_if_exception(completion)
return HandleCommandResult(stdout=completion.result_str())
@orchestrator._cli_read_command(
'orchestrator host ls',
'name=format,type=CephChoices,strings=json|plain,req=false',