aboutsummaryrefslogtreecommitdiff
path: root/rumba/ssh_support.py
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri.staessens@ugent.be>2017-11-15 00:03:05 +0100
committerSander Vrijders <sander.vrijders@ugent.be>2017-11-15 17:06:01 +0100
commit2e91ca33f90f7c74887013e08c95bb00cdd4fc00 (patch)
tree7f12aa13b45eb9e91d495b8c67b313e24585701b /rumba/ssh_support.py
parent0801eba70daacddd5692543dea013e85a82ef76b (diff)
downloadrumba-2e91ca33f90f7c74887013e08c95bb00cdd4fc00.tar.gz
rumba-2e91ca33f90f7c74887013e08c95bb00cdd4fc00.zip
prototypes: Fix VLAN setup for IRATI on Ubuntu
Some exogeni nodes have scripts that auto-rename interfaces in a way that causes conflicts with VLAN setup for IRATI. This removes those scripts and restarts the network daemon for the changes to take effect.
Diffstat (limited to 'rumba/ssh_support.py')
-rw-r--r--rumba/ssh_support.py33
1 files changed, 18 insertions, 15 deletions
diff --git a/rumba/ssh_support.py b/rumba/ssh_support.py
index ccff321..60a3767 100644
--- a/rumba/ssh_support.py
+++ b/rumba/ssh_support.py
@@ -294,14 +294,13 @@ def copy_file_to_testbed(testbed, ssh_config, path, destination):
copy_files_to_testbed(testbed, ssh_config, [path], destination)
-def setup_vlan(testbed, node, vlan_id, int_name):
+def setup_vlans(testbed, node, vlans):
"""
Gets the interface (ethx) to link mapping
@param testbed: testbed info
@param node: the node to create the VLAN on
- @param vlan_id: the VLAN id
- @param int_name: the name of the interface
+ @param vlans: list of lists of VLAN id to interface
"""
if testbed.username == 'root':
def sudo(s):
@@ -310,20 +309,24 @@ def setup_vlan(testbed, node, vlan_id, int_name):
def sudo(s):
return 'sudo ' + s
- logger.debug("Setting up VLAN on node %s, if %s.", node.name, int_name)
+ cmds = ["if [ -d /etc/udev/rules.d ] && "
+ "[ \"$(ls -A /etc/udev/rules.d)\" ]; "
+ "then sudo rm /etc/udev/rules.d/*; "
+ "type systemctl > /dev/null 2>&1; "
+ "if [ $? -eq 0 ]; then sudo systemctl "
+ "restart systemd-networkd; fi; fi"]
- args = {'ifname': str(int_name), 'vlan': str(vlan_id)}
+ for item in vlans:
+ args = {'ifname': str(item[0]), 'vlan': str(item[1])}
+ cmds += [sudo("ip link add link %(ifname)s name "
+ "%(ifname)s.%(vlan)s type vlan id %(vlan)s" % args),
+ sudo("ip link set dev %(ifname)s.%(vlan)s up" % args)]
+ if testbed.flags['no_vlan_offload']:
+ cmds += [sudo("ethtool -K %(ifname)s rxvlan off" % args),
+ sudo("ethtool -K %(ifname)s txvlan off" % args)]
+
+ logger.info('Setting up VLANs for node %s', node.name)
- cmds = [sudo("ip link add link %(ifname)s name "
- "%(ifname)s.%(vlan)s type vlan id %(vlan)s"
- % args),
- sudo("ip link set dev %(ifname)s.%(vlan)s up"
- % args)]
- if testbed.flags['no_vlan_offload']:
- cmds += [sudo("ethtool -K %(ifname)s rxvlan off"
- % args),
- sudo("ethtool -K %(ifname)s txvlan off"
- % args)]
execute_commands(testbed, node.ssh_config, cmds)
def aptitude_install(testbed, node, packages):