aboutsummaryrefslogtreecommitdiff
path: root/rumba/testbeds/qemu.py
diff options
context:
space:
mode:
authorMarco Capitani <m.capitani@nextworks.it>2017-04-14 11:57:47 +0200
committerMarco Capitani <m.capitani@nextworks.it>2017-04-14 11:57:47 +0200
commitfbbc602d9efd9f88ce35b09c02f1226881c32bfb (patch)
tree4ac9c55ed6e27caf170746490578288727d6ee5d /rumba/testbeds/qemu.py
parent6fb1eba8509fd0f9bb9cb6f2d4072e1cd879fe04 (diff)
downloadrumba-fbbc602d9efd9f88ce35b09c02f1226881c32bfb.tar.gz
rumba-fbbc602d9efd9f88ce35b09c02f1226881c32bfb.zip
Bugfixing for IRATI prototype and QEMU testbed
Diffstat (limited to 'rumba/testbeds/qemu.py')
-rw-r--r--rumba/testbeds/qemu.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/rumba/testbeds/qemu.py b/rumba/testbeds/qemu.py
index d3e1698..8ccc704 100644
--- a/rumba/testbeds/qemu.py
+++ b/rumba/testbeds/qemu.py
@@ -76,6 +76,8 @@ class Testbed(mod.Testbed):
results_queue.put("Command chain ran with %d errors" % errors)
def recover_if_names(self, experiment):
+ next_vlan = 10
+ assigned_vlan = {}
for node in experiment.nodes:
for ipcp in node.ipcps:
if isinstance(ipcp, mod.ShimEthIPCP):
@@ -88,16 +90,20 @@ class Testbed(mod.Testbed):
mac = '00:0a:0a:0a:%02x:%02x' % (vm_id, port_id)
print('DEBUG: recovering ifname for port: '
+ port['tap_id'] + '.')
- output = ssh_support.return_commands(
+ output = ssh_support.execute_command(
self,
node.ssh_config,
- ['mac2ifname ' + mac])
- print('DEBUG: output is %s' % output)
- if not hasattr(output, '__len__') or len(output) != 1:
- raise Exception("Could not retrieve ifname for ipcp %s."
- % ipcp.name)
- ipcp.ifname = output[0]
- args = {'vlan': int(port['shim'].name), 'port': ipcp.ifname}
+ 'mac2ifname ' + mac)
+ ipcp.ifname = output
+ try:
+ vlan = int(port['shim'].name)
+ except ValueError:
+ vlan = assigned_vlan.get(port['shim'].name, None)
+ if vlan is None:
+ vlan = next_vlan
+ next_vlan += 10
+ assigned_vlan[port['shim'].name] = vlan
+ args = {'vlan': vlan, 'port': ipcp.ifname}
cmds = ['ip link set %(port)s up'
% args,
'ip link add link %(port)s name %(port)s.%(vlan)s '
@@ -109,7 +115,6 @@ class Testbed(mod.Testbed):
node.ssh_config,
cmds)
-
def swap_in(self, experiment):
"""
:type experiment mod.Experiment
@@ -303,6 +308,10 @@ class Testbed(mod.Testbed):
print('Sleeping %s secs waiting for the last VMs to boot' % tsleep)
time.sleep(tsleep)
+ # TODO: to be removed, we should loop in the ssh part
+ print('Sleeping 5 seconds, just to be on the safe side')
+ time.sleep(5)
+
self.recover_if_names(experiment)
def swap_out(self, experiment):