]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephfs-shell: use libcephfs for exceptions
authorRishabh Dave <ridave@redhat.com>
Mon, 16 Dec 2019 14:23:19 +0000 (19:53 +0530)
committerRishabh Dave <ridave@redhat.com>
Mon, 30 Dec 2019 05:06:02 +0000 (10:36 +0530)
...instead of importing exceptions individually.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
src/tools/cephfs/cephfs-shell

index bbd0ddca419d97e3a8f9247c368557da39aede80..1459fe4fdf3fb3838fc483a07a44d7cf84dda951 100755 (executable)
@@ -1409,22 +1409,16 @@ def setup_cephfs(config_file):
     """
     Mounting a cephfs
     """
-    from cephfs import ObjectNotFound
-    from cephfs import Error
-
     global cephfs
     try:
         cephfs = libcephfs.LibCephFS(conffile=config_file)
         cephfs.mount()
-    except ObjectNotFound as e:
+    except libcephfs.ObjectNotFound as e:
         print('couldn\'t find ceph configuration not found')
         sys.exit(1)
-    except Error as e:
+    except libcephfs.Error as e:
         print(e)
         sys.exit(1)
-    else:
-        del ObjectNotFound
-        del Error
 
 def get_bool_vals_for_boolopts(val):
     if val.lower() in ['true', 'yes']:
@@ -1452,7 +1446,7 @@ def read_ceph_conf(shell, config_file):
         shell.prompt = get_bool_vals_for_boolopts(cephfs.conf_get('prompt'))
         shell.quiet = get_bool_vals_for_boolopts(cephfs.conf_get('quiet'))
         shell.timing = get_bool_vals_for_boolopts(cephfs.conf_get('timing'))
-    except (OSError, cephfs.Error) as e:
+    except (OSError, libcephfs.Error) as e:
         perror(e)
 
 if __name__ == '__main__':