diff options
Diffstat (limited to 'libs/utils/clientutils.py')
-rw-r--r-- | libs/utils/clientutils.py | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/libs/utils/clientutils.py b/libs/utils/clientutils.py index ad5d593..33f036e 100644 --- a/libs/utils/clientutils.py +++ b/libs/utils/clientutils.py @@ -12,6 +12,7 @@ Supported Wrappers :- import atfutils import hostutils from atfglobals import GlobalObj +import pdb def umount(mountkey): """unmounts a mountpoint @@ -24,23 +25,26 @@ def umount(mountkey): Success : 0 Failure : 1` """ - base_command = "umount " + logger = GlobalObj.getLoggerObj() + 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 + logger.error("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 + logger.error("SSH connection to host '%s' has not been established" + % clientkey) return 1 - command = base_command + mount_obj.dir - print "%s : %s" % (clientkey, command) + command = ' '.join([base_command, mount_obj.dir]) + logger.debug('%s: Executing Command: %s' % (clientkey, command)) output = client_connection.executecommand(command) return_status = atfutils.assert_success(**output) atfutils.print_stdout(output['stdoutdata']) @@ -51,7 +55,7 @@ def umount(mountkey): return_status = 0 else: - print "Unable to umount %s" % mountkey + logger.error("Unable to umount %s" % mountkey) return return_status @@ -91,41 +95,44 @@ def mount(mountkey): Success : 0 Failure : 1` """ - - base_command = command = "mount " + logger = GlobalObj.getLoggerObj() + base_command = "mount" env = GlobalObj.getTestenvObj() cm = GlobalObj.getConnectionsManagerObj() + command = [base_command] + options = [] mount_obj = env.getMount(mountkey) if not mount_obj: - print "InValid Mount. %s not defined in TestEnvironment" % mountkey + logger.error("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 + logger.error("SSH connection to host '%s' has not been established" + % clientkey) return 1 + return_status = hostutils.mkdir(clientkey, mount_obj.dir) + if return_status: + return return_status + mountdevice_obj = mount_obj.device device = mountdevice_obj.hostname + ":/" + mountdevice_obj.volumename - options = ["-t", mount_obj.type] + options.extend(["-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 + " " + + command.extend(options) + command = ' '.join(command) - return_status = hostutils.mkdir(clientkey, mount_obj.dir) - if return_status: - return return_status - - print "%s : %s" % (clientkey, command) + logger.debug('%s: Executing Command: %s' % (clientkey, command)) output = client_connection.executecommand(command) return_status = atfutils.assert_success(**output) atfutils.print_stdout(output['stdoutdata']) @@ -156,12 +163,15 @@ def mountall(): def execute_on_mount(mountkey, command, commandInput=None): """ """ + logger = GlobalObj.getLoggerObj() env = GlobalObj.getTestenvObj() mount_obj = env.getMount(mountkey) if not mount_obj: - print "InValid Mount. %s not defined in TestEnvironment" % mountkey + logger.error("InValid Mount. %s not defined in TestEnvironment" + % mountkey) return 1 + clientkey = mount_obj.client mountdir = mount_obj.dir command = "cd " + mountdir + " ;" + command |