From c16e9a6f88e2984718e01ee6c7b62c615f7d5913 Mon Sep 17 00:00:00 2001 From: ShwethaHP Date: Thu, 31 Aug 2017 16:03:59 +0530 Subject: Making mounting of volume optional in the BaseClass. Mounting of a volume will not always be distributed volume. Providing a option to mount a local volume as well. Change-Id: Iadbb596fba7e2a5fa4ba3ba53967961a70d00c8c Signed-off-by: ShwethaHP --- .../glustolibs/gluster/gluster_base_class.py | 49 +++++++++++++++------- glustolibs-gluster/glustolibs/gluster/mount_ops.py | 12 ++++-- 2 files changed, 43 insertions(+), 18 deletions(-) (limited to 'glustolibs-gluster') diff --git a/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py b/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py index 3f94fbff7..5aba6c637 100644 --- a/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py +++ b/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py @@ -406,7 +406,7 @@ class GlusterVolumeBaseClass(GlusterBaseClass): """GlusterVolumeBaseClass sets up the volume for testing purposes. """ @classmethod - def setUpClass(cls): + def setUpClass(cls, mount_vol=True): """Setup volume, shares/exports volume for cifs/nfs protocols, mounts the volume. """ @@ -483,20 +483,28 @@ class GlusterVolumeBaseClass(GlusterBaseClass): cls.volname) # Create Mounts - _rc = True - for mount_obj in cls.mounts: - ret = mount_obj.mount() - if not ret: - g.log.error("Unable to mount volume '%s:%s' on '%s:%s'", - mount_obj.server_system, mount_obj.volname, - mount_obj.client_system, mount_obj.mountpoint) - _rc = False - if not _rc: - raise ExecutionError("Mounting volume %s on few clients failed", - cls.volname) - - # Get info of mount before the IO - log_mounts_info(cls.mounts) + if mount_vol: + _rc = True + g.log.info("Starting to mount volume") + for mount_obj in cls.mounts: + ret = mount_obj.mount() + if not ret: + g.log.error("Unable to mount volume '%s:%s' on '%s:%s'", + mount_obj.server_system, mount_obj.volname, + mount_obj.client_system, mount_obj.mountpoint) + _rc = False + if not _rc: + raise ExecutionError("Mounting volume %s on few clients " + "failed", cls.volname) + else: + g.log.info("Successful in mounting volume on all clients") + + # Get info of mount before the IO + g.log.info("Get mounts Info:") + log_mounts_info(cls.mounts) + else: + g.log.info("Not Mouting the volume as 'mount_vol' option is " + "set to %s", mount_vol) @classmethod def tearDownClass(cls, umount_vol=True, cleanup_vol=True): @@ -505,6 +513,7 @@ class GlusterVolumeBaseClass(GlusterBaseClass): # Unmount volume if umount_vol: _rc = True + g.log.info("Starting to UnMount Volumes") for mount_obj in cls.mounts: ret = mount_obj.unmount() if not ret: @@ -515,12 +524,22 @@ class GlusterVolumeBaseClass(GlusterBaseClass): if not _rc: raise ExecutionError("Unmount of all mounts are not " "successful") + else: + g.log.info("Successful in unmounting volume on all clients") + else: + g.log.info("Not Unmouting the Volume as 'umount_vol' is set " + "to %s", umount_vol) # Cleanup volume if cleanup_vol: ret = cleanup_volume(mnode=cls.mnode, volname=cls.volname) if not ret: raise ExecutionError("cleanup volume %s failed", cls.volname) + else: + g.log.info("Successfully cleaned-up volume") + else: + g.log.info("Not Cleaning-Up volume as 'cleanup_vol' is %s", + cleanup_vol) # All Volume Info volume_info(cls.mnode) diff --git a/glustolibs-gluster/glustolibs/gluster/mount_ops.py b/glustolibs-gluster/glustolibs/gluster/mount_ops.py index adb3cae9f..10d323a62 100644 --- a/glustolibs-gluster/glustolibs/gluster/mount_ops.py +++ b/glustolibs-gluster/glustolibs/gluster/mount_ops.py @@ -109,7 +109,9 @@ class GlusterMount(): self.mountpoint = "/mnt/%s" % self.mounttype # Get server - self.server_system = mount['server'] + self.server_system = None + if 'server' in mount and mount['server']: + self.server_system = mount['server'] # Get client self.client_system = mount['client']['host'] @@ -342,8 +344,12 @@ def mount_volume(volname, mtype, mpoint, mserver, mclient, options='', elif options and 'vers' not in options: options = options + ",vers=3" - mcmd = ("mount -t %s %s %s:/%s %s" % - (mtype, options, mserver, volname, mpoint)) + if mserver: + mcmd = ("mount -t %s %s %s:/%s %s" % + (mtype, options, mserver, volname, mpoint)) + else: + mcmd = ("mount -t %s %s %s %s" % + (mtype, options, volname, mpoint)) if mtype == 'cifs': if smbuser is None or smbpasswd is None: -- cgit