From ca972cefbd3f4159021ac2c0d28f43c59e753f25 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 15 Nov 2018 12:22:38 -0500 Subject: [PATCH] mgr/orchestrator_cli: add support for adding NFS gateways Add necessary commands to orchestrator_cli to allow it to deploy a cluster of NFS servers. Note that we have to be able to specify the pool and an optional namespace for the recovery backend objects. Signed-off-by: Jeff Layton --- doc/mgr/orchestrator_cli.rst | 2 ++ src/pybind/mgr/orchestrator_cli/module.py | 33 +++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/doc/mgr/orchestrator_cli.rst b/doc/mgr/orchestrator_cli.rst index a1c514fc72a..6b28f1f5fbd 100644 --- a/doc/mgr/orchestrator_cli.rst +++ b/doc/mgr/orchestrator_cli.rst @@ -211,6 +211,8 @@ Creating/growing/shrinking services:: ceph orchestrator {mds,rgw} update [host…] ceph orchestrator {mds,rgw} add + ceph orchestrator nfs update [host…] + ceph orchestrator nfs add [--namespace=] e.g., ``ceph orchestrator mds update myfs 3 host1 host2 host3`` diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index 1d5bf33a5e2..3caff801191 100644 --- a/src/pybind/mgr/orchestrator_cli/module.py +++ b/src/pybind/mgr/orchestrator_cli/module.py @@ -75,6 +75,20 @@ class OrchestratorCli(orchestrator.OrchestratorClientMixin, MgrModule): "desc": "Remove an RGW service", "perm": "rw" }, + { + 'cmd': "orchestrator nfs add " + "name=svc_arg,type=CephString " + "name=pool,type=CephString " + "name=namespace,type=CephString,req=false ", + "desc": "Create an NFS service", + "perm": "rw" + }, + { + 'cmd': "orchestrator nfs rm " + "name=svc_id,type=CephString ", + "desc": "Remove an NFS service", + "perm": "rw" + }, { 'cmd': "orchestrator set backend " "name=module,type=CephString,req=true", @@ -212,6 +226,18 @@ class OrchestratorCli(orchestrator.OrchestratorClientMixin, MgrModule): spec.name = cmd['svc_arg'] return self._add_stateless_svc("rgw", spec) + def _nfs_add(self, cmd): + cluster_name = cmd['svc_arg'] + pool = cmd['pool'] + ns = cmd.get('namespace', None) + + spec = orchestrator.StatelessServiceSpec() + spec.name = cluster_name + spec.extended = { "pool":pool } + if ns != None: + spec.extended["namespace"] = ns + return self._add_stateless_svc("nfs", spec) + def _rm_stateless_svc(self, svc_type, svc_id): completion = self.remove_stateless_service(svc_type, svc_id) self._orchestrator_wait([completion]) @@ -226,6 +252,9 @@ class OrchestratorCli(orchestrator.OrchestratorClientMixin, MgrModule): def _rgw_rm(self, cmd): return self._rm_stateless_svc("rgw", cmd['svc_id']) + def _nfs_rm(self, cmd): + return self._rm_stateless_svc("nfs", cmd['svc_id']) + def _set_backend(self, cmd): """ We implement a setter command instead of just having the user @@ -319,6 +348,10 @@ class OrchestratorCli(orchestrator.OrchestratorClientMixin, MgrModule): return self._rgw_add(cmd) elif cmd['prefix'] == "orchestrator rgw rm": return self._rgw_rm(cmd) + elif cmd['prefix'] == "orchestrator nfs add": + return self._nfs_add(cmd) + elif cmd['prefix'] == "orchestrator nfs rm": + return self._nfs_rm(cmd) elif cmd['prefix'] == "orchestrator set backend": return self._set_backend(cmd) elif cmd['prefix'] == "orchestrator status": -- 2.39.5