-
Notifications
You must be signed in to change notification settings - Fork 33
Open vSwitch Example
The test setup is adapted from the official Open vSwitch Configuration cookbook, specifically the VLAN configuration. The main difference is that the VMx machines do not necessarily have to be virtual machines running on the hosts, instead it is sufficient to have 6 machines that have equivalent network connections. The management network show on the diagram also extends to the VM machines, since LNST uses it for the controller <-> slave communication.
The goal of this test is to create two Open vSwitch bridges on the "Host" machines and configure them in such a way that they create two separate VLANs (VLAN1 and VLAN2). The test itself then checks that the VLANs are configured properly by sending pings from every "VM" machine to every other.
Save the following code into file recipe.xml on controller machine.
<lnstrecipe>
<network>
<host id="vm1">
<interfaces>
<eth id="if1" label="n1">
<addresses>
<address value="192.168.200.1/24"/>
</addresses>
</eth>
</interfaces>
</host>
<host id="vm2">
<interfaces>
<eth id="if2" label="n2">
<addresses>
<address value="192.168.200.2/24"/>
</addresses>
</eth>
</interfaces>
</host>
<host id="vm3">
<interfaces>
<eth id="if3" label="n3">
<addresses>
<address value="192.168.200.3/24"/>
</addresses>
</eth>
</interfaces>
</host>
<host id="vm4">
<interfaces>
<eth id="if4" label="n4">
<addresses>
<address value="192.168.200.4/24"/>
</addresses>
</eth>
</interfaces>
</host>
<host id="h1">
<params>
<param name="ovs_support" value="true"/>
</params>
<interfaces>
<eth id="if1" label="n1"/>
<eth id="if2" label="n2"/>
<eth id="if3" label="data_net"/>
<ovs_bridge id="ovs1">
<slaves>
<slave id="if1"/>
<slave id="if2"/>
<slave id="if3"/>
</slaves>
<vlan tag="1">
<slaves>
<slave id="if1"/>
</slaves>
</vlan>
<vlan tag="2">
<slaves>
<slave id="if2"/>
</slaves>
</vlan>
</ovs_bridge>
</interfaces>
</host>
<host id="h2">
<params>
<param name="ovs_support" value="true"/>
</params>
<interfaces>
<eth id="if1" label="n3"/>
<eth id="if2" label="n4"/>
<eth id="if3" label="data_net"/>
<ovs_bridge id="ovs2">
<slaves>
<slave id="if1"/>
<slave id="if2"/>
<slave id="if3"/>
</slaves>
<vlan tag="1">
<slaves>
<slave id="if1"/>
</slaves>
</vlan>
<vlan tag="2">
<slaves>
<slave id="if2"/>
</slaves>
</vlan>
</ovs_bridge>
</interfaces>
</host>
</network>
<task>
<run host="vm1" module="IcmpPing" timeout="30" expect="fail">
<options>
<option name="addr" value="{ip(vm2,if2)}"/>
<option name="count" value="40"/>
<option name="interval" value="0"/>
<option name="limit_rate" value="95"/>
</options>
</run>
<run host="vm1" module="IcmpPing" timeout="30" expect="pass">
<options>
<option name="addr" value="{ip(vm3,if3)}"/>
<option name="count" value="40"/>
<option name="interval" value="0"/>
<option name="limit_rate" value="95"/>
</options>
</run>
<run host="vm1" module="IcmpPing" timeout="30" expect="fail">
<options>
<option name="addr" value="{ip(vm4,if4)}"/>
<option name="count" value="40"/>
<option name="interval" value="0"/>
<option name="limit_rate" value="95"/>
</options>
</run>
<run host="vm2" module="IcmpPing" timeout="30" expect="fail">
<options>
<option name="addr" value="{ip(vm1,if1)}"/>
<option name="count" value="40"/>
<option name="interval" value="0"/>
<option name="limit_rate" value="95"/>
</options>
</run>
<run host="vm2" module="IcmpPing" timeout="30" expect="fail">
<options>
<option name="addr" value="{ip(vm3,if3)}"/>
<option name="count" value="40"/>
<option name="interval" value="0"/>
<option name="limit_rate" value="95"/>
</options>
</run>
<run host="vm2" module="IcmpPing" timeout="30" expect="pass">
<options>
<option name="addr" value="{ip(vm4,if4)}"/>
<option name="count" value="40"/>
<option name="interval" value="0"/>
<option name="limit_rate" value="95"/>
</options>
</run>
</task>
</lnstrecipe>
As was specified before and is evident from the recipe, this test requires 6 machines. My advice is to use virtual machines since LNST can automatically create the required network. The xml templates in this section will be based on the fact that you are using virtual machines with libvirt.
First, the test machines that will be configuring the Open vSwitch bridge need to have OvS installed and ready to be launched. Refer to the official OvS website for installation information. LNST will take care of loading the datapath kernel module and launching the database (the database must already be initialized) and openvswitch daemons.
If you're using a Fedora/RHEL distribution and want to initialize the database you can use this command:
$ ovsdb-tool create /etc/openvswitch/conf.db
After that you need to make sure that the lnst-slave daemon is running on the specified slave machines. To do this you run:
$ systemctl start lnst-slave.service
on all the slave machines. You can learn more about the LNST invocation in LNST Invocation.
After you've made sure that lnst is running on all the slave machines you just need to run the controller. For that you first need to create a pool with the test machines that you will be using.
-
create a new directory for the pool, e.g. ~/.lnst/pool/
-
create files describing the test machines, I used h1.xml and h2.xml for the "Host" machines that will be configuring the Open vSwitch bridge, and v1.xml - v4.xml for the "VM" machines.
-
use this xml as a template for the Host files, REPLACE the HOSTNAME and LIBVIRT_DOMAIN in both files with an approriate value.
<slavemachine>
<params>
<param name="hostname" value="HOSTNAME"/>
<param name="libvirt_domain" value="LIBVIRT_DOMAIN"/>
<param name="ovs_support" value="true"/>
</params>
</slavemachine>
- use this xml as a template for the VM files, REPLACE the HOSTNAME and LIBVIRT_DOMAIN in both files with an approriate value.
<slavemachine>
<params>
<param name="hostname" value="HOSTNAME"/>
<param name="libvirt_domain" value="LIBVIRT_DOMAIN"/>
</params>
</slavemachine>
And after you've created the pool just run the controller (on the controller machine) like this:
$ lnst-ctl run recipe.xml
- IcmpPing test description and options
- Function {ip()}
- Interface type OvS-Bridge