diff options
author | Marco Capitani <[email protected]> | 2018-02-22 10:18:10 +0100 |
---|---|---|
committer | Marco Capitani <[email protected]> | 2018-03-16 14:07:24 +0100 |
commit | e174aaf3650c23331c757921b1af9b152f53c6e5 (patch) | |
tree | 281a859419b20e34605e310c9572668d6f545734 /examples | |
parent | ade6bd4cda44c88b555f521641c6e01326ab0060 (diff) | |
download | rumba-e174aaf3650c23331c757921b1af9b152f53c6e5.tar.gz rumba-e174aaf3650c23331c757921b1af9b152f53c6e5.zip |
storyboard: add replayability
implements #27
Diffstat (limited to 'examples')
-rw-r--r-- | examples/example-script.rsb | 40 | ||||
-rwxr-xr-x | examples/script-example.py | 101 | ||||
-rwxr-xr-x | examples/vpn.py | 3 |
3 files changed, 143 insertions, 1 deletions
diff --git a/examples/example-script.rsb b/examples/example-script.rsb new file mode 100644 index 0000000..8b5c714 --- /dev/null +++ b/examples/example-script.rsb @@ -0,0 +1,40 @@ +# This is a comment (no in-line comments) + +5.0 &ev1| $sb run_client_of 'server_a' +# 5.0 is the time trigger (after 5 seconds). Its a float +# $sb is the storyboard object +# run_client_of is the method to invoke + +10.3 &echo_cmd|$sb run_command 'node_a' 'echo "test"' +# methods can have multiple space-delimited arguments. +# single-quoted strings are used to enclose a single (string) argument +# which must be preceded and followed by a space. +# &echo_cmd is a label, it can be used to reference this +# event from other events + +10.5 &ev2|$sb run_client_of 'server_b' 12 'node_a' +# And optional arguments (same syntax as the method) +# also, whitespace tolerant around the | token + +# NOTE: in the absence of optional arguments, they will be randomly +# generated, so you might not get the exact same experiment every time + +13 &ev3| $Node.node_a execute_command 'echo "test"' +# $Node.<node_id> is a Node object. +# This command is actually equivalent to echo_cmd + +echo_cmd &echo2 | $sb run_command $Node.node_b 'echo "test2"' +# events can be triggered by the completion of other events + +echo2, 18 &ev4| $sb run_client_of $Server.server_b +# or both time AND other events +# Moreover, one can use entity syntax in arguments too + +1.2 &ev5| run_client_of $Server.server_c +# Events need _not_ be in temporal order +# if no object ($ handle) is provided, the storyboard +# is assumed as the object/ + + + + diff --git a/examples/script-example.py b/examples/script-example.py new file mode 100755 index 0000000..316a1d1 --- /dev/null +++ b/examples/script-example.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python + +# An example script leveraging the storyboard scripting functionality + +from rumba.storyboard import * +from rumba.model import * +import rumba.log as log +import rumba.testbeds.qemu as qemu +import rumba.prototypes.rlite as rl +from rumba.utils import ExperimentManager +import rumba.utils as utils + +log.set_logging_level(log.DEBUG) + + +n1 = NormalDIF("n1") + +n1.add_policy("rmt.pff", "lfa") +n1.add_policy("security-manager", "passwd") + +e1 = ShimEthDIF("e1") + +node_a = Node("node_a", + difs=[n1, e1], + dif_registrations={n1: [e1]}) + +node_b = Node("node_b", + difs=[e1, n1], + dif_registrations={n1: [e1]}) + +tb = qemu.Testbed(exp_name="script_test", + username="root", + password="root") + +exp = rl.Experiment(tb, nodes=[node_a, node_b]) + + +client_a = Client( + "rinaperf", + options="-t perf -s 1000 -D <duration>", + shutdown="", + c_id='rinaperf_a' +) + +client_b = Client( + "rinaperf", + options="-t perf -s 1000 -D <duration> -z rinaperfb", + shutdown="", + c_id='rinaperf_b' +) + +client_c = Client( + "rinaperf", + options="-t perf -s 1000 -D <duration> -z rinaperfc", + shutdown="", + c_id='rinaperf_c' +) + +server_a = Server( + "rinaperf", + options="-l", + arrival_rate=1, + mean_duration=5, + clients=[client_a], + s_id='server_a' +) + +server_b = Server( + "rinaperf", + options="-l -z rinaperfb", + arrival_rate=0.5, + mean_duration=10, + clients=[client_b], + s_id='server_b' +) + +server_c = Server( + "rinaperf", + options="-l -z rinaperfc", + arrival_rate=1.6, + mean_duration=3, + clients=[client_c], + s_id='server_c' +) + + +if __name__ == '__main__': + story = StoryBoard(30) + story.set_experiment(exp) + story.add_server_on_node(server_a, node_a) + story.add_server_on_node(server_b, node_a) + story.add_server_on_node(server_c, node_a) + client_a.add_node(node_b) + client_b.add_node(node_b) + client_c.add_node(node_b) + story.parse_script_file('example-script.rsb') + log.flush_log() + with ExperimentManager(exp): + exp.swap_in() + exp.bootstrap_prototype() + story.start() diff --git a/examples/vpn.py b/examples/vpn.py index b2f3c81..28de09e 100755 --- a/examples/vpn.py +++ b/examples/vpn.py @@ -44,7 +44,8 @@ d = Node("d", dif_registrations = {n1 : [e3], n2 : [n1]}) tb = qemu.Testbed(exp_name = 'example1', - username = 'sander') + username = 'root', + password = 'root') exp = our.Experiment(tb, nodes = [a, b, c, d]) |