summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Holloway <jholloway@redhat.com>2018-09-14 15:10:19 +0000
committerJonathan Holloway <jholloway@redhat.com>2018-09-14 15:18:33 +0000
commit957489592404f900d97a8ec56fb55144fe968c94 (patch)
tree51250eae0081d583fe6512a06e40e44f443cb600
parentea24fe1964e8fc74eab5e031ec67a464aed21445 (diff)
Revert "Raise Exceptions in setup_volume and mount_volume"
This reverts commit 2d425798657a725e02d63ff631c5b87187ea4ca4. Change-Id: I388fe7ff11e28e027fe9006512e35ec57ff10d9c
-rw-r--r--glustolibs-gluster/glustolibs/gluster/gluster_base_class.py173
1 files changed, 96 insertions, 77 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py b/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py
index 57b7fb1..8f9d0b9 100644
--- a/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py
+++ b/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py
@@ -39,7 +39,6 @@ from glustolibs.gluster.nfs_libs import export_volume_through_nfs
from glustolibs.gluster.mount_ops import create_mount_objs
from glustolibs.io.utils import log_mounts_info
from glustolibs.gluster.lib_utils import inject_msg_in_logs
-from glustolibs.gluster.exceptions import ExecutionError
class runs_on(g.CarteTestClass):
@@ -181,8 +180,8 @@ class GlusterBaseClass(unittest.TestCase):
volume_create_force(bool): True if create_volume should be
executed with 'force' option.
- Raises:
- ExecutionError in the event of an error.
+ Returns (bool): True if all the steps mentioned in the descriptions
+ passes. False otherwise.
"""
force_volume_create = False
if volume_create_force or cls.volume_create_force:
@@ -192,8 +191,9 @@ class GlusterBaseClass(unittest.TestCase):
g.log.info("Validate peers before setting up volume ")
ret = cls.validate_peers_are_connected()
if not ret:
- raise ExecutionError("Failed to validate peers are in connected "
- "state before setting up volume")
+ g.log.error("Failed to validate peers are in connected state "
+ "before setting up volume")
+ return False
g.log.info("Successfully validated peers are in connected state "
"before setting up volume")
@@ -203,78 +203,88 @@ class GlusterBaseClass(unittest.TestCase):
all_servers_info=cls.all_servers_info,
volume_config=cls.volume, force=force_volume_create)
if not ret:
- raise ExecutionError("Failed to Setup volume %s" % cls.volname)
+ g.log.error("Failed to Setup volume %s", cls.volname)
+ return False
g.log.info("Successful in setting up volume %s", cls.volname)
# Wait for volume processes to be online
g.log.info("Wait for volume %s processes to be online", cls.volname)
ret = wait_for_volume_process_to_be_online(cls.mnode, cls.volname)
if not ret:
- raise ExecutionError("Failed to wait for volume %s processes to "
- "be online" % cls.volname)
-
+ g.log.error("Failed to wait for volume %s processes to "
+ "be online", cls.volname)
+ return False
g.log.info("Successful in waiting for volume %s processes to be "
"online", cls.volname)
# Export/Share the volume based on mount_type
- if "nfs" in cls.mount_type:
- ret = export_volume_through_nfs(
- mnode=cls.mnode, volname=cls.volname,
- enable_ganesha=cls.enable_nfs_ganesha)
- if not ret:
- raise ExecutionError("Failed to export volume %s as NFS export"
- % cls.volname)
- g.log.info("Successful in exporting the volume %s as NFS export",
- cls.volname)
-
- # Set NFS-Ganesha specific volume options
- if cls.enable_nfs_ganesha and cls.nfs_ganesha_export_options:
- g.log.info("Setting NFS-Ganesha export specific "
- "volume options on volume %s", cls.volname)
- ret = set_volume_options(
+ if cls.mount_type != "glusterfs":
+ g.log.info("Export/Sharing the volume %s", cls.volname)
+ if "nfs" in cls.mount_type:
+ ret = export_volume_through_nfs(
mnode=cls.mnode, volname=cls.volname,
- options=cls.nfs_ganesha_export_options)
+ enable_ganesha=cls.enable_nfs_ganesha)
+ if not ret:
+ g.log.error("Failed to export volume %s "
+ "as NFS export", cls.volname)
+ return False
+ g.log.info("Successful in exporting the volume %s "
+ "as NFS export", cls.volname)
+
+ # Set NFS-Ganesha specific volume options
+ if cls.enable_nfs_ganesha and cls.nfs_ganesha_export_options:
+ g.log.info("Setting NFS-Ganesha export specific "
+ "volume options on volume %s", cls.volname)
+ ret = set_volume_options(
+ mnode=cls.mnode, volname=cls.volname,
+ options=cls.nfs_ganesha_export_options)
+ if not ret:
+ g.log.error("Failed to set NFS-Ganesha "
+ "export specific options on "
+ "volume %s", cls.volname)
+ return False
+ g.log.info("Successful in setting NFS-Ganesha export "
+ "specific volume options on volume %s",
+ cls.volname)
+
+ if "smb" in cls.mount_type or "cifs" in cls.mount_type:
+ ret = share_volume_over_smb(mnode=cls.mnode,
+ volname=cls.volname,
+ smb_users_info=cls.smb_users_info)
if not ret:
- raise ExecutionError("Failed to set NFS-Ganesha "
- "export specific options on "
- "volume %s" % cls.volname)
- g.log.info("Successful in setting NFS-Ganesha export "
- "specific volume options on volume %s",
+ g.log.error("Failed to export volume %s "
+ "as SMB Share", cls.volname)
+ return False
+ g.log.info("Successful in exporting volume %s as SMB Share",
cls.volname)
- if "smb" in cls.mount_type or "cifs" in cls.mount_type:
- ret = share_volume_over_smb(mnode=cls.mnode,
- volname=cls.volname,
- smb_users_info=cls.smb_users_info)
- if not ret:
- raise ExecutionError("Failed to export volume %s "
- "as SMB Share" % cls.volname)
- g.log.info("Successful in exporting volume %s as SMB Share",
- cls.volname)
-
- # Set SMB share specific volume options
- if cls.smb_share_options:
- g.log.info("Setting SMB share specific volume options "
- "on volume %s", cls.volname)
- ret = set_volume_options(mnode=cls.mnode,
- volname=cls.volname,
- options=cls.smb_share_options)
- if not ret:
- raise ExecutionError("Failed to set SMB share "
- "specific options "
- "on volume %s" % cls.volname)
- g.log.info("Successful in setting SMB share specific "
- "volume options on volume %s", cls.volname)
+ # Set SMB share specific volume options
+ if cls.smb_share_options:
+ g.log.info("Setting SMB share specific volume options "
+ "on volume %s", cls.volname)
+ ret = set_volume_options(mnode=cls.mnode,
+ volname=cls.volname,
+ options=cls.smb_share_options)
+ if not ret:
+ g.log.error("Failed to set SMB share "
+ "specific options "
+ "on volume %s", cls.volname)
+ return False
+ g.log.info("Successful in setting SMB share specific "
+ "volume options on volume %s", cls.volname)
# Log Volume Info and Status
g.log.info("Log Volume %s Info and Status", cls.volname)
ret = log_volume_info_and_status(cls.mnode, cls.volname)
if not ret:
- raise ExecutionError("Logging volume %s info and status failed" %
- cls.volname)
+ g.log.error("Logging volume %s info and status failed",
+ cls.volname)
+ return False
g.log.info("Successful in logging volume %s info and status",
cls.volname)
+ return True
+
@classmethod
def mount_volume(cls, mounts):
"""Mount volume
@@ -292,15 +302,15 @@ class GlusterBaseClass(unittest.TestCase):
mount_obj.client_system, mount_obj.mountpoint)
ret = mount_obj.mount()
if not ret:
- raise ExecutionError("Failed to mount volume '%s:%s' on "
- "'%s:%s'" % (mount_obj.server_system,
- mount_obj.volname,
- mount_obj.client_system,
- mount_obj.mountpoint))
- g.log.info("Successful in mounting volume '%s:%s' on "
- "'%s:%s'", mount_obj.server_system,
- mount_obj.volname, mount_obj.client_system,
- mount_obj.mountpoint)
+ g.log.error("Failed to mount volume '%s:%s' on '%s:%s'",
+ mount_obj.server_system, mount_obj.volname,
+ mount_obj.client_system, mount_obj.mountpoint)
+ return False
+ else:
+ g.log.info("Successful in mounting volume '%s:%s' on "
+ "'%s:%s'", mount_obj.server_system,
+ mount_obj.volname, mount_obj.client_system,
+ mount_obj.mountpoint)
g.log.info("Successful in mounting all mount objs for the volume %s",
cls.volname)
@@ -308,6 +318,8 @@ class GlusterBaseClass(unittest.TestCase):
g.log.info("Get mounts Info:")
log_mounts_info(mounts)
+ return True
+
@classmethod
def setup_volume_and_mount_volume(cls, mounts, volume_create_force=False):
"""Setup the volume and mount the volume
@@ -317,12 +329,20 @@ class GlusterBaseClass(unittest.TestCase):
volume_create_force(bool): True if create_volume should be
executed with 'force' option.
- Returns: None
+ Returns (bool): True if setting up volume and mounting the volume
+ for a mount obj is successful. False otherwise
"""
# Setup Volume
- cls.setup_volume(volume_create_force)
+ _rc = cls.setup_volume(volume_create_force)
+ if not _rc:
+ return _rc
+
# Mount Volume
- cls.mount_volume(mounts)
+ _rc = cls.mount_volume(mounts)
+ if not _rc:
+ return _rc
+
+ return True
@classmethod
def unmount_volume(cls, mounts):
@@ -351,10 +371,11 @@ class GlusterBaseClass(unittest.TestCase):
log_mounts_info(cls.mounts)
return False
- g.log.info("Successful in unmounting volume '%s:%s' on "
- "'%s:%s'", mount_obj.server_system,
- mount_obj.volname, mount_obj.client_system,
- mount_obj.mountpoint)
+ else:
+ g.log.info("Successful in unmounting volume '%s:%s' on "
+ "'%s:%s'", mount_obj.server_system,
+ mount_obj.volname, mount_obj.client_system,
+ mount_obj.mountpoint)
g.log.info("Successful in unmounting all mount objs for the volume %s",
cls.volname)
@@ -453,12 +474,10 @@ class GlusterBaseClass(unittest.TestCase):
cls.smb_users_info = (
g.config['gluster']['cluster_config']['smb']['users_info'])
except KeyError:
- cls.smb_users_info = {
- 'root': {
- 'password': 'foobar',
- 'acl': 'rwx',
- }
- }
+ cls.smb_users_info = {}
+ cls.smb_users_info['root'] = {}
+ cls.smb_users_info['root']['password'] = 'foobar'
+ cls.smb_users_info['root']['acl'] = 'rwx'
# NFS-Ganesha Cluster info
try: