Created
June 3, 2015 16:53
-
-
Save jbarber/6880290be6847e399922 to your computer and use it in GitHub Desktop.
Get information from openvswitch ovsdb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import ovs.db.idl | |
import ovs.poller | |
ovs.vlog.Vlog.set_levels_from_string("console:dbg") | |
ovs.vlog.Vlog.init() | |
remote = 'unix:/var/run/openvswitch/db.sock' | |
# If not present, will read from default path | |
#schema_file = '/usr/share/openvswitch/vswitch.ovsschema' | |
schema_helper = ovs.db.idl.SchemaHelper(schema_file) | |
# Either only get selected information: | |
#schema_helper.register_columns("Bridge", ["name", "ports"]) | |
#schema_helper.register_columns("Port", ["name", "mac"]) | |
# Or all of it: | |
schema_helper.register_all() | |
idl = ovs.db.idl.Idl(remote, schema_helper) | |
p = ovs.poller.Poller() | |
while True: | |
# You must call wait(poller) before you call p.block(), otherwise you | |
# will block forever or not get any information back | |
idl.run() | |
idl.wait(p) | |
p.block() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment