A library for parsing the netplan configuration data
Project description
netplan - a Python library for parsing the netplan configuration data.
About this Fork
This fork simply packages existing work done by other people, including :
- The original
netplan
Python library, written by Peter Pentchev as part of the OpenStack development team at StorPool. - Changes made by @jjacque of Algolia in their fork.
Unfortunately, version presently on PyPI breaks on Ubuntu 20.04 and is unusable. Additionally :
- The original author seems uninterested in continuing development and changes have not been published for 3 years.
- The Algolia fork seems to have created debian packages, but I can't find them anywhere. It has seen recent development, though, so I hope at some point the packages will become available.
This is forked from algolia/python-netplan
for the sole purpose of making
it pip installable. This fork will be made available as the netplan-ebs
package on PyPI.
Though the package will be installed as netplan-ebs
, the actual
importable package will still be netplan
. Due to this, this fork
and upstream cannot coexist in the same python environment.
This package contains no EBS-specific code and adds no additional dependencies from upstream.
If you are considering using this:
- I do not really have the bandwidth to maintain this fork. I will make the best effort to keep this package installable and track any changes from upstream, but that's about it.
- If upstream resumes development, or publishes an installable package
either through
pip
orapt
though a PPA, this fork and the associated pypi package will likely become unmaintained. - Issues dealing with install and basic functionality are welcome.
- Pull Requests should ideally be sent to
algolia/python-netplan
, so that the codebase does not diverge for entirely non-technical reasons. - If you are able and willing to take over maintenance of this package, please get in touch with me.
If you do end up using this package - especially if you do so in a production setting - please reach out to me and let me know by email at shashank at chintal dot in. The number of users, if any, is likely to determine how much effort I will put into maintaining this.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file netplan-ebs-0.4.1.tar.gz
.
File metadata
- Download URL: netplan-ebs-0.4.1.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | feb7464643e8cb8193235cd4bd0892d0ef850cb2dc66dd54135ebeb39e3a5985 |
|
MD5 | c5d58afbce31db773cf2f3e718778fff |
|
BLAKE2b-256 | 3cd810c1c4dde3094171c294a923233cfe2b359b577630e8c7f0ca6f7f071998 |
File details
Details for the file netplan_ebs-0.4.1-py3-none-any.whl
.
File metadata
- Download URL: netplan_ebs-0.4.1-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 443e4a2824d2da08f59429626d41d858a6ce60bb01bb6f107133f85ee9937c20 |
|
MD5 | 6dc1b934380e30c657f1448a12599273 |
|
BLAKE2b-256 | 95d228aa13fd25abb75433388379786679c393391f8fe6706c049c349ddf28fb |