]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/orch,cephadm: add 'host set-addr'
authorSage Weil <sage@redhat.com>
Thu, 6 Feb 2020 03:35:07 +0000 (21:35 -0600)
committerSage Weil <sage@redhat.com>
Fri, 7 Feb 2020 19:36:45 +0000 (13:36 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/orchestrator.py
src/pybind/mgr/orchestrator_cli/module.py

index 67414a2b0381ba997bdc9d64e4beab6295b1f7a7..d386803f5eebbdc9a48dcae9d129dac83cb2017b 100644 (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):
         """
index 78214b6296c48ce123e66360c7e360cea1412ba0..a295f42c3aaa0e88fc51552bbca1cae1837489eb 100644 (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
         """
index 5c5946a6c96ddf167dfd704ef194535bdcae8948..fc19758f7182a45c05c450342ccc0a87b13561f8 100644 (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',