diff options
author | Marco Capitani <m.capitani@nextworks.it> | 2017-04-12 15:21:21 +0200 |
---|---|---|
committer | Marco Capitani <m.capitani@nextworks.it> | 2017-04-12 15:21:21 +0200 |
commit | 22db738a842f8e21bb49f6431bd671d37073f832 (patch) | |
tree | b7603c93d1f5b5b4e2487d89463f5a5d526be2e2 /rumba/model.py | |
parent | 2b155aa25a2f61ad9bb84c273781a0597c6cef76 (diff) | |
download | rumba-22db738a842f8e21bb49f6431bd671d37073f832.tar.gz rumba-22db738a842f8e21bb49f6431bd671d37073f832.zip |
Rumba tester v2: all-in-one testing tool
Deep reworking of the testing tool, it can be provided with a (demo-like)
.conf file, a testbed and a prototype, and it auto-runs the experiment.
Removed generated testing scripts.
Diffstat (limited to 'rumba/model.py')
-rw-r--r-- | rumba/model.py | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/rumba/model.py b/rumba/model.py index 5ec36cc..c2c4cfa 100644 --- a/rumba/model.py +++ b/rumba/model.py @@ -317,105 +317,6 @@ class Experiment: # Generate missing information self.generate() - @staticmethod - def from_config_file(testbed, filename='demo.conf'): - """ - :type testbed: Testbed - :rtype: Experiment - :param testbed: the testbed for the experiment - :param filename: name of the .conf file - :return: an Experiment object - """ - - shims = {} - nodes = {} - difs = {} - with open(filename, 'r') as conf: - - line_cnt = 0 - - while 1: - line = conf.readline() - if line == '': - break - line_cnt += 1 - - line = line.replace('\n', '').strip() - - if line.startswith('#') or line == "": - continue - - 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)) - speed_unit = m.group(3).lower() - vm_list = m.group(4).split() - - if shim in shims or shim in difs: - print('Error: Line %d: shim %s already defined' - % (line_cnt, shim)) - continue - - if speed_unit == 'K': - speed = speed // 1000 - if speed_unit == 'G': - speed = speed * 1000 - - shims[shim] = {'name': shim, 'speed': speed, 'type': 'eth'} - - for vm in vm_list: - nodes.setdefault(vm, {'name': vm, 'difs': [], 'dif_registrations': {}, 'registrations': {}}) - nodes[vm]['difs'].append(shim) - continue - - m = re.match(r'\s*dif\s+([\w-]+)\s+([\w-]+)\s+(\w.*)$', line) - if m: - dif = m.group(1) - vm = m.group(2) - dif_list = m.group(3).split() - - if dif in shims: - print('Error: Line %d: dif %s already defined as shim' - % (line_cnt, dif)) - continue - - difs.setdefault(dif, {'name': dif}) # Other dict contents might be policies. - - 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)) - continue - - 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. - - continue - - # No match, spit a warning - print('Warning: Line %d unrecognized and ignored' % line_cnt) - - # File parsed - - parsed_difs = {} - - for shim_name, shim in shims.items(): - 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)) - - parsed_nodes = [] - for node, node_data in nodes.items(): - 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()} - parsed_nodes.append(Node(name, difs, dif_registrations)) - - return Experiment(testbed=testbed, nodes=parsed_nodes) - def __repr__(self): s = "" for n in self.nodes: |