From 94cebef59c46404e20c6d71752ebfb80147d122a Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Mon, 23 Apr 2018 16:55:35 +0200 Subject: examples: Make scalingtime.py more generic This makes scalingtime.py more generic by allowing the user to pass command-line arguments to select the prototype, testbed, ... Fixes #50 --- examples/scalingtime.py | 137 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 125 insertions(+), 12 deletions(-) (limited to 'examples') diff --git a/examples/scalingtime.py b/examples/scalingtime.py index cb1ba4f..bf4a739 100755 --- a/examples/scalingtime.py +++ b/examples/scalingtime.py @@ -7,6 +7,8 @@ from rumba.utils import * import rumba.testbeds.emulab as emulab import rumba.testbeds.jfed as jfed import rumba.testbeds.qemu as qemu +import rumba.testbeds.local as local +import rumba.testbeds.dockertb as docker # import prototype plugins import rumba.prototypes.ouroboros as our @@ -20,16 +22,81 @@ import sys description = "Script to create the demo from the Rumba paper" argparser = argparse.ArgumentParser(description = description) -argparser.add_argument('-m', '--metro', type = int, default = '2', + +# Parameters to set the experiment size +argparser.add_argument('--metro-networks', type = int, default = '2', help = "Number of metro networks") -argparser.add_argument('-n', '--metro-nodes', type = int, default = '5', +argparser.add_argument('--metro-nodes', type = int, default = '5', help = "Number of nodes per metro") -argparser.add_argument('-e', '--end-nodes', type = int, default = '2', +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, + default='INFO', + choices=['DEBUG', 'INFO', 'WARNING', + 'ERROR', 'CRITICAL'], + help='Logging verbosity level') +argparser.add_argument('--prototype', type=str, required=True, + choices=['irati', 'ouroboros', 'rlite'], + help='The kind of prototype plugin to use to run' + ' the experiment.') + +subparsers = argparser.add_subparsers(dest='testbed') +emulab_p = subparsers.add_parser('emulab', help='Use emulab testbed') +jfed_p = subparsers.add_parser('jfed', help='Use jfed testbed') +qemu_p = subparsers.add_parser('qemu', help='Use qemu testbed') +local_p = subparsers.add_parser('local', help='Use local testbed') +docker_p = subparsers.add_parser('docker', help='Use Docker testbed') + +qemu_p.add_argument('--bzimage', metavar='BZIMAGE', type=str, + help='path to the bzImage file to use') +qemu_p.add_argument('--initramfs', metavar='INITRAMFS', type=str, + help='path to the initramfs file to use') +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") + +emulab_p.add_argument('--url', metavar='URL', type=str, + default="wall2.ilabt.iminds.be", + help='Url') +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") + +jfed_p.add_argument('--cert-file', type = str, + required=True, + 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('--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") + +docker_p.add_argument('--base-image', metavar='DOCKIMAGE', type=str, + default=None, required=True, + help='Docker image to be used') +docker_p.add_argument('--use-ovs', action='store_true', + default=False, help='Use ovs switch') + args = argparser.parse_args() -log.set_logging_level('DEBUG') +log.set_logging_level(args.verbosity) pi = NormalDIF("pi") pi.dt_strategy = 'minimal' @@ -40,7 +107,7 @@ nodes = [] core_nodes = [] -for i in range(0, args.metro): +for i in range(0, args.metro_networks): m = NormalDIF("m-" + str(i)) e_prev = None m1 = None @@ -120,14 +187,60 @@ for i in range(0, args.metro): core_nodes.append(c1) core_nodes.append(c2) -tb = jfed.Testbed(exp_name = "metro2", - cert_file = '/home/sander/cert.pem', - authority = 'exogeni.net:umassvmsite', - username = 'sander') - -exp = our.Experiment(tb, nodes = nodes) +if args.testbed == 'emulab': + test_class = emulab.Testbed + testbed_args = {a.dest: getattr(args, a.dest) + for a in emulab_p._actions + if a.dest != 'help' + and getattr(args, a.dest) is not None} +elif args.testbed == 'jfed': + test_class = jfed.Testbed + testbed_args = {a.dest: getattr(args, a.dest) + for a in jfed_p._actions + if a.dest != 'help' + and getattr(args, a.dest) is not None} +elif args.testbed == 'qemu': + test_class = qemu.Testbed + testbed_args = {a.dest: getattr(args, a.dest) + for a in qemu_p._actions + if a.dest != 'help' + and getattr(args, a.dest) is not None} +elif args.testbed == 'local': + test_class = local.Testbed + testbed_args = {a.dest: getattr(args, a.dest) + for a in local_p._actions + if a.dest != 'help' + and getattr(args, a.dest) is not None} +elif args.testbed == 'docker': + test_class = docker.Testbed + testbed_args = {a.dest: getattr(args, a.dest) + for a in docker_p._actions + if a.dest != 'help' + and getattr(args, a.dest) is not None} +elif args.testbed is None: + print('Testbed type must be specified!') + print(argparser.format_help()) + exit(1) + +testbed = test_class(**testbed_args) + +if args.prototype == 'irati': + exp_class = irati.Experiment +elif args.prototype == 'ouroboros': + exp_class = our.Experiment +elif args.prototype == 'rlite': + exp_class = rl.Experiment +else: + print('Unexpected prototype!') + print(argparser.format_help()) + exit(1) + +exp = exp_class(testbed, nodes = nodes) with ExperimentManager(exp, swap_out_strategy=PAUSE_SWAPOUT): exp.swap_in() - exp.install_prototype() + if not isinstance(testbed, docker.Testbed) \ + and not isinstance(testbed, qemu.Testbed) \ + and not isinstance(testbed, local.Testbed): + exp.install_prototype() exp.bootstrap_prototype() -- cgit v1.2.3