From: Ondrej Lichtner olichtne@redhat.com
This is an example python recipe that can be run as an executable script. Performs a simple ping between two hosts.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com --- recipes/examples/python_recipe.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 recipes/examples/python_recipe.py
diff --git a/recipes/examples/python_recipe.py b/recipes/examples/python_recipe.py new file mode 100755 index 0000000..b15bc60 --- /dev/null +++ b/recipes/examples/python_recipe.py @@ -0,0 +1,31 @@ +#!/bin/python2 +""" +This is an example python recipe that can be run as an executable script. +Performs a simple ping between two hosts. +""" + +from lnst.Common.Parameters import IpParam +from lnst.Common.IpAddress import IpAddress +from lnst.Controller import Controller +from lnst.Controller import BaseRecipe +from lnst.Controller import HostReq, DeviceReq + +from lnst.Tests import IcmpPing + +class MyRecipe(BaseRecipe): + m1 = HostReq() + m1.eth0 = DeviceReq(label="net1") + + m2 = HostReq() + m2.eth0 = DeviceReq(label="net1") + + def test(self): + self.matched.m1.eth0.ip_add(IpAddress("192.168.1.1/24")) + self.matched.m2.eth0.ip_add(IpAddress("192.168.1.2/24")) + ping_job = self.matched.m1.run(IcmpPing(dst=self.matched.m2.eth0, + interval=0)) + +ctl = Controller(debug=1) + +r = MyRecipe() +ctl.run(r, allow_virt=True)