3

How to configure Open vSwitch (OVS) by python ?

Usually, I use shell commands to configure an Open vSwitch without OpenFlow controller. For example,

ovs-vsctl --may-exist add-br br0
ovs-vsctl --may-exist add-br br1
ovs-vsctl set bridge br1 protocols=OpenFlow13
ovs-vsctl --may-exist add-port br0 patch-tun -- set interface patch-tun type=patch options:peer=patch-int
ovs-vsctl set port patch-tun vlan_mode=trunk
ovs-vsctl --may-exist add-port br1 patch-int -- set interface patch-int type=patch options:peer=patch-tun
ovs-vsctl set port patch-int vlan_mode=trunk
ovs-ofctl --protocols=OpenFlow13 add-flow br1 "table=0,priority=1,in_port=1,dl_dst=00:00:00:00:00:00/01:00:00:00:00:00 actions=resubmit(,20)"
ovs-ofctl --protocols=OpenFlow13 add-flow br1 "table=0,priority=1,in_port=1,dl_dst=01:00:00:00:00:00/01:00:00:00:00:00 actions=resubmit(,21)"
.....

But I feel a pain in such shell script in case that I have to do add-port, del-port, add-flow or del-flow dynamically according to the situation. (Though OpenFlow controller may be able to do it, I don't want to keep any controller running since my OVS works only for bridging and vxlan tunneling.)

OVS seems to have its own python library (https://github.com/openvswitch/ovs/tree/master/python), but I can not find the how-to doc. Or, is there any other python library which can configure OVS ?

takaomag
  • 1,545
  • 1
  • 16
  • 26
  • mininet though its a bit more than just a python library http://mininet.org/ https://github.com/mininet/mininet/wiki/FAQ#python-api http://mininet.org/sample-workflow/ – lxx Dec 23 '14 at 01:18
  • Did you find any example yet? I am looking for the same thing. – Khayam Gondal Mar 12 '17 at 00:52

1 Answers1

-1

I believe this is an application for OVS - for make some tests, if you run ovs-test will call this implementation python/ovstest/X.py. But this work if you install: python setup.py install.

  • Can you please articulate your question more clearly? Consider reading [how to ask a good question](https://stackoverflow.com/help/how-to-ask). – Sam Chats Jul 13 '17 at 20:48