summaryrefslogtreecommitdiffstats
path: root/SharedModules/Utils/clientutils.py
diff options
context:
space:
mode:
Diffstat (limited to 'SharedModules/Utils/clientutils.py')
-rw-r--r--SharedModules/Utils/clientutils.py282
1 files changed, 0 insertions, 282 deletions
diff --git a/SharedModules/Utils/clientutils.py b/SharedModules/Utils/clientutils.py
deleted file mode 100644
index ad5d593..0000000
--- a/SharedModules/Utils/clientutils.py
+++ /dev/null
@@ -1,282 +0,0 @@
-"""clientutils module contains functions required for performing
-certain operations on client
-
-Supported Wrappers :-
------------
-*) umount
-*) umountall
-*) mount
-*) mountall
-"""
-
-import atfutils
-import hostutils
-from atfglobals import GlobalObj
-
-def umount(mountkey):
- """unmounts a mountpoint
-
- Parameters:
- mountkey : name given to a mount as specified in testenv.cfg file.
- Ex:-"mount1"
-
- Returns:
- Success : 0
- Failure : 1`
- """
- base_command = "umount "
- env = GlobalObj.getTestenvObj()
- cm = GlobalObj.getConnectionsManagerObj()
-
- mount_obj = env.getMount(mountkey)
- if not mount_obj:
- print "InValid Mount. %s not defined in TestEnvironment" % mountkey
- return 1
-
- clientkey = mount_obj.client
- client_connection = cm.getConnection(clientkey)
- if not client_connection:
- print "SSH connection to host '%s' has not been established" % clientkey
- return 1
-
- command = base_command + mount_obj.dir
- print "%s : %s" % (clientkey, command)
- output = client_connection.executecommand(command)
- return_status = atfutils.assert_success(**output)
- atfutils.print_stdout(output['stdoutdata'])
- atfutils.print_stderr(output['stderrdata'])
- if return_status:
- stdoutdata = str(output["stdoutdata"])
- if ((stdoutdata.rfind("not found")) or (stdoutdata.rfind("not mount"))):
- return_status = 0
-
- else:
- print "Unable to umount %s" % mountkey
-
- return return_status
-
-def umountall():
- """unmounts all mount specified in testenv.cfg file.
- Ex:- mount1, mount2 etc
-
- Parameters:
- None
-
- Returns:
- Success : 0
- Failure : 1`
- """
- env = GlobalObj.getTestenvObj()
- failure_flag = False
-
- mounts_keys = env.getMountsKeys()
- for mountkey in mounts_keys:
- return_status = umount(mountkey)
- if return_status:
- failure_flag = True
-
- if failure_flag:
- return 1
- else:
- return 0
-
-def mount(mountkey):
- """mounts a filesystem
-
- Parameters:
- mountkey : name given to a mount as specified in testenv.cfg file.
- Ex:-"mount1"
-
- Returns:
- Success : 0
- Failure : 1`
- """
-
- base_command = command = "mount "
- env = GlobalObj.getTestenvObj()
- cm = GlobalObj.getConnectionsManagerObj()
-
- mount_obj = env.getMount(mountkey)
- if not mount_obj:
- print "InValid Mount. %s not defined in TestEnvironment" % mountkey
- return 1
-
- clientkey = mount_obj.client
- client_connection = cm.getConnection(clientkey)
- if not client_connection:
- print "SSH connection to host '%s' has not been established" % clientkey
- return 1
-
- mountdevice_obj = mount_obj.device
- device = mountdevice_obj.hostname + ":/" + mountdevice_obj.volumename
- options = ["-t", mount_obj.type]
- if mount_obj.logfile:
- options.extend(["-o", ("log-file="+mount_obj.logfile),
- "log-level=INFO"])
-
- if mount_obj.options:
- options.extend([mount_obj.option])
-
- options.extend([device, mount_obj.dir])
- for index, option in enumerate(options):
- command = command + option + " "
-
- return_status = hostutils.mkdir(clientkey, mount_obj.dir)
- if return_status:
- return return_status
-
- print "%s : %s" % (clientkey, command)
- output = client_connection.executecommand(command)
- return_status = atfutils.assert_success(**output)
- atfutils.print_stdout(output['stdoutdata'])
- atfutils.print_stderr(output['stderrdata'])
- return return_status
-
-def mountall():
- """mounts a filesystem for all mounts specified in testenv.cfg file.
-
- Parameters:
- None
-
- Returns:
- Success : 0
- Failure : 1`
- """
- env = GlobalObj.getTestenvObj()
-
- mounts_keys = env.getMountsKeys()
- for mountkey in mounts_keys:
- return_status = mount(mountkey)
- if return_status:
- return return_status
-
- return 0
-
-
-def execute_on_mount(mountkey, command, commandInput=None):
- """
- """
- env = GlobalObj.getTestenvObj()
- mount_obj = env.getMount(mountkey)
- if not mount_obj:
- print "InValid Mount. %s not defined in TestEnvironment" % mountkey
- return 1
-
- clientkey = mount_obj.client
- mountdir = mount_obj.dir
- command = "cd " + mountdir + " ;" + command
- return_status = hostutils.execute_command(clientkey, command, commandInput)
- return return_status
-
-__all__ = ['execute_on_mount',
- 'umount',
- 'umountall',
- 'mount',
- 'mountall']
-
-##def umountall(clientkey):
-## """
-## """
-## base_command = "umount "
-## env = GlobalObj.get_testenv_obj()
-## cm = GlobalObj.get_connectionsmanager_obj()
-## client_obj = env.getclient(clientkey)
-## mountdir = client_obj.mountdir
-## volume = client_obj.device
-## client = cm.getconnection(clientkey)
-##
-## mountpoints = []
-## success_flag = False
-## failure_flag = False
-## command = "mount | grep " + mountdir
-## output = client.executecommand(command)
-## if not output["exitstatus"]:
-## for data in output["stdoutdata"]:
-## mountpoints.append(data.split(" ")[2])
-##
-## for mountpoint in mountpoints:
-## command = base_command + mountpoint
-## output = client.executecommand(command)
-## return_code = utils.assert_success(**output)
-## if return_code:
-## failure_flag = True
-## else:
-## success_flag = True
-## continue
-##
-## if failure_flag:
-## return 1
-##
-## mountpoints = []
-## success_flag = False
-## failure_flag = False
-## command = "mount | grep " + volume
-## output = client.executecommand(command)
-## if not output["exitstatus"]:
-## for data in output["stdoutdata"]:
-## mountpoints.append(data.split(" ")[2])
-##
-## for mountpoint in mountpoints:
-## command = base_command + mountpoint
-## output = client.executecommand(command)
-## return_code = utils.assert_success(**output)
-## if return_code:
-## failure_flag = True
-## else:
-## success_flag = True
-## continue
-##
-## if failure_flag:
-## return 1
-##
-## return 0
-
-##def cd_mount(mountkey):
-## """
-## """
-## env = GlobalObj.getTestenvObj()
-## mount_obj = env.getMount(mountkey)
-## if not mount_obj:
-## print "InValid Mount. %s not defined in TestEnvironment" % mountkey
-## return 1
-##
-## clientkey = mount_obj.client
-## dirpath = mount_obj.dir
-## return_status = hostutils.cd(clientkey, dirpath)
-## return return_status
-##
-##def cd_allmounts():
-## """
-## """
-## env = GlobalObj.getTestenvObj()
-## mounts_keys = env.getMountsKeys()
-## for mountkey in mounts_keys:
-## return_status = cd_mount(mountkey)
-## if return_status:
-## return return_status
-##
-## return 0
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-