I don’t mind coding in Java (i.e. OpenDaylight) but I wanted something quick and easy, so I’m writing a utility-esque script that sacrifices extensibility for speed. And since Python is something I’ve been meaning to stretch my muscles in, I decided to throw this together.

Keep in mind that this can all be done by ovsdb-client natively via Linux command line, but I wanted to write it in Python to learn it, as well as provide it for a cool (technically) cross-platform language.

Simple idea, send an OVS echo function through JSON-RPC to the address and port of your choice. Assumes you’ve already set up OVS to listen passively on an interface for manager OVSDB requests:

ovs-vsctl set-manager ptcp:6634:

Suggestions welcome.

import socket
import json
import time
def pingOVS(HOST, PORT):
    #Create socket
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    #Establish TCP session via IP address and port specified
    s.connect((HOST, PORT))
    #Send JSON to socket
    print "Sending echo request =====>"
    #Wait for response and print to console
    result = json.loads(s.recv(1024))
    print "<========" + str(result)
while True:
    pingOVS("", 6634)


Matt Oswalt

Matt Oswalt is an all-around technology nerd, currently focusing on networking, software development, and everything in between. He is at his happiest in front of a keyboard, next to a brewing kettle, or wielding his silo-smashing sledgehammer. He spends his days diving deep into the intersection of networking and software, and likes to blog about his experiences when he comes up for air. You can follow him on Twitter or LinkedIN.