A simple Python script to help you when generating Open vSwitch network configuration scripts

I’ve written a simple script in Python that will help you to generate network configuration scripts integrating Open vSwitch for RHEL-based Linux distributions like CentOS. Note that the Open vSwitch integration is optional but is quite useful. It helps me to remember the options  I need and I hope it’s useful to you too.

The script is hosted at my Github account.

The README.RHEL included with Open vSwitch explains how to use the optional Open vSwitch integration with RHEL network configuration scripts identifying all the attributes and values you can add to the scripts. The script comes with a wizard that creates the content for a network script that should be placed in the /etc/sysconfig/network-scripts directory. A file like the following will be generated:

DEVICE=intbr0
ONBOOT=yes
DEVICETYPE=ovs
TYPE=OVSIntPort
OVS_BRIDGE=ovsbridge0
OVSBOOTPROTO="dhcp"
OVSDHCPINTERFACES="eth0"
HOTPLUG=no

Let me know about any errors, thoughts and suggestions.

Enjoy!

Online course poll

Hi,
I’m preparing material for new courses that will be published in the Eliademy platform and I’d like to know which one you are most interested in so I can focus my effort to something the community really demands.

The courses will be free but I’ll use premium applications to prepare the video materials.

I’d like to know your opinion so please use this poll.  Note that 101 courses are introductory courses 🙂

Thanks for your feedback.

CentOS 7 – Installing Openvswitch 2.3.1 LTS

Openvswitch 2.3.1 was released on December 2014 and this post explains how to quickly generate an RPM to install Openvswitch command-line tools. I’ll be using the Openvswitch’s kernel module that comes with CentOS kernel so no kernel module is compiled.

As the root user let’s install some packages and add a new user:

yum -y install wget openssl-devel gcc make python-devel openssl-devel kernel-devel graphviz kernel-debug-devel autoconf automake rpm-build redhat-rpm-config libtool

adduser ovs

su - ovs

Now as the ovs user we’ll generate the rpm file. In this post I’m skipping the rpmbuild tests included with openvswitch as I’m solving some dependency problems.

mkdir -p ~/rpmbuild/SOURCES

wget http://openvswitch.org/releases/openvswitch-2.3.1.tar.gz

cp openvswitch-2.3.1.tar.gz ~/rpmbuild/SOURCES/

tar xfz openvswitch-2.3.1.tar.gz

sed 's/openvswitch-kmod, //g' openvswitch-2.3.1/rhel/openvswitch.spec > openvswitch-2.3.1/rhel/openvswitch_no_kmod.spec

rpmbuild -bb --nocheck ~/openvswitch-2.3.1/rhel/openvswitch_no_kmod.spec

exit

Finally we install the rpm package:

 yum localinstall /home/ovs/rpmbuild/RPMS/x86_64/openvswitch-2.3.1-1.x86_64.rpm

Let’s check that the command-line tools are ready:

ovs-vsctl -V
ovs-vsctl (Open vSwitch) 2.3.1
Compiled Jan 25 2015 02:13:00
DB Schema 7.6.2

UPDATE: If you’re using SELinux in enfocing mode, if you try to start the service (systemctl start openvswitch.service) you’ll find some errors: install: cannot change owner and permissions of ‘/etc/openvswitch’: No such file or directory andCreating empty database /etc/openvswitch/conf.db ovsdb-tool: I/O error: /etc/openvswitch/conf.db: failed to lock lockfile (No such file or directory). This is how I solved them (the commands are executed as root):

yum install policycoreutils-python
mkdir /etc/openvswitch
semanage fcontext -a -t openvswitch_rw_t "/etc/openvswitch(/.*)?"
restorecon -Rv /etc/openvswitch

UPDATE: If you run the ovs-vsctl show command and you receive the following error, please check that your openvswitch service has been started (use systemctl start openvswitch.service)

  • ovs-vsctl: unix:/var/run/openvswitch/db.sock: database connection failed (No such file or directory)

Done!