diff options
author | Nick Aerts <nick.aerts@ugent.be> | 2018-02-24 12:27:36 +0100 |
---|---|---|
committer | Nick Aerts <nick.aerts@ugent.be> | 2018-03-20 11:30:07 +0100 |
commit | a7cd88d752b72ea85ccefa5e1f3dceba13fb1fc2 (patch) | |
tree | 9c29f08693d577c81959c3194aec04e9bc1ba195 /examples/docker-ouroboros.py | |
parent | 24bed306b5a67fc682b04cae017b0d0f3ac55a00 (diff) | |
download | rumba-a7cd88d752b72ea85ccefa5e1f3dceba13fb1fc2.tar.gz rumba-a7cd88d752b72ea85ccefa5e1f3dceba13fb1fc2.zip |
testbeds: Add docker testbed
This adds support for a testbed based on Docker containers running on
the local host. Bridging the containers can be done using built-in
Linux bridging or using OpenVSwitch bridges.
A new resource 'executor' has been added to abstract away command
execution on nodes on the testbed. Executors have been created for
local command execution, docker exec based command execution and
SSH-based command execution. This has also been changed in the
prototypes to execute using the correct executor.
Diffstat (limited to 'examples/docker-ouroboros.py')
-rwxr-xr-x | examples/docker-ouroboros.py | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/examples/docker-ouroboros.py b/examples/docker-ouroboros.py new file mode 100755 index 0000000..1c6009c --- /dev/null +++ b/examples/docker-ouroboros.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python + +# An example script using the rumba package + +from rumba.model import * +from rumba.utils import ExperimentManager + +# import testbed plugins +import rumba.testbeds.dockertb as docker + +# import prototype plugins +import rumba.prototypes.ouroboros as our + +import argparse +import sys + + +description = "Script to create an ouroboros" + +argparser = argparse.ArgumentParser(description = description) +argparser.add_argument('-n', '--nodes', type = int, default = '10', + help = "Total number of nodes") + +args = argparser.parse_args() + +log.set_logging_level('DEBUG') + +n01 = NormalDIF("n01") + +if (args.nodes < 3): + print("The ouroboros must be longer than 2 nodes") + sys.exit(-1) + +nodes = [] + +shim_prev = None +for i in range(0, args.nodes): + shim = ShimEthDIF("e" + str(i)) + + if shim_prev == None and shim != None: + node = Node("node" + str(i), difs = [n01, shim], + dif_registrations = {n01 : [shim]}) + elif shim_prev != None and shim != None: + node = Node("node" + str(i), difs = [n01, shim, shim_prev], + dif_registrations = {n01 : [shim, shim_prev]}) + else: + node = Node("node" + str(i), difs = [n01, shim_prev], + dif_registrations = {n01 : [shim_prev]}) + + shim_prev = shim + nodes.append(node) + +nodes[0].add_dif(shim_prev) +nodes[0].add_dif_registration(n01, shim_prev) + +tb = docker.Testbed(exp_name = "ouroboros", + base_image = "ouroborosrumba/prototype") + +exp = our.Experiment(tb, nodes = nodes) + +print(exp) + +with ExperimentManager(exp): + exp.swap_in() + exp.bootstrap_prototype() |