diff options
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/scalingtime.py | 94 |
1 files changed, 48 insertions, 46 deletions
diff --git a/examples/scalingtime.py b/examples/scalingtime.py index bf4a739..ff3c2ed 100755 --- a/examples/scalingtime.py +++ b/examples/scalingtime.py @@ -16,20 +16,20 @@ import rumba.prototypes.rlite as rl import rumba.prototypes.irati as irati import argparse -import sys +from rumba.visualizer import draw_experiment description = "Script to create the demo from the Rumba paper" -argparser = argparse.ArgumentParser(description = description) +argparser = argparse.ArgumentParser(description=description) # Parameters to set the experiment size -argparser.add_argument('--metro-networks', type = int, default = '2', - help = "Number of metro networks") -argparser.add_argument('--metro-nodes', type = int, default = '5', - help = "Number of nodes per metro") -argparser.add_argument('--end-nodes', type = int, default = '2', - help = "Number of nodes connected to each metro") +argparser.add_argument('--metro-networks', type=int, default='2', + help="Number of metro networks") +argparser.add_argument('--metro-nodes', type=int, default='5', + help="Number of nodes per metro") +argparser.add_argument('--end-nodes', type=int, default='2', + help="Number of nodes connected to each metro") # Other parameters argparser.add_argument('--verbosity', metavar='VERBOSITY', type=str, @@ -57,8 +57,8 @@ qemu_p.add_argument('--use_vhost', action='store_true', default=False, help='Use vhost') qemu_p.add_argument('--qemu_logs_dir', metavar='QEMU_LOGS', type=str, default=None, help='path to the folder for qemu logs') -qemu_p.add_argument('--username', type = str, help = "Username") -qemu_p.add_argument('--password', type = str, help = "Password") +qemu_p.add_argument('--username', type=str, help="Username") +qemu_p.add_argument('--password', type=str, help="Password") emulab_p.add_argument('--url', metavar='URL', type=str, default="wall2.ilabt.iminds.be", @@ -66,27 +66,27 @@ emulab_p.add_argument('--url', metavar='URL', type=str, emulab_p.add_argument('--image', metavar='IMG', type=str, default="UBUNTU14-64-STD", help='Ubuntu image') -emulab_p.add_argument('--username', type = str, required=True, - help = "Username") -emulab_p.add_argument('--password', type = str, help = "Password") -emulab_p.add_argument('--exp-name', type = str, required=True, - help = "Name of the experiment") +emulab_p.add_argument('--username', type=str, required=True, + help="Username") +emulab_p.add_argument('--password', type=str, help="Password") +emulab_p.add_argument('--exp-name', type=str, required=True, + help="Name of the experiment") -jfed_p.add_argument('--cert-file', type = str, +jfed_p.add_argument('--cert-file', type=str, required=True, - help = "Absolute path to certificate (.pem) file" + help="Absolute path to certificate (.pem) file" " to be used with jFed") -jfed_p.add_argument('--authority', type = str, default = 'exogeni.net', - help = "jFed testbed to use") +jfed_p.add_argument('--authority', type=str, default='exogeni.net', + help="jFed testbed to use") jfed_p.add_argument('--image', metavar='IMAGE', type=str, default=None, help='Image to be used') jfed_p.add_argument('--exp-hours', metavar='HOURS', type=str, default="2", help='Experiment hours') -jfed_p.add_argument('--username', type = str, required=True, - help = "Username") -jfed_p.add_argument('--exp-name', type = str, required=True, - help = "Name of the experiment") +jfed_p.add_argument('--username', type=str, required=True, + help="Username") +jfed_p.add_argument('--exp-name', type=str, required=True, + help="Name of the experiment") docker_p.add_argument('--base-image', metavar='DOCKIMAGE', type=str, default=None, required=True, @@ -117,19 +117,19 @@ for i in range(0, args.metro_networks): e = ShimEthDIF("e-" + str(i) + "-" + str(j)) else: e = None - if e_prev == None and e != None: + if e_prev is None and e is not None: node = Node("metro-" + str(i) + "-" + str(j), - difs = [m, pi, e], - dif_registrations = {pi : [m], m : [e]}) + difs=[m, pi, e], + dif_registrations={pi: [m], m: [e]}) m1 = node - elif e_prev != None and e != None: + elif e_prev is not None and e is not None: node = Node("metro-" + str(i) + "-" + str(j), - difs = [m, pi, e, e_prev], - dif_registrations = {pi : [m], m : [e, e_prev]}) + difs=[m, pi, e, e_prev], + dif_registrations={pi: [m], m: [e, e_prev]}) else: node = Node("metro-" + str(i) + "-" + str(j), - difs = [m, pi, e_prev], - dif_registrations = {pi : [m], m : [e_prev]}) + difs=[m, pi, e_prev], + dif_registrations={pi: [m], m: [e_prev]}) mn = node nodes.append(node) e_prev = e @@ -137,8 +137,8 @@ for i in range(0, args.metro_networks): for k in range(0, args.end_nodes): ee = ShimEthDIF("e-" + str(i) + "-" + str(j) + "-" + str(k)) end_node = Node("end-" + str(i) + "-" + str(j) + "-" + str(k), - difs = [pi, ee], - dif_registrations = {pi : [ee]}) + difs=[pi, ee], + dif_registrations={pi: [ee]}) node.add_dif(ee) node.add_dif_registration(pi, ee) nodes.append(end_node) @@ -155,12 +155,12 @@ for i in range(0, args.metro_networks): e2 = ShimEthDIF("c-e-" + str(i) + "-2") c1 = Node("c-" + str(i) + "-0", - difs = [c, m, pi, e0, e2], - dif_registrations = {pi : [m, c], m : [e0], c : [e2]}) + difs=[c, m, pi, e0, e2], + dif_registrations={pi: [m, c], m: [e0], c: [e2]}) c2 = Node("c-" + str(i) + "-1", - difs = [c, m, pi, e1, e2], - dif_registrations = {pi : [m, c], m : [e1], c : [e2]}) + difs=[c, m, pi, e1, e2], + dif_registrations={pi: [m, c], m: [e1], c: [e2]}) nodes.append(c1) nodes.append(c2) @@ -235,12 +235,14 @@ else: print(argparser.format_help()) exit(1) -exp = exp_class(testbed, nodes = nodes) - -with ExperimentManager(exp, swap_out_strategy=PAUSE_SWAPOUT): - exp.swap_in() - if not isinstance(testbed, docker.Testbed) \ - and not isinstance(testbed, qemu.Testbed) \ - and not isinstance(testbed, local.Testbed): - exp.install_prototype() - exp.bootstrap_prototype() +exp = exp_class(testbed, nodes=nodes) + +if __name__ == "__main__": + draw_experiment(exp) + with ExperimentManager(exp, swap_out_strategy=PROMPT_SWAPOUT): + exp.swap_in() + if not isinstance(testbed, docker.Testbed) \ + and not isinstance(testbed, qemu.Testbed) \ + and not isinstance(testbed, local.Testbed): + exp.install_prototype() + exp.bootstrap_prototype() |