cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
343
Views
10
Helpful
5
Replies
Highlighted
Beginner

YDK Openconfig: Issue with Table connections for BGP

Hi all,

 

I was trying to use YDK openconfig_network_instance python modules to pass the redistribution of routes of BGP IOS-XR router, the import-policy field apparently doesn't recognize the already defined policies in the IOS-XR

Could anyone kindly help me find what parameters I'm missing?

 

Below the steps I've tried:

 

 

from ydk.models.openconfig import openconfig_network_instance as oc_netins
from ydk.models.openconfig.openconfig_interfaces import Interfaces as oci
from ydk.models.openconfig.openconfig_network_instance_types import DEFAULTINSTANCE,L3VRF
from ydk.models.openconfig.openconfig_types import IPV4
from ydk.models.openconfig.openconfig_policy_types import BGP, DIRECTLYCONNECTED
from ydk.models.openconfig.openconfig_routing_policy import DefaultPolicyType
from ydk.services import CRUDService
from ydk.providers import NetconfServiceProvider
from ydk.models.openconfig import openconfig_bgp as oc_bgp
from ydk.models.openconfig import openconfig_bgp_types as oc_bgp_types

netins_s = oc_netins.NetworkInstances()
netins = netins_s.NetworkInstance()
table_connection = netins.table_connections.TableConnection()
table_connection.src_protocol=DIRECTLYCONNECTED()
table_connection.config.src_protocol=DIRECTLYCONNECTED()
table_connection.dst_protocol=BGP()
table_connection.config.dst_protocol=BGP()
table_connection.address_family=IPV4()
table_connection.config.address_family=IPV4()
table_connection.config.import_policy = "ROUTE-POLICY"
netins.table_connections.table_connection.append(table_connection)
bgp_proto = netins.protocols.Protocol()
bgp_proto.name = "default"
bgp_proto.config.name = "default"
bgp_proto.identifier = BGP()
bgp = bgp_proto.bgp
bgp.global_.config.as_ = 65000
afi_safi = bgp.global_.afi_safis.AfiSafi()
afi_safi.afi_safi_name = oc_bgp_types.IPV4UNICAST()
afi_safi.config.afi_safi_name = oc_bgp_types.IPV4UNICAST()
afi_safi.config.enabled = True
bgp.global_.afi_safis.afi_safi.append(afi_safi)
netins.protocols.protocol.append(bgp_proto)

provider = NetconfServiceProvider(address=ipaddress, username=user, password=password)
crud = CRUDService()
crud.create(provider, netins)

 

Apparently the defined route policy specified in the table connections doesn't match the route policy defined in the device

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/ydk/errors/error_handler.py", line 112, in helper
    return func(self, provider, entity, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/ydk/services/crud_service.py", line 49, in create
    return _crud_update(provider, entity, self._crud.create)
  File "/usr/local/lib/python3.7/site-packages/ydk/services/crud_service.py", line 70, in _crud_update
    return crud_call(provider, entity)
  File "/usr/local/lib/python3.7/site-packages/ydk/types/py_types.py", line 303, in get_name_leaf_data
    leaf.set(value)
  File "/usr/local/lib/python3.7/site-packages/ydk/types/py_types.py", line 80, in set
    raise _YModelError("Invalid value '{}' in '{}'".format(other, self.leaf_name))
ydk.errors.YModelError: Invalid value 'ROUTE-POLICY' in 'import-policy'

Note that ROUTE-POLICY was previously defined on the device for the sake of testing the redistribution config

!
route-policy ROUTE-POLICY
  pass
end-policy
!

If I try the same without specifying any import policy in the table connections section the RPC is accepted but the BGP configuration will not contain the desired redistribution

 

!
router bgp 65000
 bgp router-id 10.1.1.1
 address-family ipv4 unicast
 !
!

 

2020-05-25 16:03:39,493 - ydk - INFO - ============= Sending RPC to device =============
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><edit-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <target>
    <candidate/>
  </target>
  <config><network-instances xmlns="http://openconfig.net/yang/network-instance" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
  <network-instance nc:operation="merge">
    <name>default</name>
    <config>
      <name>default</name>
    </config>
    <table-connections>
      <table-connection>
        <src-protocol xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:DIRECTLY_CONNECTED</src-protocol>
        <dst-protocol xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:BGP</dst-protocol>
        <address-family xmlns:oc-types="http://openconfig.net/yang/openconfig-types">oc-types:IPV4</address-family>
        <config>
          <src-protocol xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:DIRECTLY_CONNECTED</src-protocol>
          <address-family xmlns:oc-types="http://openconfig.net/yang/openconfig-types">oc-types:IPV4</address-family>
          <dst-protocol xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:BGP</dst-protocol>
        </config>
      </table-connection>
    </table-connections>
    <protocols>
      <protocol>
        <identifier xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:BGP</identifier>
        <name>default</name>
        <config>
          <name>default</name>
        </config>
        <bgp>
          <global>
            <config>
              <as>65000</as>
            </config>
            <afi-safis>
              <afi-safi>
                <afi-safi-name xmlns:oc-bgp-types="http://openconfig.net/yang/bgp-types">oc-bgp-types:IPV4_UNICAST</afi-safi-name>
                <config>
                  <afi-safi-name xmlns:oc-bgp-types="http://openconfig.net/yang/bgp-types">oc-bgp-types:IPV4_UNICAST</afi-safi-name>
                  <enabled>true</enabled>
                </config>
              </afi-safi>
            </afi-safis>
          </global>
        </bgp>
      </protocol>
    </protocols>
  </network-instance>
</network-instances>
</config>
</edit-config>
</rpc>
2020-05-25 16:03:39,522 - ydk - INFO - ============= Received RPC from device =============
<?xml version="1.0"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="3">
  <ok/>
</rpc-reply>

2020-05-25 16:03:39,522 - ydk - INFO - Executing 'commit' RPC
2020-05-25 16:03:39,522 - ydk - INFO - ============= Sending RPC to device =============
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><commit xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/>
</rpc>
2020-05-25 16:03:40,844 - ydk - INFO - ============= Received RPC from device =============
<?xml version="1.0"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="4">
  <ok/>
</rpc-reply>

2020-05-25 16:03:40,844 - ydk - INFO - Operation succeeded

My system info

GNU bash, version 5.0.3(1)-release
python
Python 3.7.7 (default, Apr 21 2020, 14:26:12)
[GCC 8.3.0] on linux

pip list
Package                 Version
----------------------- -----------
alabaster               0.7.12
Babel                   2.8.0
bleach                  3.1.4
certifi                 2020.4.5.1
cffi                    1.14.0
chardet                 3.0.4
cryptography            2.9.2
docutils                0.16
gitdb                   4.0.4
GitPython               3.1.0
idna                    2.9
imagesize               1.2.0
importlib-metadata      1.6.0
jeepney                 0.4.3
Jinja2                  2.11.2
keyring                 21.2.0
MarkupSafe              1.1.1
pip                     20.0.2
pkginfo                 1.5.0.1
pyang                   1.6
pybind11                2.5.0
pycparser               2.20
Pygments                2.6.1
pytz                    2019.3
readme-renderer         26.0
requests                2.23.0
requests-toolbelt       0.9.1
rstr                    2.2.6
SecretStorage           3.1.2
setuptools              46.1.3
six                     1.14.0
smmap                   3.0.2
snowballstemmer         2.0.0
Sphinx                  1.4a1
sphinx-rtd-theme        0.1.9
tqdm                    4.45.0
twine                   3.1.1
urllib3                 1.25.9
webencodings            0.5.1
wheel                   0.34.2
ydk                     0.8.4
ydk-models-cisco-ios-xr 6.6.3
ydk-models-ietf         0.1.5.post2
ydk-models-openconfig   0.1.6.post1
zipp                    3.1.0

Cisco IOS-XR version
Cisco IOS XR Software, Version 6.6.2

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

From what I can see, the YDK worked fine this time.

There might be some limitations in specific implementation of openconfig Yang models in IOS XR. Therefore I suggest you to talk to IOS XR software development team, which knows programmability implementation details.

Yan Gorelik
YDK Solutions

View solution in original post

5 REPLIES 5
Highlighted
Participant

Hi 

The following line in your script is incorrect:

table_connection.config.import_policy = "ROUTE-POLICY"

The 'import_policy' is instance of YLeafList class and must be handled differently:

table_connection.config.import_policy.append("ROUTE-POLICY")

 I also would suggest update your openconfig package to new version 0.1.8; simply:

pip install -U ydk-models-openconfig
Yan Gorelik
YDK Solutions
Highlighted

Thanks @yangorelik !! I've upgraded and implemented as you recommeded, that solves the import policy part, but still for some reason the IOS-XR device that I'm pushing the table connections still won't reflect that table connection as desired ... even after the RPC call returns ok status

 

By this neconf message:

2020-05-25 19:50:50,016 - ydk - INFO - ============= Sending RPC to device =============
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><edit-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <target>
    <candidate/>
  </target>
  <config><network-instances xmlns="http://openconfig.net/yang/network-instance" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
  <network-instance nc:operation="merge">
    <name>default</name>
    <config>
      <name>default</name>
    </config>
    <table-connections>
      <table-connection>
        <src-protocol xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:DIRECTLY_CONNECTED</src-protocol>
        <dst-protocol xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:BGP</dst-protocol>
        <address-family xmlns:oc-types="http://openconfig.net/yang/openconfig-types">oc-types:IPV4</address-family>
        <config>
          <src-protocol xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:DIRECTLY_CONNECTED</src-protocol>
          <address-family xmlns:oc-types="http://openconfig.net/yang/openconfig-types">oc-types:IPV4</address-family>
          <dst-protocol xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:BGP</dst-protocol>
          <import-policy>ROUTE-POLICY</import-policy>
        </config>
      </table-connection>
    </table-connections>
    <protocols>
      <protocol>
        <identifier xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:BGP</identifier>
        <name>default</name>
        <config>
          <name>default</name>
        </config>
        <bgp>
          <global>
            <config>
              <as>65000</as>
              <router-id>10.1.1.1</router-id>
            </config>
            <afi-safis>
              <afi-safi>
                <afi-safi-name xmlns:oc-bgp-types="http://openconfig.net/yang/bgp-types">oc-bgp-types:IPV4_UNICAST</afi-safi-name>
                <config>
                  <afi-safi-name xmlns:oc-bgp-types="http://openconfig.net/yang/bgp-types">oc-bgp-types:IPV4_UNICAST</afi-safi-name>
                  <enabled>true</enabled>
                </config>
              </afi-safi>
            </afi-safis>
          </global>
        </bgp>
      </protocol>
    </protocols>
  </network-instance>
</network-instances>
</config>
</edit-config>
</rpc>
2020-05-25 19:50:50,040 - ydk - INFO - ============= Received RPC from device =============
<?xml version="1.0"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="53">
  <ok/>
</rpc-reply>

2020-05-25 19:50:50,041 - ydk - INFO - Executing 'commit' RPC
2020-05-25 19:50:50,041 - ydk - INFO - ============= Sending RPC to device =============
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><commit xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/>
</rpc>
2020-05-25 19:50:51,285 - ydk - INFO - ============= Received RPC from device =============
<?xml version="1.0"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="54">
  <ok/>
</rpc-reply>

I was expecting that 'redistribute connected route-policy ROUTE-POLICY' would appear under the ipv4 unicast AFI but instead still looks like this:

!
router bgp 65000
 bgp router-id 10.1.1.1
 address-family ipv4 unicast
 !
!
Highlighted

From what I can see, the YDK worked fine this time.

There might be some limitations in specific implementation of openconfig Yang models in IOS XR. Therefore I suggest you to talk to IOS XR software development team, which knows programmability implementation details.

Yan Gorelik
YDK Solutions

View solution in original post

Highlighted

Did not notice this on the logs before, openconfig deviations for ios-xr are not parsed through from the little i understand:

 

2020-05-26 15:43:19,969 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Reached limit (65535) for storing typedefs.
2020-05-26 15:43:19,970 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Module "cisco-xr-openconfig-network-instance-deviations" parsing failed.

which seems ignored and continues on with configuration, but it can be seen by looking at the actual yang file of the openconfig ios-xr-deviations that indeed openconfig table-connections are not supported :(

 

  deviation "/oc-netinst:network-instances/oc-netinst:network-instance/oc-netinst:table-connections/oc-netinst:table-connection" {
    deviate not-supported;
  }

 

Thanks for the help

Highlighted

Regarding error messages. That issue was spotted previously. The details could be viewed here. In short, the Libyang has limitation of 255 deviation statements per module. Apparently number of such statements exceeds 255.

The only known workaround for this issue is manual altering of deviation file in the temporary repository by deleting deviation statements, which are not of importance for your application.

Yan Gorelik
YDK Solutions
Content for Community-Ad
Cisco Community October 2020 Spotlight Award Winners
This widget could not be displayed.