Skip to main content

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.

Release files for netplan 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for netplan 0.3.3
File Size Uploaded
netplan-0.3.3.tar.gz 12.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for netplan 0.3.3
File Interpreter ABI Platform
netplan-0.3.3-py3-none-any.whl Python 3 none any Details
netplan-0.3.3-py2-none-any.whl Python 2 none any Details

Total release size: 34.7 kB

Release files / netplan-0.3.3.tar.gz

Download URL netplan-0.3.3.tar.gz
Size 12.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a7ba8377d9fde05cb1a446f0082c0f4011ca74537e1647e4e9c227b893c031b1
BLAKE2b-256 checksum
How to use checksums
3646284e325e534b615f591fcf2b61381f67c82fce01de110be3f3fdb8db08a7
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / netplan-0.3.3-py3-none-any.whl

Download URL netplan-0.3.3-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a0c08243ef26a3816bd3aecacebd4b57865f8e80e727c9198b1b7b66e65c4ce
BLAKE2b-256 checksum
How to use checksums
a2613d64b6422f5c44f00aba0ade39cb4b96707bcdcab740b9c7e2a9bb777298
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / netplan-0.3.3-py2-none-any.whl

Download URL netplan-0.3.3-py2-none-any.whl
Size 11.0 kB
Tags Python 2
SHA-256 checksum
How to use checksums
46d3c9c28d5044dd51035555db0fc7dcec1a373d86bc6b358e57aec8a58a6847
BLAKE2b-256 checksum
How to use checksums
078f4c83bcdc63bb04ec0931afd8fbeff07d893c5dcadd6b86e83f7c717c90d7
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.3.3 This release

3 release files

0.3.2

3 release files

0.3.1

2 release files

0.3.0

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page