From d3b9a2252c56565952a891832df9020aaeccf72c Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 5 Feb 2020 21:35:07 -0600 Subject: [PATCH] mgr/orch,cephadm: add 'host set-addr' Signed-off-by: Sage Weil --- src/pybind/mgr/cephadm/module.py | 10 ++++++++++ src/pybind/mgr/orchestrator.py | 10 ++++++++++ src/pybind/mgr/orchestrator_cli/module.py | 11 +++++++++++ 3 files changed, 31 insertions(+) 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', -- 2.47.3