Skip to main content

Declarative network manager API

Project description

We are Nmstate!

A declarative network manager API for hosts.

Unit Test Status Coverage Status PyPI version Fedora Rawhide version

Copr build status:

  • EPEL 7 GIT master: EPEL7 GIT master Copr build status
  • Fedora GIT master: Fedora GIT master Copr build status

What is it?

Nmstate is a library with an accompanying command line tool that manages host networking settings in a declarative manner. The networking state is described by a pre-defined schema. Reporting of current state and changes to it (desired state) both conform to the schema.

Nmstate is aimed to satisfy enterprise needs to manage host networking through a northbound declarative API and multi provider support on the southbound. NetworkManager acts as the main (and currently the only) provider supported.

Contact

Nmstate uses the NetworkManager mailing list (Archives) for discussions. Emails about nmstate should be tagged with [nmstate] in the subject header to ease filtering.

Development planning (sprints and progress reporting) happens in (Jira). Access requires login.

There is also #nmstate on Freenode IRC.

Development Environment

Nmstate uses tox to run unit tests and linters. Since Nmstate uses the binary module PyGObject it also requires the build dependencies for it.

RHEL 7.6

Recommended minimum installation:

yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm  # install EPEL for python-pip
subscription-manager repos --enable "rhel-*-optional-rpms" --enable "rhel-*-extras-rpms"  # recommended for EPEL
yum install git python-pip
pip install tox  # python-tox in EPEL seems to be too old
yum-builddep python-gobject  # install build dependencies for PyGObject

Note: This will not run the unit tests for Python 3.6 because this Python version is not available there.

Unit tests

Run Unit Tests:

tox

Runtime Environment

Install (from sources) system-wide:

sudo pip install --upgrade .

Install just for the local user:

pip install --user --upgrade .

Make sure that ~/.local/bin is in your PATH when installing as a local user. The export command can be used to add it for the current session:

export PATH="${HOME}/.local/bin:${PATH}"

Container Image

Nmstate also provides a container image based on CentOS 7 to try it:

CONTAINER_ID=$(sudo docker run --privileged -d -v /sys/fs/cgroup:/sys/fs/cgroup:ro nmstate/centos7-nmstate)
sudo docker exec -ti "${CONTAINER_ID}" /bin/bash
# now play with nmstatectl in the container
nmstatectl show
# remove the container at the end
sudo docker stop "${CONTAINER_ID}"
sudo docker rm "${CONTAINER_ID}"

Basic Operations

Show current state:

nmstatectl show

Change to desired state:

nmstatectl set desired-state.yml
nmstatectl set desired-state.json

Edit current state of eth3 in a text editor:

nmstatectl edit eth3

nmstatectl will also read from stdin when no file is specified:

nmstatectl set < desired-state.yml

Desired/Current state example (JSON):

{
    "interfaces": [
        {
            "description": "Production Network",
            "ethernet": {
                "auto-negotiation": true,
                "duplex": "full",
                "speed": 1000
            },
            "ipv4": {
                "address": [
                    {
                        "ip": "192.0.2.142",
                        "prefix-length": 24
                    }
                ],
                "enabled": true
            },
            "mtu": 1500,
            "name": "eth3",
            "state": "up",
            "type": "ethernet"
        }
    ]
}

See nmstatectl --help for additional command-line options.

Supported Interfaces:

  • bond
  • dummy
  • ethernet
  • ovs-bridge

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nmstate-0.0.5.tar.gz (38.4 kB view hashes)

Uploaded Source

Built Distribution

nmstate-0.0.5-py2-none-any.whl (55.5 kB view hashes)

Uploaded Python 2

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page