From 6526fb9023e654ee4cb09b874d9f9b92cd66e85e Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Wed, 13 Feb 2019 08:10:51 -0500 Subject: [PATCH] mgr/rook: add the ability to scale the mon count Signed-off-by: Jeff Layton --- src/pybind/mgr/rook/module.py | 8 ++++++++ src/pybind/mgr/rook/rook_cluster.py | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/pybind/mgr/rook/module.py b/src/pybind/mgr/rook/module.py index f9ae9d07a6a15..0aac98a23d79b 100644 --- a/src/pybind/mgr/rook/module.py +++ b/src/pybind/mgr/rook/module.py @@ -392,6 +392,14 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator): lambda: self.rook_cluster.rm_service(service_type, service_id), None, "Removing {0} services for {1}".format(service_type, service_id)) + def update_mons(self, num, hosts): + if hosts: + raise RuntimeError("Host list is not supported by rook.") + + return RookWriteCompletion( + lambda: self.rook_cluster.update_mon_count(num), None, + "Updating mon count to {0}".format(num)) + def create_osds(self, drive_group, all_hosts): # type: (orchestrator.DriveGroupSpec, List[str]) -> RookWriteCompletion diff --git a/src/pybind/mgr/rook/rook_cluster.py b/src/pybind/mgr/rook/rook_cluster.py index 5d319b4758c19..f42b95a0b5d00 100644 --- a/src/pybind/mgr/rook/rook_cluster.py +++ b/src/pybind/mgr/rook/rook_cluster.py @@ -337,6 +337,20 @@ class RookCluster(object): else: return True + def update_mon_count(self, newcount): + patch = [{"op": "replace", "path": "/spec/mon/count", "value": newcount}] + + try: + self.rook_api_patch( + "cephclusters/{0}".format(self.cluster_name), + body=patch) + except ApiException as e: + log.exception("API exception: {0}".format(e)) + raise ApplyException( + "Failed to update mon count in Cluster CRD: {0}".format(e)) + + return "Updated mon count to {0}".format(newcount) + def add_osds(self, drive_group, all_hosts): # type: (orchestrator.DriveGroupSpec, List[str]) -> None """ -- 2.39.5