aboutsummaryrefslogtreecommitdiff
path: root/rumba/ssh_support.py
diff options
context:
space:
mode:
Diffstat (limited to 'rumba/ssh_support.py')
-rw-r--r--rumba/ssh_support.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/rumba/ssh_support.py b/rumba/ssh_support.py
index 13ac1c6..ca4893c 100644
--- a/rumba/ssh_support.py
+++ b/rumba/ssh_support.py
@@ -27,13 +27,13 @@ def get_ssh_client():
return ssh_client
-def execute_commands(testbed, hostname, commands, time_out=3):
+def execute_commands(testbed, ssh_config, commands, time_out=3):
'''
Remote execution of a list of shell command on hostname. By
default this function will exit (timeout) after 3 seconds.
@param testbed: testbed info
- @param hostname: host name or ip address of the node
+ @param ssh_config: ssh config of the node
@param command: *nix shell command
@param time_out: time_out value in seconds, error will be generated if
no result received in given number of seconds, the value None can
@@ -42,7 +42,7 @@ def execute_commands(testbed, hostname, commands, time_out=3):
ssh_client = get_ssh_client()
try:
- ssh_client.connect(hostname, 22,
+ ssh_client.connect(ssh_config.hostname, ssh_config.port,
testbed.username, testbed.password,
look_for_keys=True, timeout=time_out)
for command in commands:
@@ -59,13 +59,13 @@ def execute_commands(testbed, hostname, commands, time_out=3):
print(str(e))
return
-def execute_command(testbed, hostname, command, time_out=3):
+def execute_command(testbed, ssh_config, command, time_out=3):
'''
Remote execution of a list of shell command on hostname. By
default this function will exit (timeout) after 3 seconds.
@param testbed: testbed info
- @param hostname: host name or ip address of the node
+ @param ssh_config: ssh config of the node
@param command: *nix shell command
@param time_out: time_out value in seconds, error will be generated if
no result received in given number of seconds, the value None can
@@ -76,7 +76,7 @@ def execute_command(testbed, hostname, command, time_out=3):
ssh_client = get_ssh_client()
try:
- ssh_client.connect(hostname, 22,
+ ssh_client.connect(ssh_config.hostname, ssh_config.port,
testbed.username, testbed.password,
look_for_keys=True, timeout=time_out)
stdin, stdout, stderr = ssh_client.exec_command(command)
@@ -93,13 +93,13 @@ def execute_command(testbed, hostname, command, time_out=3):
print(str(e))
return
-def copy_file_to_testbed(testbed, hostname, text, file_name):
+def copy_file_to_testbed(testbed, ssh_config, text, file_name):
'''
Write a string to a given remote file.
Overwrite the complete file if it already exists!
@param testbed: testbed info
- @param hostname: host name or ip address of the node
+ @param ssh_config: ssh config of the node
@param text: string to be written in file
@param file_name: file name (including full path) on the host
'''
@@ -140,19 +140,20 @@ def setup_vlan(testbed, node, vlan_id, int_name):
'''
print("Setting up VLAN on node " + node.name)
+ cmds = list()
cmd = "sudo ip link add link " + \
str(int_name) + \
" name " + str(int_name) + \
"." + str(vlan_id) + \
" type vlan id " + str(vlan_id)
- execute_command(testbed, node.full_name, cmd)
+ cmds.append(cmd)
cmd = "sudo ifconfig " + \
str(int_name) + "." + \
str(vlan_id) + " up"
- execute_command(node.full_name, cmd, testbed)
+ cmds.append(cmd)
cmd = "sudo ethtool -K " + \
str(int_name) + " rxvlan off"
- execute_command(node.full_name, cmd, testbed)
+ cmds.append(cmd)
cmd = "sudo ethtool -K " + \
str(int_name) + " txvlan off"
- execute_command(node.full_name, cmd, testbed)
+ execute_commands(testbed, node.ssh_config, cmds)