From: Sage Weil Date: Thu, 6 Feb 2020 03:35:07 +0000 (-0600) Subject: mgr/orch,cephadm: add 'host set-addr' X-Git-Tag: v15.1.1~506^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F33098%2Fhead;p=ceph.git mgr/orch,cephadm: add 'host set-addr' Signed-off-by: Sage Weil --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 67414a2b0381..d386803f5eeb 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -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): """ diff --git a/src/pybind/mgr/orchestrator.py b/src/pybind/mgr/orchestrator.py index 78214b6296c4..a295f42c3aaa 100644 --- a/src/pybind/mgr/orchestrator.py +++ b/src/pybind/mgr/orchestrator.py @@ -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 """ diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index 5c5946a6c96d..fc19758f7182 100644 --- a/src/pybind/mgr/orchestrator_cli/module.py +++ b/src/pybind/mgr/orchestrator_cli/module.py @@ -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',