{"id":24191,"library":"ovs","title":"Open vSwitch Python library","description":"Official Python bindings for Open vSwitch (OVS), version 3.7.1. Provides APIs for interacting with OVS daemons via JSON-RPC, managing OpenFlow, and configuring virtual switches. Released quarterly, used primarily in SDN/NFV environments.","status":"active","version":"3.7.1","language":"python","source_language":"en","source_url":"https://github.com/openvswitch/ovs","tags":["openvswitch","sdn","networking","openflow","ovsdb","json-rpc"],"install":[{"cmd":"pip install ovs","lang":"bash","label":"default"},{"cmd":"pip install ovs==3.7.1","lang":"bash","label":"exact version"}],"dependencies":[],"imports":[{"note":"vlog is a top-level module for logging","symbol":"vlog","correct":"from ovs import vlog"},{"note":"JSON-RPC utilities","symbol":"jsonrpc","correct":"from ovs import jsonrpc"},{"note":"Database access (OVSDB)","symbol":"db","correct":"from ovs import db"},{"note":"High-level OVSDB client","symbol":"ovsdb","correct":"from ovs import ovsdb"},{"note":"Flow table utilities","symbol":"flow","correct":"from ovs import flow"},{"note":"Event loop","symbol":"poll_loop","correct":"from ovs import poll_loop"},{"note":"POSIX socket helpers","symbol":"posix","correct":"from ovs import posix"},{"note":"Polling utilities","symbol":"poller","correct":"from ovs import poller"},{"note":"Process management","symbol":"process","correct":"from ovs import process"},{"note":"sFlow remote configuration","symbol":"sFlow","correct":"from ovs import sFlow"},{"note":"Stream abstraction (TCP/SSL/Unix)","symbol":"stream","correct":"from ovs import stream"},{"note":"Time utilities","symbol":"timeval","correct":"from ovs import timeval"},{"note":"Unix control socket","symbol":"unixctl","correct":"from ovs import unixctl"},{"note":"Miscellaneous utilities","symbol":"util","correct":"from ovs import util"},{"note":"Version info","symbol":"version","correct":"from ovs import version"}],"quickstart":{"code":"from ovs import vlog\nfrom ovs import jsonrpc\nfrom ovs import stream\nimport ovs.unixctl\nimport sys\n\n# Example: connect to a remote OVSDB server via JSON-RPC\nif __name__ == '__main__':\n    # Initialize logging\n    vlog.init()\n\n    # Create a stream to OVSDB (passing connection string)\n    # For SSL: ssl:127.0.0.1:6632\n    # For TCP: tcp:127.0.0.1:6640\n    # For Unix: unix:/var/run/openvswitch/db.sock\n    remote = 'tcp:127.0.0.1:6640'\n    new_stream, error = stream.Stream.open_block(\n        stream.Stream.open(remote))\n    if error:\n        sys.stderr.write('Failed to connect: %s\\n' % error)\n        sys.exit(1)\n\n    rpc = jsonrpc.Connection(new_stream)\n    # Send a JSON-RPC echo request\n    request = jsonrpc.Message.create_request('echo', [])\n    rpc.send(request)\n    reply, error = rpc.recv_block()\n    if error:\n        sys.stderr.write('Error: %s\\n' % error)\n    else:\n        print('Reply: %s' % reply)\n    rpc.close()","lang":"python","description":"Minimal example connecting to OVSDB via JSON-RPC and sending an echo request."},"warnings":[{"fix":"For simpler OVS interactions, consider using ovsdb-client (command-line) or a third-party library like python-ovs.","message":"The ovs library is not a high-level Python SDK. It is a thin wrapper around OVS internal C libraries. Many functions require deep understanding of OVS internals. Do not expect a user-friendly API.","severity":"gotcha","affected_versions":"all"},{"fix":"Replace 'from ovs import appctl' with 'from ovs import unixctl'.","message":"The ovs.appctl and ovs.daemon modules are deprecated and may be removed in future versions. Use ovs.unixctl instead.","severity":"deprecated","affected_versions":">=3.0"},{"fix":"Upgrade to Python 3.6+ and use ovs>=3.0.","message":"Python 2 support removed in ovs 3.0. If you are on Python 2, you must use ovs 2.x.","severity":"breaking","affected_versions":">=3.0"},{"fix":"Use ovs event loop exclusively or offload OVS operations to a separate process.","message":"The ovs library uses a custom event loop (poll_loop). Mixing with other event loops (e.g., asyncio, gevent) requires careful integration. Do not assume thread safety.","severity":"gotcha","affected_versions":"all"},{"fix":"Use the OVS command-line tools for management operations like bridge renaming.","message":"All OVS library functions expecting a 'bridge' name or 'port' name assume the exact OVS internal naming. Renaming a bridge via the library after creation is not supported.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use 'from ovs import unixctl' instead.","cause":"The appctl module was deprecated and removed in ovs 3.0.","error":"AttributeError: module 'ovs' has no attribute 'appctl'"},{"fix":"Install OVS from source or use 'from ovs import db' for lower-level OVSDB access.","cause":"The ovsdb module is not always included in pip packages; it is part of the full OVS source distribution.","error":"ImportError: cannot import name 'ovsdb' from 'ovs' (unknown location)"},{"fix":"Start ovsdb-server: 'sudo service openvswitch-switch start'. Then check socket location with 'ovsdb-tool show-log'.","cause":"The OVS daemon (ovsdb-server) is not running or the socket path is wrong.","error":"OSError: [Errno 2] No such file or directory: '/var/run/openvswitch/db.sock'"},{"fix":"Check the connection parameters. Use 'tcp:127.0.0.1:6640' or 'unix:/var/run/openvswitch/db.sock'.","cause":"Stream.open_block() returned an error, and rpc is None.","error":"AttributeError: 'NoneType' object has no attribute 'recv_block'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}