For more info about recipes, see README file in recipes/examples/pyrecipes/
directory.
Signed-off-by: Jiri Prochazka <jprochaz(a)redhat.com>
---
recipes/examples/pyrecipes/2_hosts.py | 12 ++++++
recipes/examples/pyrecipes/README | 39 ++++++++++++++++++
recipes/examples/pyrecipes/bond_vs_team.py | 62 +++++++++++++++++++++++++++++
recipes/examples/pyrecipes/bond_vs_team.xml | 4 ++
recipes/examples/pyrecipes/ping_flood.py | 23 +++++++++++
recipes/examples/pyrecipes/ping_flood.xml | 4 ++
recipes/examples/pyrecipes/vlan.py | 60 ++++++++++++++++++++++++++++
recipes/examples/pyrecipes/vlan.xml | 15 +++++++
8 files changed, 219 insertions(+)
create mode 100644 recipes/examples/pyrecipes/2_hosts.py
create mode 100644 recipes/examples/pyrecipes/README
create mode 100644 recipes/examples/pyrecipes/bond_vs_team.py
create mode 100644 recipes/examples/pyrecipes/bond_vs_team.xml
create mode 100644 recipes/examples/pyrecipes/ping_flood.py
create mode 100644 recipes/examples/pyrecipes/ping_flood.xml
create mode 100644 recipes/examples/pyrecipes/vlan.py
create mode 100644 recipes/examples/pyrecipes/vlan.xml
diff --git a/recipes/examples/pyrecipes/2_hosts.py
b/recipes/examples/pyrecipes/2_hosts.py
new file mode 100644
index 0000000..3a0d053
--- /dev/null
+++ b/recipes/examples/pyrecipes/2_hosts.py
@@ -0,0 +1,12 @@
+from lnst.Controller.PyRecipe import LnstNetwork
+
+class Network(LnstNetwork):
+ def setup(self):
+ m1 = self.add_host(id="m1")
+ m2 = self.add_host(id="m2")
+
+ m1_eth1 = m1.add_interface(id="eth1", type="eth",
label="tnet")
+ m1_eth1.add_address("192.168.111.1/24")
+
+ m2_eth1 = m2.add_interface(id="eth1", type="eth",
label="tnet")
+ m2_eth1.add_address("192.168.111.1/24")
diff --git a/recipes/examples/pyrecipes/README b/recipes/examples/pyrecipes/README
new file mode 100644
index 0000000..77da20c
--- /dev/null
+++ b/recipes/examples/pyrecipes/README
@@ -0,0 +1,39 @@
+ping_flood.xml
+Network description:
+ Host "m1"
+ eth1
+
+ Host "m2"
+ eth1
+
+Test description:
+ IcmpPing from m1.eth1 to m2.eth1
+
+vlan.xml
+Network description:
+ Host "m1"
+ eth1
+ vlan10 on eth1
+ Host "m2"
+ eth1
+ vlan10 on eth1
+
+Test description:
+ IcmpPing from m1.vlan10 to m2.vlan10
+ Netperf (TCP_STREAM), client m1, server m2
+
+team_vs_bond.xml
+Network description:
+ Host "m1"
+ eth1
+ eth2
+ bond (active backup) with slaves eth1 and eth2
+
+ Host "m2"
+ eth1
+ eth2
+ team (active backup) with slaves eth1 and eth2
+
+Test description:
+ IcmpPing from m1.bond to m2.team
+ Netperf (TCP_STREAM), client m1, server m2
diff --git a/recipes/examples/pyrecipes/bond_vs_team.py
b/recipes/examples/pyrecipes/bond_vs_team.py
new file mode 100644
index 0000000..ee5e2e6
--- /dev/null
+++ b/recipes/examples/pyrecipes/bond_vs_team.py
@@ -0,0 +1,62 @@
+from lnst.Controller.PyRecipe import LnstTask, LnstNetwork
+
+class Network(LnstNetwork):
+ def setup(self):
+ m1 = self.add_host("m1")
+ m2 = self.add_host("m2")
+
+ m1_eth1 = m1.add_interface(id="eth1", type="eth",
label="tnet")
+ m1_eth2 = m1.add_interface(id="eth2", type="eth",
label="tnet")
+ m2_eth1 = m2.add_interface(id="eth1", type="eth",
label="tnet")
+ m2_eth2 = m2.add_interface(id="eth2", type="eth",
label="tnet")
+
+ m1_bond = m1.add_interface(id="bond", type="bond")
+ m2_team = m2.add_interface(id="team", type="team")
+
+ m1_bond.add_slaves([m1_eth1, m1_eth2])
+ m2_team.add_slaves([m2_eth1, m2_eth2])
+
+ m1_bond.add_option({'mode' : 'active-backup'})
+ m1_bond.add_option({'miimon' : '100'})
+ m2_team.add_option({'teamd_config' : '{"hwaddr" :
"00:11:22:33:44:55", "runner" : {"name" :
"activebackup"}}'})
+
+ m1_bond.add_address("192.168.111.1/24")
+ m2_team.add_address("192.168.111.2/24")
+
+class Task(LnstTask):
+ def task(self):
+ ctl = self.ctl
+
+ m1 = ctl.get_host("m1")
+ m2 = ctl.get_host("m2")
+
+ m1.sync_resources(modules=["IcmpPing", "Netperf"])
+ m2.sync_resources(modules=["IcmpPing", "Netperf"])
+
+ m1_bond = m1.get_interface("bond")
+ m2_team = m2.get_interface("team")
+
+ ping = ctl.get_module("IcmpPing",
+ options={
+ 'addr' : m2_team.get_ip(0),
+ 'count' : 100,
+ 'interval' : 0.1,
+ 'iface' : m1_bond.get_devname()})
+
+ nperf_cli = ctl.get_module("Netperf",
+ options={
+ 'role' : 'client',
+ 'netperf_server' : m2_team.get_ip(0),
+ 'duration' : '10',
+ 'testname' : 'TCP_STREAM'})
+ nperf_srv = ctl.get_module("Netperf",
+ options={
+ 'role' : 'server',
+ 'bind' : m2_team.get_ip(0)})
+ ctl.wait(2)
+ m1.run(ping)
+
+ srv_proc = m2.run(nperf_srv, bg=True)
+ ctl.wait(2)
+ m1.run(nperf_cli)
+ srv_proc.intr()
diff --git a/recipes/examples/pyrecipes/bond_vs_team.xml
b/recipes/examples/pyrecipes/bond_vs_team.xml
new file mode 100644
index 0000000..30fd513
--- /dev/null
+++ b/recipes/examples/pyrecipes/bond_vs_team.xml
@@ -0,0 +1,4 @@
+<lnstrecipe>
+ <network python="bond_vs_team.py" />
+ <task python="bond_vs_team.py" />
+</lnstrecipe>
diff --git a/recipes/examples/pyrecipes/ping_flood.py
b/recipes/examples/pyrecipes/ping_flood.py
new file mode 100644
index 0000000..d07fc96
--- /dev/null
+++ b/recipes/examples/pyrecipes/ping_flood.py
@@ -0,0 +1,23 @@
+from lnst.Controller.PyRecipe import LnstTask
+
+class Task(LnstTask):
+ def task(self):
+ ctl = self.ctl
+
+ m1 = ctl.get_host("m1")
+ m2 = ctl.get_host("m2")
+
+ m1.sync_resources(modules=["IcmpPing"])
+ m2.sync_resources(modules=["IcmpPing"])
+
+ m1_eth1 = m1.get_interface("eth1")
+ m2_eth1 = m2.get_interface("eth1")
+
+ ping_m = ctl.get_module("IcmpPing",
+ options={
+ "addr" : m2_eth1.get_ip(0),
+ "count" : 100,
+ "interval" : 0.2,
+ "iface" : m1_eth1.get_devname()})
+
+ m1.run(ping_m)
diff --git a/recipes/examples/pyrecipes/ping_flood.xml
b/recipes/examples/pyrecipes/ping_flood.xml
new file mode 100644
index 0000000..3a2fa07
--- /dev/null
+++ b/recipes/examples/pyrecipes/ping_flood.xml
@@ -0,0 +1,4 @@
+<lnstrecipe>
+ <network python="2_hosts.py" />
+ <task python="ping_flood.py" />
+</lnstrecipe>
diff --git a/recipes/examples/pyrecipes/vlan.py b/recipes/examples/pyrecipes/vlan.py
new file mode 100644
index 0000000..16faea9
--- /dev/null
+++ b/recipes/examples/pyrecipes/vlan.py
@@ -0,0 +1,60 @@
+from lnst.Controller.PyRecipe import LnstNetwork, LnstTask
+
+class Network(LnstNetwork):
+ def setup(self):
+ m1 = self.add_host("m1")
+ m2 = self.add_host("m2")
+
+ m1_eth1 = m1.add_interface(id="eth1", type="eth",
label="tnet")
+ m2_eth1 = m2.add_interface(id="eth1", type="eth",
label="tnet")
+
+ m1_vlan10 = m1.add_interface(id="vlan10", type="vlan")
+ m2_vlan10 = m2.add_interface(id="vlan10", type="vlan")
+
+ m1_vlan10.add_slave(m1_eth1)
+ m2_vlan10.add_slave(m2_eth1)
+
+ m1_vlan10.add_option({'vlan_tci' : '10'})
+ m2_vlan10.add_option({'vlan_tci' : '10'})
+
+ m1_vlan10.add_address("192.168.111.1/24")
+ m2_vlan10.add_address("192.168.111.2/24")
+
+class Task(LnstTask):
+ def task(self):
+ ctl = self.ctl
+
+ m1 = ctl.get_host("m1")
+ m2 = ctl.get_host("m1")
+
+ m1.sync_resources(modules=["IcmpPing", "Netperf"])
+ m2.sync_resources(modules=["IcmpPing", "Netperf"])
+
+ m1_vlan10 = m1.get_interface("vlan10")
+ m2_vlan10 = m2.get_interface("vlan10")
+
+ ping = ctl.get_module("IcmpPing",
+ options={
+ "addr" : m2_vlan10.get_ip(0),
+ "count" : 100,
+ "interval" : 0.2,
+ "iface" : m1_vlan10.get_devname()})
+
+ nperf_cli = ctl.get_module("Netperf",
+ options={
+ "role" : "client",
+ "netperf_server" :
m2_vlan10.get_ip(0),
+ "testname" : "TCP_STREAM",
+ "duration" : 10})
+
+ nperf_srv = ctl.get_module("Netperf",
+ options={
+ "role" : "server",
+ "bind" : m2_vlan10.get_ip(0)})
+
+ m1.run(ping)
+
+ srv_proc = m2.run(nperf_srv, bg=True)
+ ctl.wait(2)
+ m1.run(nperf_cli)
+ srv_proc.intr()
diff --git a/recipes/examples/pyrecipes/vlan.xml b/recipes/examples/pyrecipes/vlan.xml
new file mode 100644
index 0000000..e54e6f8
--- /dev/null
+++ b/recipes/examples/pyrecipes/vlan.xml
@@ -0,0 +1,15 @@
+<lnstrecipe>
+ <network python="vlan.py">
+ <host id="m1">
+ <interfaces>
+ <eth id="eth1" label="tnet" />
+ </interfaces>
+ </host>
+ <host id="m2">
+ <interfaces>
+ <eth id="eth1" label="tnet" />
+ </interfaces>
+ </host>
+ </network>
+ <task python="vlan.py" />
+</lnstrecipe>
--
2.4.3