用于解析netplan配置数据的库

netplan的Python项目详细描述


netplan-用于分析netplan配置数据的python库。

说明

此模块解析描述系统的 netplan.io包使用的格式的网络配置。 主解析器是“netplan.parser.parser”类(也导出为 “netplan.parser”);其“parse()”方法返回 “netplan.config.netplan”类(也导出为“netplan.netplan”)。

示例用法

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='')

netplan解析器工具

三种类型的查询-解析接口数据,获取所有相关的 接口,并且只获取与物理相关的接口 可通过命令行netplan-parser工具获得:

# 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

联系人

python库是由peter pentchev作为 位于StorPoolOpenStack development团队。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java根据一些规则对地图进行排序   java需要关于突破游戏冲突bug的帮助   在Javaservlet中打印XSLT转换的XML文档   使用volatile'status flag'布尔值的java同步?   java Hibernate 4.2、JPA 2.0关系OnetoMany单向注释   在java中,如何在不使用for循环的情况下找到数组列表中第二高的数字?   排序Java多维数组   安装位置上的java Izpack toggel复选框   使用SQL Server 2008数据库交付Java应用程序   处理如何解决线程“动画线程”java中的异常。lang.NullPointerException?   安卓如何在Java中调用OpenSSL方法?   JAVA使用tomcat在jsf应用程序上运行lang.StackOverflowerError   java隐藏javafx Listview中的垂直滚动条   java如何使用Spring Boot在运行时提供静态资源?   java如何将@EJB与远程接口结合使用”   java哪个版本是Sun/Oracle提供的JavaEEAPIX的最新版本。jar和下载最新版本>7.0   java向JavaFX ToggleSwitch添加更改侦听器   保存在哪里以及如何处理Java应用程序的版本?   java AsyncTask执行doInBackground()时出错