]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/rook: add support for adding NFS gateways
authorJeff Layton <jlayton@redhat.com>
Thu, 15 Nov 2018 17:23:09 +0000 (12:23 -0500)
committerJeff Layton <jlayton@redhat.com>
Mon, 14 Jan 2019 15:36:46 +0000 (10:36 -0500)
Add the necessary machinery to the rook orchestrator to allow it to
request a cluster of nfs-ganesha gateways.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
src/pybind/mgr/rook/module.py
src/pybind/mgr/rook/rook_cluster.py

index 60129540a18e0c0f7ca30ab1c570983318449e04..9c8c862d24bd1fd7c31942a0d219ab1616300949 100644 (file)
@@ -373,6 +373,9 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator):
         elif service_type == "rgw" :
             return self._service_add_decorate("RGW", spec,
                                          self.rook_cluster.add_objectstore)
+        elif service_type == "nfs" :
+            return self._service_add_decorate("NFS", spec,
+                                         self.rook_cluster.add_nfsgw)
         else:
             raise NotImplementedError(service_type)
 
index cf5d5f9077c571a93e6950ee4918d9c9c6fd667d..02288975bad493ae18747a8ecd338f63cb3074ff 100644 (file)
@@ -229,6 +229,35 @@ class RookCluster(object):
         with self.ignore_409("CephFilesystem '{0}' already exists".format(spec.name)):
             self.rook_api_post("cephfilesystems/", body=rook_fs)
 
+    def add_nfsgw(self, spec):
+        # TODO use spec.placement
+        # TODO use spec.min_size (and use max_size meaningfully)
+        # TODO warn if spec.extended has entries we don't kow how
+        #      to action.
+
+        rook_nfsgw = {
+            "apiVersion": ROOK_API_NAME,
+            "kind": "CephNFS",
+            "metadata": {
+                "name": spec.name,
+                "namespace": self.rook_namespace
+            },
+            "spec": {
+                "RADOS": {
+                    "pool": spec.extended["pool"]
+                },
+                "server": {
+                    "active": spec.max_size,
+                }
+            }
+        }
+
+        if "namespace" in spec.extended:
+            rook_nfsgw["spec"]["RADOS"]["namespace"] = spec.extended["namespace"]
+
+        with self.ignore_409("NFS cluster '{0}' already exists".format(spec.name)):
+            self.rook_api_post("cephnfses/", body=rook_nfsgw)
+
     def add_objectstore(self, spec):
   
         rook_os = {
@@ -264,12 +293,14 @@ class RookCluster(object):
             self.rook_api_post("cephobjectstores/", body=rook_os)
 
     def rm_service(self, service_type, service_id):
-        assert service_type in ("mds", "rgw")
+        assert service_type in ("mds", "rgw", "nfs")
 
         if service_type == "mds":
             rooktype = "cephfilesystems"
         elif service_type == "rgw":
             rooktype = "cephobjectstores"
+        elif service_type == "nfs":
+            rooktype = "cephnfses"
 
         objpath = "{0}/{1}".format(rooktype, service_id)