You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

IOS-XE设备使用Netconf-Yang修改接口描述出现bad arg错误怎么解决

问题原因

你返回的报错均为OpenConfig(oc-前缀)模型的校验错误,与你要修改的ietf-interfaces接口配置完全无关。这是IOS-XE 16.8.1版本的已知Netconf实现缺陷:当你使用default_operation: merge参数时,设备会强制校验全量Yang模型数据,包括你未修改的OpenConfig模型部分,只要设备现有配置不符合OC模型定义就会直接抛错,和你提交的接口修改配置本身无关。

你用pyang2dsdl校验得到的「config应该为data」提示属于误报,pyang2dsdl默认校验的是get操作返回的data结构,edit-config请求的根节点本来就是<config>,无需修改。

解决方案

方案1(优先推荐,无需修改设备配置)

  1. 给你要修改的配置节点单独添加nc:operation="merge"属性,修改后的yang-config.xml内容如下:
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
    <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
        <interface nc:operation="merge">
            <name>GigabitEthernet1/1/1</name>
            <description>netconf-test1</description>
            <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type>
        </interface>
    </interfaces>
</config>
  1. 将Ansible任务中的default_operation参数改为none,设备就只会校验你显式指定要修改的节点,不会校验全量配置:
- name: Changing interfaces description
  netconf_config:
    lock: if-supported
    error_option: rollback-on-error
    default_operation: "none"
    commit: yes
    content: "{{ lookup('file', outfile) }}"
  register: result

方案2(无需修改Ansible配置,适配全量merge场景)

如果你确实需要使用全量merge操作,直接在设备全局配置下关闭OpenConfig模型支持即可:

  1. 执行全局配置命令:no netconf-yang module openconfig*
  2. 重启Netconf进程生效:netconf-yang restart

方案3(长期优化建议)

如果条件允许,建议将Cat9K的版本升级到16.12.x或者17.3.x以上的长期支持版本,这些版本修复了大量早期IOS-XE的Netconf/Yang实现bug,兼容性提升明显。

内容的提问来源于stack exchange,提问作者MrPoulet

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.26 22:06:03