aboutsummaryrefslogtreecommitdiff
path: root/rumba/ssh_support.py
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@ugent.be>2017-03-28 18:14:32 +0200
committerSander Vrijders <sander.vrijders@ugent.be>2017-03-28 18:14:32 +0200
commit92d2849f76c3395f9a51ab79a5726e1df5348ba8 (patch)
treea6edcfde2679f0377c6d34e16f292ffd5a2391a7 /rumba/ssh_support.py
parent28556357ef43a549d18bf9a38d3c81b16f0ccbe6 (diff)
downloadrumba-92d2849f76c3395f9a51ab79a5726e1df5348ba8.tar.gz
rumba-92d2849f76c3395f9a51ab79a5726e1df5348ba8.zip
Fix pylint warnings and errors
This fixes several warnings and errors as reported by pylint.
Diffstat (limited to 'rumba/ssh_support.py')
-rw-r--r--rumba/ssh_support.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/rumba/ssh_support.py b/rumba/ssh_support.py
index 552c43f..13ac1c6 100644
--- a/rumba/ssh_support.py
+++ b/rumba/ssh_support.py
@@ -27,7 +27,7 @@ def get_ssh_client():
return ssh_client
-def execute_commands(testbed, hostname, commands, time_out = 3):
+def execute_commands(testbed, hostname, commands, time_out=3):
'''
Remote execution of a list of shell command on hostname. By
default this function will exit (timeout) after 3 seconds.
@@ -44,9 +44,10 @@ def execute_commands(testbed, hostname, commands, time_out = 3):
try:
ssh_client.connect(hostname, 22,
testbed.username, testbed.password,
- look_for_keys = True, timeout = time_out)
+ look_for_keys=True, timeout=time_out)
for command in commands:
stdin, stdout, stderr = ssh_client.exec_command(command)
+ del stdin, stdout
err = str(stderr.read()).strip('b\'\"\\n')
if err != "":
err_array = err.split('\\n')
@@ -58,7 +59,7 @@ 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, hostname, command, time_out=3):
'''
Remote execution of a list of shell command on hostname. By
default this function will exit (timeout) after 3 seconds.
@@ -77,8 +78,9 @@ def execute_command(testbed, hostname, command, time_out = 3):
try:
ssh_client.connect(hostname, 22,
testbed.username, testbed.password,
- look_for_keys = True, timeout = time_out)
+ look_for_keys=True, timeout=time_out)
stdin, stdout, stderr = ssh_client.exec_command(command)
+ del stdin
err = str(stderr.read()).strip('b\'\"\\n')
if err != "":
print(err)
@@ -113,6 +115,7 @@ def copy_file_to_testbed(testbed, hostname, text, file_name):
"; chmod a+rwx " + file_name
stdin, stdout, stderr = ssh_client.exec_command(cmd)
+ del stdin, stdout
err = str(stderr.read()).strip('b\'\"\\n')
if err != "":
print(err)
@@ -126,31 +129,30 @@ def copy_file_to_testbed(testbed, hostname, text, file_name):
except Exception as e:
print(str(e))
-def setup_vlan(testbed, node_name, vlan_id, int_name):
+def setup_vlan(testbed, node, vlan_id, int_name):
'''
Gets the interface (ethx) to link mapping
@param testbed: testbed info
- @param node_name: the node to create the VLAN on
+ @param node: the node to create the VLAN on
@param vlan_id: the VLAN id
@param int_name: the name of the interface
'''
- print("Setting up VLAN on node " + node_name)
+ print("Setting up VLAN on node " + node.name)
- node_full_name = full_name(node_name, testbed)
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)
+ execute_command(testbed, node.full_name, cmd)
cmd = "sudo ifconfig " + \
str(int_name) + "." + \
str(vlan_id) + " up"
- execute_command(node_full_name, cmd, testbed)
+ execute_command(node.full_name, cmd, testbed)
cmd = "sudo ethtool -K " + \
str(int_name) + " rxvlan off"
- execute_command(node_full_name, cmd, testbed)
+ execute_command(node.full_name, cmd, testbed)
cmd = "sudo ethtool -K " + \
str(int_name) + " txvlan off"
- execute_command(node_full_name, cmd, testbed)
+ execute_command(node.full_name, cmd, testbed)