aboutsummaryrefslogtreecommitdiff
path: root/examples/script-example.py
diff options
context:
space:
mode:
authorMarco Capitani <m.capitani@nextworks.it>2018-02-22 10:18:10 +0100
committerMarco Capitani <m.capitani@nextworks.it>2018-03-16 14:07:24 +0100
commite174aaf3650c23331c757921b1af9b152f53c6e5 (patch)
tree281a859419b20e34605e310c9572668d6f545734 /examples/script-example.py
parentade6bd4cda44c88b555f521641c6e01326ab0060 (diff)
downloadrumba-e174aaf3650c23331c757921b1af9b152f53c6e5.tar.gz
rumba-e174aaf3650c23331c757921b1af9b152f53c6e5.zip
storyboard: add replayability
implements #27
Diffstat (limited to 'examples/script-example.py')
-rwxr-xr-xexamples/script-example.py101
1 files changed, 101 insertions, 0 deletions
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()