aboutsummaryrefslogtreecommitdiff
path: root/rumba/ssh_support.py
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@ugent.be>2017-11-15 10:27:58 +0100
committerSander Vrijders <sander.vrijders@ugent.be>2017-11-15 10:55:14 +0100
commit88e18d3e30d67681b0f6cf4a55c731255daa650b (patch)
tree08b688a40b36181533f74f80435e8318dd0ba70e /rumba/ssh_support.py
parenta10232a5bd0db41733d0d8562e2fe56008f01cec (diff)
downloadrumba-88e18d3e30d67681b0f6cf4a55c731255daa650b.tar.gz
rumba-88e18d3e30d67681b0f6cf4a55c731255daa650b.zip
prototypes: Use common aptitude install function
This lets the prototypes use a common function to install packages through aptitude.
Diffstat (limited to 'rumba/ssh_support.py')
-rw-r--r--rumba/ssh_support.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/rumba/ssh_support.py b/rumba/ssh_support.py
index bb0eb2e..7b9112a 100644
--- a/rumba/ssh_support.py
+++ b/rumba/ssh_support.py
@@ -325,3 +325,31 @@ def setup_vlan(testbed, node, vlan_id, int_name):
sudo("ethtool -K %(ifname)s txvlan off"
% args)]
execute_commands(testbed, node.ssh_config, cmds)
+
+def aptitude_install(testbed, node, packages):
+ """
+ Installs packages through aptitude
+
+ @param testbed: testbed info
+ @param node: the node to install the packages on
+ @param packages: list of packages
+ """
+
+ if testbed.username == 'root':
+ def sudo(s):
+ return s
+ else:
+ def sudo(s):
+ return 'sudo ' + s
+
+ package_install = "apt-get install "
+ for package in packages:
+ package_install += package + " "
+ package_install += "--yes"
+
+ cmds = [sudo("while fuser /var/lib/dpkg/lock > /dev/null 2>&1 " +
+ "do sleep 1; echo \"Waiting for dpkg...\"; done"),
+ sudo("apt-get update"),
+ sudo(package_install)]
+
+ execute_proxy_commands(testbed, node.ssh_config, cmds, time_out=None)