aboutsummaryrefslogtreecommitdiff
path: root/rumba/testbeds/emulab.py
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@ugent.be>2017-03-28 13:18:26 +0200
committerSander Vrijders <sander.vrijders@ugent.be>2017-03-28 16:29:51 +0200
commit0e8936e55956813f7f7db633b1cb96241a78ea58 (patch)
tree39b26c2cf3b8943d9f34d87fb9a537c0b13e860f /rumba/testbeds/emulab.py
parent99d8c66180e24849bb4f0f7edd1be4fe852f44db (diff)
downloadrumba-0e8936e55956813f7f7db633b1cb96241a78ea58.tar.gz
rumba-0e8936e55956813f7f7db633b1cb96241a78ea58.zip
testbeds: Port to new API
The new API passes the Experiment instance to the testbeds, so that the configs for the testbeds can be generated starting from the IPCPs. The classes Link, Interface, P2PLink have been deprecated.
Diffstat (limited to 'rumba/testbeds/emulab.py')
-rw-r--r--rumba/testbeds/emulab.py67
1 files changed, 32 insertions, 35 deletions
diff --git a/rumba/testbeds/emulab.py b/rumba/testbeds/emulab.py
index cbaa730..c696fbb 100644
--- a/rumba/testbeds/emulab.py
+++ b/rumba/testbeds/emulab.py
@@ -37,7 +37,7 @@ warnings.filterwarnings("ignore")
#
class Testbed(mod.Testbed):
def __init__(self, exp_name, username, password = "",
- proj_name = "ARCFIRE", url = "wall1.ilabt.iminds.be",
+ proj_name = "ARCFIRE", url = "wall2.ilabt.iminds.be",
image = "UBUNTU14-64-STD"):
mod.Testbed.__init__(self, exp_name, username, password, proj_name)
self.url = url
@@ -101,13 +101,12 @@ class Testbed(mod.Testbed):
return output
- def _create_experiment(self, nodes, links):
+ def _create_experiment(self, experiment):
'''
Creates an emulab experiment
@param self: testbed info
- @param nodes: holds the nodes in the experiment
- @param links: holds the links in the experiment
+ @param experiment: the experiment
'''
proj_name = self.proj_name
exp_name = self.exp_name
@@ -121,7 +120,7 @@ class Testbed(mod.Testbed):
except:
print("First experiment to be created for that project.")
- ns = self.generate_ns_script(nodes, links)
+ ns = self.generate_ns_script(experiment)
dest_file_name = '/users/'+ self.username + \
'/temp_ns_file.%s.ns' % os.getpid()
ssh.copy_file_to_testbed(self, self.ops_server(), ns, dest_file_name)
@@ -135,13 +134,12 @@ class Testbed(mod.Testbed):
ssh.execute_command(self, self.ops_server(),'rm ' + dest_file_name)
print("New experiment succesfully created.")
- def generate_ns_script(self, nodes, p2plinks):
+ def generate_ns_script(self, experiment):
'''
Generate ns script based on network graph.
Enables to customize default node image.
- @param nodes: holds the nodes in the experiment
- @param links: holds the links in the experiment
+ @param experiment: the experiment
@param self: testbed info
@return: ns2 script for Emulab experiment
@@ -151,16 +149,19 @@ class Testbed(mod.Testbed):
ns2_script += "set ns [new Simulator]\n"
ns2_script += "source tb_compat.tcl\n"
- for node in nodes:
+ for node in experiment.nodes:
ns2_script += "set " + node.name + " [$ns node]\n"
ns2_script += "tb-set-node-os $" + node.name + " " + \
self.image + "\n"
- for link in p2plinks:
- ns2_script += "set " + link.name + \
+ for dif in experiment.dif_ordering:
+ if type(dif) is mod.ShimEthDIF:
+ if len(dif.ipcps) != 2:
+ continue
+ ns2_script += "set " + dif.name + \
" [$ns duplex-link $" + \
- link.node_a.name + " $" + \
- link.node_b.name + " 1000Mb 0ms DropTail]\n"
+ dif.members[0].name + " $" + \
+ dif.members[1].name + " 1000Mb 0ms DropTail]\n"
ns2_script += "$ns run\n"
@@ -191,16 +192,15 @@ class Testbed(mod.Testbed):
print("Still waiting")
time.sleep(5)
- def complete_experiment_graph(self, nodes, p2plinks):
+ def complete_experiment_graph(self, experiment):
'''
Gets the interface (ethx) to link mapping
@param self: testbed info
- @param nodes: holds the nodes in the experiment
- @param links: holds the links in the experiment
+ @param experiment: the experiment
'''
- node_full_name = self.full_name(nodes[0].name)
+ node_full_name = self.full_name(experiment.nodes[0].name)
cmd = 'cat /var/emulab/boot/topomap'
topomap = ssh.execute_command(self, node_full_name, cmd)
# Almost as ugly as yo momma
@@ -214,31 +214,28 @@ class Testbed(mod.Testbed):
item2 = item2.split(':')
link_name = item2[0]
link_ip = item2[1]
- for link in p2plinks:
- if link.name == link_name:
- if link.node_a.name == node_name:
- link.int_a.ip = link_ip
- elif link.node_b.name == node_name:
- link.int_b.ip = link_ip
-
- for node in nodes:
+ for node in experiment.nodes:
+ if node.name != node_name:
+ continue
+ for ipcp in node.ipcps:
+ if ipcp.dif.name == link_name:
+ ipcp.ip = link_ip
+
+ for node in experiment.nodes:
cmd = 'cat /var/emulab/boot/ifmap'
node_full_name = self.full_name(node.name)
output = ssh.execute_command(self, node_full_name, cmd)
output = re.split('\\\\n', output)
for item in output:
item = item.split()
- for link in p2plinks:
- if link.node_a.name == node.name and \
- link.int_a.ip == item[1]:
- link.int_a.name = item[0]
- elif link.node_b.name == node.name and \
- link.int_b.ip == item[1]:
- link.int_b.name = item[0]
+ for ipcp in node.ipcps:
+ if type(ipcp) is mod.ShimEthIPCP:
+ if ipcp.ip == item[1]:
+ ipcp.ifname = item[0]
node.full_name = self.full_name(node.name)
- def create_experiment(self, nodes, links):
- self._create_experiment(nodes, links)
+ def create_experiment(self, experiment):
+ self._create_experiment(experiment)
self.swap_exp_in()
self.wait_until_nodes_up()
- self.complete_experiment_graph(nodes, links)
+ self.complete_experiment_graph(experiment)