aboutsummaryrefslogtreecommitdiff
path: root/rumba/model.py
diff options
context:
space:
mode:
authorMarco Capitani <m.capitani@nextworks.it>2017-04-11 15:53:49 +0200
committerMarco Capitani <m.capitani@nextworks.it>2017-04-11 15:53:49 +0200
commit46310717c3293054324cc6a0271d855b638df0ff (patch)
tree69b27a68b2d97962f3bcbdee40d412453285eea2 /rumba/model.py
parent7f5054816fc68bca1d9d4901d1e365b57a278542 (diff)
downloadrumba-46310717c3293054324cc6a0271d855b638df0ff.tar.gz
rumba-46310717c3293054324cc6a0271d855b638df0ff.zip
Resolving node_id issue and general cleanup
Diffstat (limited to 'rumba/model.py')
-rw-r--r--rumba/model.py31
1 files changed, 21 insertions, 10 deletions
diff --git a/rumba/model.py b/rumba/model.py
index bab92bf..9f6d2c2 100644
--- a/rumba/model.py
+++ b/rumba/model.py
@@ -316,7 +316,7 @@ class Experiment:
:type testbed: Testbed
:param testbed: the testbed for the experiment
:param filename: name of the .conf file
- :return: the nodes list for the configuration file
+ :return: the Experiment
"""
shims = {}
@@ -337,7 +337,8 @@ class Experiment:
if line.startswith('#') or line == "":
continue
- m = re.match(r'\s*eth\s+([\w-]+)\s+(\d+)([GMK])bps\s+(\w.*)$', line)
+ m = re.match(r'\s*eth\s+([\w-]+)\s+(\d+)([GMK])bps\s+(\w.*)$',
+ line)
if m:
shim = m.group(1)
speed = int(m.group(2))
@@ -357,7 +358,10 @@ class Experiment:
shims[shim] = {'name': shim, 'speed': speed, 'type': 'eth'}
for vm in vm_list:
- nodes.setdefault(vm, {'name': vm, 'difs': [], 'dif_registrations': {}, 'registrations': {}})
+ nodes.setdefault(vm, {'name': vm,
+ 'difs': [],
+ 'dif_registrations': {},
+ 'registrations': {}})
nodes[vm]['difs'].append(shim)
continue
@@ -372,16 +376,21 @@ class Experiment:
% (line_cnt, dif))
continue
- difs.setdefault(dif, {'name': dif}) # Other dict contents might be policies.
+ difs.setdefault(dif, {'name': dif})
if vm in nodes and dif in nodes[vm]['dif_registrations']:
- print('Error: Line %d: vm %s in dif %s already specified'
- % (line_cnt, vm, dif))
+ print(
+ 'Error: Line %d: vm %s in dif %s already specified'
+ % (line_cnt, vm, dif))
continue
- nodes.setdefault(vm, {'name': vm, 'difs': [], 'dif_registrations': {}, 'registrations': {}})
+ nodes.setdefault(vm, {'name': vm,
+ 'difs': [],
+ 'dif_registrations': {},
+ 'registrations': {}})
nodes[vm]['difs'].append(dif)
- nodes[vm]['dif_registrations'][dif] = dif_list # It is not defined yet, per check above.
+ nodes[vm]['dif_registrations'][dif] = dif_list
+ # It is not defined yet, per check above.
continue
@@ -393,7 +402,8 @@ class Experiment:
parsed_difs = {}
for shim_name, shim in shims.items():
- parsed_difs[shim_name] = (ShimEthDIF(shim_name, link_speed=shim['speed']))
+ parsed_difs[shim_name] = (ShimEthDIF(shim_name,
+ link_speed=shim['speed']))
for dif_name, dif in difs.items():
parsed_difs[dif_name] = (NormalDIF(dif_name))
@@ -403,7 +413,8 @@ class Experiment:
name = node_data['name']
difs = [parsed_difs[x] for x in node_data['difs']]
dif_registrations = {parsed_difs[x]: [parsed_difs[y] for y in l]
- for x, l in node_data['dif_registrations'].items()}
+ for x, l
+ in node_data['dif_registrations'].items()}
parsed_nodes.append(Node(name, difs, dif_registrations))
return cls(testbed=testbed, nodes=parsed_nodes)