Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/usr/bin/env python
import shlex
import subprocess
import sys
def main():
# NOTE(andyhky): Refer to http://openvswitch.org/ovs-vswitchd.conf.db.5.pdf
# for definitions of controller vs. manager.
manager = "ovs-vsctl find manager is_connected=false"
controller = "ovs-vsctl find controller is_connected=false"
mgr_stdout = subprocess.Popen(shlex.split(manager),
stdout=subprocess.PIPE).stdout
ctrl_stdout = subprocess.Popen(shlex.split(controller),
stdout=subprocess.PIPE).stdout
# NOTE(ahill): These commands should only return 0 with no output.
if len(mgr_stdout.readlines()) != 0 or len(ctrl_stdout.readlines()) != 0:
return 1
else:
return 0
if __name__ == "__main__":
sys.exit(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment