cancel
Showing results for 
Search instead for 
Did you mean: 
cancel

Who Me Too'd this topic

JunOS openconfig interfaces read errors

mdifrancesco-2
Level 1
Level 1

Hello Community colleagues!

 

Wondering if anyone is experiencing the same errors when trying to read with ydk-py with an OC Interfaces filter from a JunOS (MX 19.4)

 

Seems to me that unlike the IOS-XR devices i've tried before this, JunOS  have some openconfig model representation mismatch with the YDK bundle, at least for the addresses element within interfaces. Also, unlike IOS-XR they don't list the OC yang models in the capabilities list when opening the netconf session which also creates other issues for writing config as well... I've managed to solve that by using pre-defined OC Repository() objects, but this doesn't seem to apply for read ...

 

For the read part this is what I'm trying initially:

 

>>> from ydk.services import NetconfService
>>> from ydk.types import Filter
>>> from ydk.models.openconfig.openconfig_interfaces import Interfaces as oci
>>> from ydk.models.openconfig import openconfig_network_instance as oc_netins
>>> netconf = NetconfService()
>>> ifaces_filt= oci()
>>> filters = Filter(ifaces_filt)
>>> crud = CRUDService()
>>> netconf_output = crud.read_config(provider, filters)

 

And this is the response:

 

2020-09-08 09:04:15,261 - ydk - INFO - Executing CRUD read operation on [openconfig-interfaces:interfaces]
2020-09-08 09:04:15,261 - ydk - INFO - Executing 'get-config' RPC on [openconfig-interfaces:interfaces] from running
2020-09-08 09:04:15,262 - ydk - INFO - ============= Sending RPC to device =============
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><get-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <source>
    <running/>
  </source>
  <filter><interfaces xmlns="http://openconfig.net/yang/interfaces"/></filter>
</get-config>
</rpc>
2020-09-08 09:04:15,365 - ydk - INFO - ============= Received RPC from device =============
<?xml version="1.0"?>
<nc:rpc-reply xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/19.4R0/junos" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="12">
  <nc:data>
    <interfaces xmlns="http://openconfig.net/yang/interfaces">
      <interface>
        <name>fxp0</name>
        <config>
          <name>fxp0</name>
          <type>ianaift:ethernetCsmacd</type>
          <description/>
          <enabled>true</enabled>
        </config>
        <subinterfaces>
          <subinterface>
            <index>0</index>
            <config>
              <index>0</index>
            </config>
            <ipv4 xmlns="http://openconfig.net/yang/interfaces/ip">
              <addresses>
                <address>
                  <ip>10.1.1.5</ip>
                  <config>
                    <ip>10.1.1.5</ip>
                    <prefix-length>24</prefix-length>
                  </config>
                </address>
              </addresses>
            </ipv4>
          </subinterface>
        </subinterfaces>
      </interface>
      <interface>
        <name>ge-0/0/0</name>
        <config>
          <name>ge-0/0/0</name>
          <type>ianaift:ethernetCsmacd</type>
          <mtu>1514</mtu>
          <description>ge-0/0/0 test</description>
          <enabled>true</enabled>
        </config>
        <subinterfaces>
          <subinterface>
            <index>0</index>
            <config>
              <index>0</index>
            </config>
            <ipv4 xmlns="http://openconfig.net/yang/interfaces/ip">
              <addresses>
                <address>
                  <ip>192.168.2.1</ip>
                  <config>
                    <ip>192.168.2.1</ip>
                    <prefix-length>27</prefix-length>
                  </config>
                </address>
              </addresses>
            </ipv4>
          </subinterface>
        </subinterfaces>
      </interface>
      <interface>
        <name>lo0</name>
        <config>
          <name>lo0</name>
          <type>ianaift:softwareLoopback</type>
          <description/>
          <enabled>true</enabled>
        </config>
        <subinterfaces>
          <subinterface>
            <index>0</index>
            <config>
              <index>0</index>
            </config>
            <ipv4 xmlns="http://openconfig.net/yang/interfaces/ip">
              <addresses>
                <address>
                  <ip>192.168.1.101</ip>
                  <config>
                    <ip>192.168.1.101</ip>
                    <prefix-length>32</prefix-length>
                  </config>
                </address>
              </addresses>
            </ipv4>
          </subinterface>
        </subinterfaces>
      </interface>
    </interfaces>
  </nc:data>
</nc:rpc-reply>

2020-09-08 09:04:15,373 - ydk - ERROR - Cannot find model with module name '//openconfig.net/yang/interfaces/ip'
2020-09-08 09:04:15,375 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Data model "//openconfig.net/yang/interfaces/ip" not found.
2020-09-08 09:04:15,381 - ydk - ERROR - Cannot find model with module name '//openconfig.net/yang/interfaces'
2020-09-08 09:04:15,381 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Data model "//openconfig.net/yang/interfaces" not found.

If instead of using crud.read_config() I switch to crud.read() I'd get this RPC response:

2020-09-08 09:03:36,630 - ydk - INFO - Executing CRUD read operation on [openconfig-interfaces:interfaces]
2020-09-08 09:03:36,637 - ydk - INFO - Executing 'get' RPC on [openconfig-interfaces:interfaces]
2020-09-08 09:03:36,639 - ydk - INFO - ============= Sending RPC to device =============
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><get xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <filter><interfaces xmlns="http://openconfig.net/yang/interfaces"/></filter>
</get>
</rpc>
2020-09-08 09:03:36,651 - ydk - INFO - ============= Received RPC from device =============
<?xml version="1.0"?>
<nc:rpc-reply xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/19.4R0/junos" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="9">
  <nc:rpc-error>
    <nc:error-type>protocol</nc:error-type>
    <nc:error-tag>operation-failed</nc:error-tag>
    <nc:error-severity>error</nc:error-severity>
    <nc:error-message>syntax error</nc:error-message>
    <nc:error-info>
      <nc:bad-element>interfaces</nc:bad-element>
    </nc:error-info>
  </nc:rpc-error>
</nc:rpc-reply>

Below is the details of my python environment:

 

Python 3.7.7
ydk                     0.8.4
ydk-models-cisco-ios-xr 6.6.3
ydk-models-ietf         0.1.5.post2
ydk-models-openconfig   0.1.8

 

 

Cheers,

Mauro

Who Me Too'd this topic