]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/fs/nfs: Use check_mon_command() instead of mon_command()
authorVarsha Rao <varao@redhat.com>
Tue, 26 May 2020 10:13:40 +0000 (15:43 +0530)
committerVarsha Rao <varao@redhat.com>
Fri, 29 May 2020 09:17:32 +0000 (14:47 +0530)
check_mon_command() checks the return code of mon command.

Signed-off-by: Varsha Rao <varao@redhat.com>
src/pybind/mgr/volumes/fs/nfs.py

index 0df2751895a885595e9b8b1acff95b01e92b11e9..cb34bd9e8f03e08fc8815f9d119c241eeabb717f 100644 (file)
@@ -210,29 +210,26 @@ class FSExport(object):
     def _create_user_key(self, entity, path, fs_name):
         osd_cap = 'allow rw pool={} namespace={}, allow rw tag cephfs data={}'.format(
                 self.rados_pool, self.rados_namespace, fs_name)
-        ret, out, err = self.mgr.mon_command({
+
+        ret, out, err = self.mgr.check_mon_command({
             'prefix': 'auth get-or-create',
             'entity': 'client.{}'.format(entity),
             'caps' : ['mon', 'allow r', 'osd', osd_cap, 'mds', 'allow rw path={}'.format(path)],
             'format': 'json',
             })
 
-        if ret!= 0:
-            return ret, err
-
         json_res = json.loads(out)
-        log.info("Export user is {}".format(json_res[0]['entity']))
-
+        log.info("Export user created is {}".format(json_res[0]['entity']))
         return json_res[0]['entity'], json_res[0]['key']
 
     def _delete_user(self, entity):
-        ret, out, err = self.mgr.mon_command({
-            'prefix': 'auth del',
-            'entity': 'client.{}'.format(entity),
-            })
-
-        if ret!= 0:
-            log.warning(f"User could not be deleted: {err}")
+        try:
+            self.mgr.check_mon_command({
+                'prefix': 'auth del',
+                'entity': 'client.{}'.format(entity),
+                })
+        except MonCommandFailed as e:
+            log.warning(f"User could not be deleted: {e}")
 
     def format_path(self, path):
         if path is not None:
@@ -312,9 +309,6 @@ class FSExport(object):
             user_id = f"{cluster_id}{ex_id}"
             user_out, key = self._create_user_key(user_id, path, fs_name)
 
-            if isinstance(user_out, int):
-                return user_out, "", key
-
             ex_dict = {
                     'path': self.format_path(path),
                     'pseudo': self.format_path(pseudo_path),
@@ -442,11 +436,8 @@ class NFSCluster:
                 return r, out, err
             log.info("{}".format(out))
 
-            command = {'prefix': 'osd pool application enable', 'pool': self.pool_name, 'app': 'nfs'}
-            r, out, err = self.mgr.mon_command(command)
-
-            if r != 0:
-                return r, out, err
+            self.mgr.check_mon_command({'prefix': 'osd pool application enable',
+                'pool': self.pool_name, 'app': 'nfs'})
 
         self._set_pool_namespace(cluster_id)
         self._set_cluster_id(cluster_id)