aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rumba/prototypes/irati.py10
-rw-r--r--rumba/ssh_support.py33
2 files changed, 23 insertions, 20 deletions
diff --git a/rumba/prototypes/irati.py b/rumba/prototypes/irati.py
index 6a0b0f5..3a64ede 100644
--- a/rumba/prototypes/irati.py
+++ b/rumba/prototypes/irati.py
@@ -123,13 +123,13 @@ class Experiment(mod.Experiment):
"""
name = node.name
- logger.info('Setting up vlans for node %s', node.name)
+ vlans = []
for ipcp in node.ipcps:
if isinstance(ipcp, mod.ShimEthIPCP):
- if_name = ipcp.ifname
- vlan = self.shim2vlan[ipcp.dif.name]
- ssh.setup_vlan(self.testbed, node,
- vlan, if_name)
+ vlans.append([ipcp.ifname, self.shim2vlan[ipcp.dif.name]])
+
+ if vlans:
+ ssh.setup_vlans(self.testbed, node, vlans)
gen_files_conf = self.conf_files[node] + ['da.map']
dir_path = os.path.dirname(os.path.abspath(__file__))
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):