From a256735d4cc0d577faf86dda1672738301fefe78 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Mon, 25 Feb 2019 09:21:08 -0500 Subject: [PATCH] mgr/orchestrator: allow scaling the NFS server count up and down Add a new 'ceph orchestrator nfs update' command that will take the NFS clustername and a new count as arguments. That will get translated to a StatelessServiceSpec and passed to update_stateless_service. Also, add the necessary stubs to the test_orchestrator and the CLI QA test. Signed-off-by: Jeff Layton --- qa/tasks/mgr/test_orchestrator_cli.py | 3 +++ src/pybind/mgr/orchestrator_cli/module.py | 13 +++++++++++++ src/pybind/mgr/test_orchestrator/module.py | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/qa/tasks/mgr/test_orchestrator_cli.py b/qa/tasks/mgr/test_orchestrator_cli.py index 90bae17f244..bbb8fb80cfb 100644 --- a/qa/tasks/mgr/test_orchestrator_cli.py +++ b/qa/tasks/mgr/test_orchestrator_cli.py @@ -126,3 +126,6 @@ class TestOrchestratorCli(MgrTestCase): def test_mgr_update(self): self._orch_cmd("mgr", "update", "3") + + def test_nfs_update(self): + self._orch_cmd("nfs", "update", "service_name", "2") diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index 37a8dcd4966..2bfa7e20597 100644 --- a/src/pybind/mgr/orchestrator_cli/module.py +++ b/src/pybind/mgr/orchestrator_cli/module.py @@ -268,6 +268,19 @@ Usage: def _nfs_rm(self, svc_id): return self._rm_stateless_svc("nfs", svc_id) + @CLIWriteCommand('orchestrator nfs update', + "name=svc_id,type=CephString " + "name=num,type=CephInt", + 'Scale an NFS service') + @handle_exceptions + def _nfs_update(self, svc_id, num): + spec = orchestrator.StatelessServiceSpec() + spec.name = svc_id + spec.count = num + completion = self.update_stateless_service("nfs", spec) + self._orchestrator_wait([completion]) + return HandleCommandResult() + @CLIWriteCommand('orchestrator service', "name=action,type=CephChoices,strings=start|stop|reload " "name=svc_type,type=CephString " diff --git a/src/pybind/mgr/test_orchestrator/module.py b/src/pybind/mgr/test_orchestrator/module.py index 9a272e3568d..9c9f5acbc2c 100644 --- a/src/pybind/mgr/test_orchestrator/module.py +++ b/src/pybind/mgr/test_orchestrator/module.py @@ -270,6 +270,10 @@ class TestOrchestrator(MgrModule, orchestrator.Orchestrator): def remove_stateless_service(self, service_type, id_): pass + @deferred_write("update_stateless_service") + def update_stateless_service(self, service_type, spec): + pass + @deferred_read def get_hosts(self): return [orchestrator.InventoryNode('localhost', [])] -- 2.39.5