Skip to main content

A library for parsing the netplan configuration data

Project description

netplan - a Python library for parsing the netplan configuration data.

Description

This module parses the YAML configuration files describing the system's network configuration in the format used by the netplan.io package. The main parser is the "netplan.parser.Parser" class (also exported as "netplan.Parser"); its "parse()" method returns a data structure of the "netplan.config.NetPlan" class (also exported as "netplan.NetPlan").

Example usage

import netplan

p = netplan.Parser()
data = p.parse()
for iface, cfg in data.items():
    print('{section}/{name}'.format(section=cfg.section, name=iface)

p = netplan.Parser()
data = p.parse(exclude=['set-mtu.yaml'])
fix = {'version': 2}
for iface, cfg in data.get_all_interfaces(['br-enp4s0']).data.items():
    if cfg.get('mtu') != 9000:
        if cfg.section not in fix:
            fix[cfg.section] = {}
        fix[cfg.section][iface] = {'mtu': 9000}
fix = {'network': fix}
with open('/etc/netplan/set-mtu.yaml', mode='w') as f:
    print(yaml.dump(fix), file=f, end='')

The netplan-parser tool

The three types of queries - parse the interface data, get all related interfaces, and get only the physical related interfaces - are also available via the command-line netplan-parser tool:

# Show the configuration of all interfaces in YAML format
netplan-parser show

# Show the configuration of the specified interfaces in JSON format
netplan-parser -f json show eno1 eno2.617

# List the names of the interfaces related to the specified one
netplan-parser -f names related eno2.617

# Show the configuration of the physical interfaces related to
# the specified ones
netplan-parser --format=json physical eno2.617 br1-eno1

Contact

The netplan Python library was written by Peter Pentchev as part of the OpenStack development team at StorPool.

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

netplan-0.3.3.tar.gz (12.8 kB view details)

Uploaded Source

Built Distributions

netplan-0.3.3-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

netplan-0.3.3-py2-none-any.whl (11.0 kB view details)

Uploaded Python 2

File details

Details for the file netplan-0.3.3.tar.gz.

File metadata

  • Download URL: netplan-0.3.3.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.4

File hashes

Hashes for netplan-0.3.3.tar.gz
Algorithm Hash digest
SHA256 a7ba8377d9fde05cb1a446f0082c0f4011ca74537e1647e4e9c227b893c031b1
MD5 e903c62bdcdc89a56bab324c2b0d87d3
BLAKE2b-256 3646284e325e534b615f591fcf2b61381f67c82fce01de110be3f3fdb8db08a7

See more details on using hashes here.

File details

Details for the file netplan-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: netplan-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.4

File hashes

Hashes for netplan-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4a0c08243ef26a3816bd3aecacebd4b57865f8e80e727c9198b1b7b66e65c4ce
MD5 9c9c8085bd3d0376eca8234a80dbd718
BLAKE2b-256 a2613d64b6422f5c44f00aba0ade39cb4b96707bcdcab740b9c7e2a9bb777298

See more details on using hashes here.

File details

Details for the file netplan-0.3.3-py2-none-any.whl.

File metadata

  • Download URL: netplan-0.3.3-py2-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.4

File hashes

Hashes for netplan-0.3.3-py2-none-any.whl
Algorithm Hash digest
SHA256 46d3c9c28d5044dd51035555db0fc7dcec1a373d86bc6b358e57aec8a58a6847
MD5 58a1ea34b22a0ae98664588688900205
BLAKE2b-256 078f4c83bcdc63bb04ec0931afd8fbeff07d893c5dcadd6b86e83f7c717c90d7

See more details on using hashes here.

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