From be6fa52a342e15cd1bf65620ac95dba79877d508 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 22 Aug 2018 18:36:32 +0200 Subject: [PATCH] mgr/orchestrator: Add RGW service support Signed-off-by: Rubab-Syed --- src/pybind/mgr/orchestrator_cli/module.py | 14 ++++++++ src/pybind/mgr/rook/module.py | 4 +++ src/pybind/mgr/rook/rook_cluster.py | 43 +++++++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index dffe367a938..560cc073ff8 100644 --- a/src/pybind/mgr/orchestrator_cli/module.py +++ b/src/pybind/mgr/orchestrator_cli/module.py @@ -174,6 +174,20 @@ class OrchestratorCli(MgrModule): ) self._wait([completion]) + return 0, "", "Success." + elif svc_type == "rgw": + store_name = cmd['svc_arg'] + + spec = orchestrator.StatelessServiceSpec() + spec.name = store_name + + completion = self._oremote( + "add_stateless_service", + svc_type, + spec + ) + self._wait([completion]) + return 0, "", "Success." else: raise NotImplementedError(svc_type) diff --git a/src/pybind/mgr/rook/module.py b/src/pybind/mgr/rook/module.py index 33dfe7cc3ea..4e9a69066c2 100644 --- a/src/pybind/mgr/rook/module.py +++ b/src/pybind/mgr/rook/module.py @@ -359,6 +359,10 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator): return RookWriteCompletion( lambda: self.rook_cluster.add_filesystem(spec), None, "Creating Filesystem services for {0}".format(spec.name)) + elif service_type == "rgw" : + return RookWriteCompletion( + lambda: self.rook_cluster.add_objectstore(spec), None, + "Creating RGW services for {0}".format(spec.name)) else: # TODO: RGW, NFS raise NotImplementedError(service_type) diff --git a/src/pybind/mgr/rook/rook_cluster.py b/src/pybind/mgr/rook/rook_cluster.py index c4046fe5791..709d10e67fa 100644 --- a/src/pybind/mgr/rook/rook_cluster.py +++ b/src/pybind/mgr/rook/rook_cluster.py @@ -218,6 +218,49 @@ class RookCluster(object): else: raise + def add_objectstore(self, spec): + + rook_os = { + "apiVersion": ROOK_API_NAME, + "kind": "ObjectStore", + "metadata": { + "name": spec.name, + "namespace": self.rook_namespace + }, + "spec": { + "metaDataPool": { + "failureDomain": "host", + "replicated": { + "size": 1 + } + }, + "dataPool": { + "failureDomain": "osd", + "replicated": { + "size": 1 + } + }, + "gateway": { + "type": "s3", + "port": 80, + "instances": 1, + "allNodes": False + } + } + } + + try: + self.rook_api_post( + "objectstores/", + body=rook_os + ) + except ApiException as e: + if e.status == 409: + log.info("ObjectStore '{0}' already exists".format(spec.name)) + # Idempotent, succeed. + else: + raise + def can_create_osd(self): current_cluster = self.rook_api_get( "clusters/{0}".format(self.cluster_name)) -- 2.39.5