用于解析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第三方库


热门话题
JDBC字符串中的java Mysql会话变量   java Gradle多项目:链接到父项目时子项目失败   eclipse我在使用Java:401未经授权错误列出google驱动器文件时出错   java如何在spring boot中以编程方式设置defaultLocale   java不能跨类更改JLabel   java如何在获取元素号的同时找到数组中的最小数   java如何在不使用节点的情况下交替合并链表?通过使用递归?   当使用XStream转换为java对象时,xml序列化会转义xml中的某些元素   java如何使用MPAndroid图表库跳过折线图中特定索引上的值?   java记录未使用primefaces 6.2更新   java JQuery数据表HideColumn   java为什么我的播放器在我移动时会振动,碰撞检测方法导致了这种情况   使用HTTP状态500而不是HTTP状态400的java JAXRS响应   java从超类方法调用子类方法?   用于远程ip(主机)的Java RMI