A Declarative API for Host Network Management

View on GitHub

Nmstate Plugin Interface

The nmstate-0.3.2 release brings the plugin support which allows user to managing the network via their own plugin.

How to Install and Load the Plugin

If NMSTATE_PLUGIN_DIR is defined as system environment variable in the runtime of nmstate, nmstate will load plugin form that folder after build-in plugins been loaded.

If NMSTATE_PLUGIN_DIR is not define, nmstate will use the ‘plugins’ folder where libnmstate python module is installed. For example: /usr/lib/python3.6/site-packages/libnmstate/plugins/

The plugin file should be named with prefix nmstate_plugin_ and end with .py. For example, the OVS DB plugin ins nmstate_plugin_ovsdb.py

If any non-build-in plugin failed to loaded, there will not no Exception raised, but a warning message.

Plugin example:

You may take the OVS DB plugin as example or below:

from libnmstate.plugin import NmstatePlugin
from libnmstate.schema import Interface
from libnmstate.schema import InterfaceType
from libnmstate.schema import InterfaceState

class FooPlugin(NmstatePlugin):
    def name(self):
        return "foo_plugin"

    def priority(self):
        return NmstatePlugin.DEFAULT_PRIORITY + 1

    def plugin_capabilities(self):
        return [

    def get_interfaces(self):
        return [
                Interface.NAME: "foo1",
                Interface.TYPE: InterfaceType.OTHER,
                Interface.STATE: InterfaceState.UP,
                "foo": {"a": 1, "b": 2},


Plugin Priority

The bigger number of NmstatePlugin.priority property is, the higher priority the plugin will be.

Plugin Capabilities

The NmstatePlugin.plugin_capabilities() function returns a list of constants indicating the ability of this plugin: