aboutsummaryrefslogtreecommitdiff
path: root/rumba/prototypes/irati.py
diff options
context:
space:
mode:
authorMarco Capitani <m.capitani@nextworks.it>2017-04-19 11:52:21 +0200
committerMarco Capitani <m.capitani@nextworks.it>2017-04-19 11:52:21 +0200
commit91d22038f85b1f8a9e20772d5f6a6f7ad37963f2 (patch)
treeebda1768f834f62c58776988d92fa8562b6b1e0e /rumba/prototypes/irati.py
parent1d3022acb3fa3067f2027ae1a2c61aa99790c024 (diff)
downloadrumba-91d22038f85b1f8a9e20772d5f6a6f7ad37963f2.tar.gz
rumba-91d22038f85b1f8a9e20772d5f6a6f7ad37963f2.zip
Fixes for issues #4 and #5 (irati plugin and vlans)
Diffstat (limited to 'rumba/prototypes/irati.py')
-rw-r--r--rumba/prototypes/irati.py68
1 files changed, 49 insertions, 19 deletions
diff --git a/rumba/prototypes/irati.py b/rumba/prototypes/irati.py
index 1965069..e248720 100644
--- a/rumba/prototypes/irati.py
+++ b/rumba/prototypes/irati.py
@@ -31,6 +31,9 @@ import rumba.prototypes.irati_templates as irati_templates
# An experiment over the IRATI implementation
+from rumba import ssh_support
+
+
class Experiment(mod.Experiment):
@staticmethod
@@ -45,6 +48,7 @@ class Experiment(mod.Experiment):
mod.Experiment.__init__(self, testbed, nodes)
self.manager = False
self.conf_files = None
+ self.shim2vlan = {}
if self.testbed.username == 'root':
self.sudo = self.fake_sudo
@@ -93,6 +97,7 @@ class Experiment(mod.Experiment):
print("irati: configuration files generated for all nodes")
self.bootstrap_network()
print("irati: IPCPs created and enrolled on all nodes")
+ input('Press ENTER to quit')
def process_node(self, node):
"""
@@ -102,6 +107,14 @@ class Experiment(mod.Experiment):
:return:
"""
name = node.name
+
+ for ipcp in node.ipcps:
+ if isinstance(ipcp, mod.ShimEthIPCP):
+ if_name = ipcp.ifname
+ vlan = self.shim2vlan[ipcp.dif.name]
+ ssh_support.setup_vlan(self.testbed, node,
+ vlan, if_name)
+
gen_files_conf = self.conf_files[node] + ['da.map']
dir_path = os.path.dirname(os.path.abspath(__file__))
gen_files_bin = 'enroll.py'
@@ -124,16 +137,12 @@ class Experiment(mod.Experiment):
'installpath': '/usr',
'verb': 'DBG',
'ipcmcomps': ipcm_components}
- try:
- # TODO: watch out for empty path...
- ssh.copy_paths_to_testbed(self.testbed,
- node.ssh_config,
- gen_files,
- '')
- except subprocess.CalledProcessError as e:
- raise Exception(str(e))
- # TODO: review ssh opts through ssh support
+ # TODO: watch out for empty path...
+ ssh.copy_paths_to_testbed(self.testbed,
+ node.ssh_config,
+ gen_files,
+ '')
cmds = [self.sudo('hostname %(name)s' % format_args),
self.sudo('chmod a+rw /dev/irati'),
@@ -141,8 +150,6 @@ class Experiment(mod.Experiment):
self.sudo('mv %(genfilesbin)s /usr/bin') % format_args,
self.sudo('chmod a+x /usr/bin/enroll.py') % format_args]
- # TODO: is the port up on the VM at this point?
-
cmds += [self.sudo('modprobe rina-default-plugin'),
self.sudo('%(installpath)s/bin/ipcm -a \"%(ipcmcomps)s\" '
'-c /etc/%(name)s.ipcm.conf -l %(verb)s &> log &'
@@ -168,7 +175,7 @@ class Experiment(mod.Experiment):
subprocess.check_call('sleep 2'. split()) # Important!
- e_args = {'ldif': e['lower_dif'].name,
+ e_args = {'ldif': self.dif_name(e['lower_dif']),
'dif': e['dif'].name,
'name': e['enrollee'].name,
'o_name': e['enroller'].name}
@@ -187,6 +194,12 @@ class Experiment(mod.Experiment):
e['enrollee'].ssh_config,
cmd)
+ def dif_name(self, dif):
+ try:
+ return str(self.shim2vlan[dif.name])
+ except KeyError:
+ return dif.name
+
def write_conf(self):
"""Write the configuration files"""
# Constants and initializations
@@ -197,10 +210,22 @@ class Experiment(mod.Experiment):
mgmt_dif_name = 'NMS'
conf_files = {} # dict of per-nod conf files
+ # Translating Shim Eth difs to vlan tags.
+ next_vlan = 10
+ for dif in self.dif_ordering:
+ if isinstance(dif, mod.ShimEthDIF):
+ try:
+ vlan = int(dif.name)
+ self.shim2vlan[dif.name] = vlan
+ except ValueError:
+ vlan = next_vlan
+ next_vlan += 10
+ self.shim2vlan[dif.name] = vlan
+
# TODO: what format are the mappings registered in? Is this ok?
app_mappings = []
for node in self.nodes:
- app_mappings += [{'name': app, 'dif': dif.name}
+ app_mappings += [{'name': app, 'dif': self.dif_name(dif)}
for app in node.registrations
for dif in node.registrations[app]]
@@ -262,16 +287,19 @@ class Experiment(mod.Experiment):
for ipcp in node.ipcps: # type: mod.ShimEthIPCP
if isinstance(ipcp, mod.ShimEthIPCP):
shim = ipcp2shim_map[ipcp.name] # type: mod.ShimEthDIF
+ shim_name = self.dif_name(shim)
ipcmconf["ipcProcessesToCreate"].append({
"apName": "eth.%s.IPCP" % ipcp.name,
"apInstance": "1",
- "difName": shim.name
+ "difName": shim_name
})
- template_file_name = self.conf_dir('shimeth.%s.%s.dif'
- % (node.name, shim.name))
+
+ template_file_name = self.conf_dir(
+ 'shimeth.%s.%s.dif'
+ % (node.name, shim_name))
ipcmconf["difConfigurations"].append({
- "name": shim.name,
+ "name": shim_name,
"template": os.path.basename(template_file_name)
})
@@ -285,7 +313,8 @@ class Experiment(mod.Experiment):
indent=4, sort_keys=True))
fout.close()
conf_files.setdefault(node, []).append(
- 'shimeth.%s.%s.dif' % (node.name, shim.name))
+ 'shimeth.%s.%s.dif'
+ % (node.name, shim_name))
# Run over dif_ordering array, to make sure each IPCM config has
# the correct ordering for the ipcProcessesToCreate list of operations.
@@ -310,7 +339,8 @@ class Experiment(mod.Experiment):
"difsToRegisterAt": []}
for lower_dif in node.dif_registrations[dif]: # type: mod.DIF
- normal_ipcp["difsToRegisterAt"].append(lower_dif.name)
+ normal_ipcp["difsToRegisterAt"].append(
+ self.dif_name(lower_dif))
ipcmconf["ipcProcessesToCreate"].append(normal_ipcp)