diff options
author | Shwetha-H-Panduranga <shwetha@gluster.com> | 2011-12-07 11:56:48 +0530 |
---|---|---|
committer | Shwetha-H-Panduranga <shwetha@gluster.com> | 2011-12-07 11:56:48 +0530 |
commit | 4399cf4d161526300244d8cf090a461c792ab82e (patch) | |
tree | 7ca5ad70b0429148c63ab77667e8e54acaf5b11e /libs/utils/managerutils.py | |
parent | 77c7f324610224e808d8940aec7e6dbf19b790a5 (diff) |
Renaming Directories
Diffstat (limited to 'libs/utils/managerutils.py')
-rw-r--r-- | libs/utils/managerutils.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/libs/utils/managerutils.py b/libs/utils/managerutils.py new file mode 100644 index 0000000..ca38b3f --- /dev/null +++ b/libs/utils/managerutils.py @@ -0,0 +1,55 @@ +"""managerutils module. + +Supported Wrappers:- +--------------- +*) ssh_connect +*) ssh_connect_allhosts +""" + +import re +import ssh +from atfglobals import GlobalObj + +def ssh_connect(hostkey): + """ + """ + env = GlobalObj.getTestenvObj() + cm = GlobalObj.getConnectionsManagerObj() + host_connection = cm.getConnection(hostkey) + if not host_connection: + host_obj = env.getHost(hostkey) + if not host_obj: + print "Invalid Host. %s is not defined in TestEnvironment" % hostkey + return 1 + else: + host_connection = ssh.SshConnection() + if host_connection.connect(host_obj.hostname, host_obj.user, + host_obj.password): + return 1 + else: + if re.match("server", hostkey, re.IGNORECASE): + cm.addServer(hostkey, host_connection) + else: + cm.addClient(hostkey, host_connection) + return 0 + else: + print "Connection to %s already exist" % hostkey + + return 0 + +def ssh_connect_allhosts(): + """ + """ + env = GlobalObj.getTestenvObj() + cm = GlobalObj.getConnectionsManagerObj() + hosts_keys = env.getHostsKeys() + for hostkey in hosts_keys: + return_status = ssh_connect(hostkey) + if return_status: + return return_status + + return 0 + +__all__ = ['ssh_connect', + 'ssh_connect_allhosts'] + |