CiscoDevNet / openconfig-getting-started

Getting started guides for OpenConfig in Cisco IOS XR
Other
30 stars 6 forks source link

OpenConfig implementation in IOS-XRv is not matching the BGP AFI/SAFI names #2

Closed jwbensley closed 7 years ago

jwbensley commented 8 years ago

NB: This is the gRPC client "grpc_cfg.py" I am using based off of the public Cisco example: https://gist.github.com/jwbensley/cd2f5bfacee321328ca638b5b5523bd9

NB: This is using the IOS-XRv 6.2.1 stable vagrant image from https://devhub.cisco.com/artifactory/appdevci-release/XRv64/6.2.1/ dated 17th Oct 2016

OpenConfig defines the BGP AFI/SAFI types "IPV6_UNICAST" and "IPV4_UNICAST" etc but the IOS-XRv device only accepts "ipv6-unicast" or "ipv4-unicast" so they must be replaced/converted to lower case text of the AFI/SAFI name before the config (serialized as JSON using Pyangbind v0.5.8) can be pushed to the IOS-XRv device.

This:

{
    "1.1.1.1": {
        "neighbor-address": "1.1.1.1", 
        "config": {
            ...
        }, 
        "afi-safis": {
            "afi-safi": {
                "openconfig-bgp-types:IPV4_UNICAST": {
                        ...
                    }, 
                    "config": {
                        ...
                    }, 
                    "afi-safi-name": "openconfig-bgp-types:IPV4_UNICAST"
                }
            }
        }
},

Needs to be:

{
    "1.1.1.1": {
        "neighbor-address": "1.1.1.1", 
        "config": {
            ...
        }, 
        "afi-safis": {
            "afi-safi": {
                "openconfig-bgp-types:ipv4-unicast": {
                        ...
                    }, 
                    "config": {
                        ...
                    }, 
                    "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                }
            }
        }
},

From openconfig-bgp-types.yang:


  identity IPV4_UNICAST {
    base AFI_SAFI_TYPE;
    description
      "IPv4 unicast (AFI,SAFI = 1,1)";
    reference "RFC4760";
  }

  identity IPV6_UNICAST {
    base AFI_SAFI_TYPE;
    description
      "IPv6 unicast (AFI,SAFI = 2,1)";
    reference "RFC4760";
  }

Here is a live example, the same issue but with IPv6. If I change from "IPV6_UNICAST" to "ipv6-unicast" it works fine:

bensley@ubuntu-laptop:~/Python/pyb_oc/ios-xr-grpc-python-master/examples$ cat snips/broken_afi_safi.json 
{
    "openconfig-bgp:bgp": {
        "neighbors": {
            "neighbor": [
                {
                    "neighbor-address": "2001:7f8:2d:e:2:0:2686:1", 
                    "config": {
                        "neighbor-address": "2001:7f8:2d:e:2:0:2686:1", 
                        "peer-as": 2686, 
                        "peer-group": "public_v6_peers", 
                        "description": "AT&T EMEA - AS2686"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "afi-safi-name": "openconfig-bgp-types:IPV6_UNICAST", 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:IPV6_UNICAST"
                                }, 
                                "ipv6-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 500
                                        }
                                    }
                                }
                            }
                        ]
                    }
                }
            ]
        }
    }
}
bensley@ubuntu-laptop:~/Python/pyb_oc/ios-xr-grpc-python-master/examples$ python grpc_cfg.py 
Config before merge:

{
    "Cisco-IOS-XR-ipv4-bgp-cfg:bgp": {
        "instance": [
            {
                "instance-as": [
                    {
                        "four-byte-as": [
                            {
                                "as": 65001, 
                                "bgp-running": [
                                    null
                                ], 
                                "default-vrf": {
                                    "global": {
                                        "global-afs": {
                                            "global-af": [
                                                {
                                                    "af-name": "ipv4-unicast", 
                                                    "enable": [
                                                        null
                                                    ]
                                                }, 
                                                {
                                                    "af-name": "ipv6-unicast", 
                                                    "enable": [
                                                        null
                                                    ]
                                                }
                                            ]
                                        }, 
                                        "router-id": "1.1.0.10"
                                    }, 
                                    "bgp-entity": {
                                        "neighbor-groups": {
                                            "neighbor-group": [
                                                {
                                                    "neighbor-group-afs": {
                                                        "neighbor-group-af": [
                                                            {
                                                                "af-name": "ipv4-unicast", 
                                                                "activate": [
                                                                    null
                                                                ], 
                                                                "route-policy-in": "public_v4_peering_ingress", 
                                                                "route-policy-out": "public_v4_peering_egress"
                                                            }
                                                        ]
                                                    }, 
                                                    "create": [
                                                        null
                                                    ], 
                                                    "neighbor-group-name": "public_v4_peers"
                                                }, 
                                                {
                                                    "neighbor-group-afs": {
                                                        "neighbor-group-af": [
                                                            {
                                                                "af-name": "ipv6-unicast", 
                                                                "activate": [
                                                                    null
                                                                ], 
                                                                "route-policy-in": "public_v6_peering_ingress", 
                                                                "route-policy-out": "public_v6_peering_egress"
                                                            }
                                                        ]
                                                    }, 
                                                    "create": [
                                                        null
                                                    ], 
                                                    "neighbor-group-name": "public_v6_peers"
                                                }
                                            ]
                                        }
                                    }
                                }
                            }
                        ], 
                        "as": 0
                    }
                ], 
                "instance-name": "default"
            }
        ]
    }
}

{u'cisco-grpc:errors': {u'error': {u'error-type': u'protocol', u'error-severity': u'error', u'error-tag': u'unknown-element', u'error-message': u'Unknown element is specified.', u'error-info': {u'bad-element': u'ipv6-unicast'}}}}
RP/0/RP0/CPU0:ios#show  run router bgp         
Wed Nov  9 16:31:03.446 UTC
router bgp 65001
 bgp router-id 1.1.0.10
 address-family ipv4 unicast
 !
 address-family ipv6 unicast
 !
 neighbor-group public_v4_peers
  address-family ipv4 unicast
   route-policy public_v4_peering_ingress in
   route-policy public_v4_peering_egress out
  !
 !
 neighbor-group public_v6_peers
  address-family ipv6 unicast
   route-policy public_v6_peering_ingress in
   route-policy public_v6_peering_egress out
  !
 !
!

RP/0/RP0/CPU0:ios#show ver
Wed Nov  9 16:33:45.682 UTC

Cisco IOS XR Software, Version 6.2.1.17I
Copyright (c) 2013-2016 by Cisco Systems, Inc.

Build Information:
 Built By     : nkhai
 Built On     : Thu Oct 13 12:53:41 PDT 2016
 Build Host   : iox-ucs-002
 Workspace    : /auto/iox-ucs-002-san1/production/6.2.1.17I.DT_IMAGE/iosxrv-x64/workspace
 Version      : 6.2.1.17I
 Location     : /opt/cisco/XR/packages/

cisco IOS XRv x64 () processor 
System uptime is 45 minutes
einarnn commented 8 years ago

James,

Can you please check which version of the openconfig model you are using on the client side versus the version supported by the device? The openconfig models switched to the identity definition you have on the client side a while ago, but Cisco platforms do not support that version as yet.

Cheers,

Einar

111pontes commented 8 years ago

Issue was tracked with XR defect CSCvb66790. It has been fixed for several weeks now. A more recent XR should have the fix already.

jwbensley commented 8 years ago

@111pontes I will try to download the latest bleeding edge image and try that.

@einarnn I am using the latest OpenConfig YANG modules from https://github.com/openconfig/public/tree/master/release/models/bgp which haven't been updated in 4 months.

Under https://github.com/openconfig/public/tree/master/release/models the module openconfig-types.yang hasn't been updated for 5 months. Also 5 months for the modules in https://github.com/openconfig/public/tree/master/release/models/interfaces

Looking through the modules they all say yang-version "1" and oc-ext:openconfig-version "2.1.1".

How can I check what is supported on the IOS-XRv device? Is there a command I can run?

Many thanks!

jwbensley commented 8 years ago

I suspect this is the info you were after @einarnn ;

xr-vm_node0_RP0_CPU0:/opt/cisco/XR/packages/iosxrv-mgbl-3.0.0.0-r62117I/rp/yang$ grep -r "openconfig-version" openconfig*.yang
openconfig-bgp-multiprotocol.yang:  oc-ext:openconfig-version "1.1.0";
openconfig-bgp-operational.yang:  oc-ext:openconfig-version "1.1.0";
openconfig-bgp-policy.yang:  oc-ext:openconfig-version "1.1.0";
openconfig-bgp-types.yang:  oc-ext:openconfig-version "1.1.0";
openconfig-bgp.yang:  oc-ext:openconfig-version "1.1.0";
openconfig-extensions.yang:  extension openconfig-version {
openconfig-if-aggregate.yang:  oc-ext:openconfig-version "0.2.0";
openconfig-if-ethernet.yang:  oc-ext:openconfig-version "0.2.0";
openconfig-if-ip.yang:  oc-ext:openconfig-version "0.2.0";
openconfig-interfaces.yang:  oc-ext:openconfig-version "0.2.0";
openconfig-mpls-igp.yang:  oc-ext:openconfig-version "0.2.1";
openconfig-mpls-ldp.yang:  oc-ext:openconfig-version "0.2.1";
openconfig-mpls-rsvp.yang:  oc-ext:openconfig-version "0.2.1";
openconfig-mpls-sr.yang:  oc-ext:openconfig-version "0.2.1";
openconfig-mpls-static.yang:  oc-ext:openconfig-version "0.2.1";
openconfig-mpls-te.yang:  oc-ext:openconfig-version "0.2.1";
openconfig-mpls-types.yang:  oc-ext:openconfig-version "0.2.1";
openconfig-mpls.yang:  oc-ext:openconfig-version "0.2.1";
openconfig-platform-transceiver.yang:  oc-ext:openconfig-version "0.1.0";
openconfig-platform-types.yang:  oc-ext:openconfig-version "0.4.0";
openconfig-platform.yang:  oc-ext:openconfig-version "0.4.0";
openconfig-policy-types.yang:  oc-ext:openconfig-version "1.1.0";
openconfig-routing-policy.yang:  oc-ext:openconfig-version "1.1.0";
openconfig-telemetry.yang:  oc-ext:openconfig-version "0.2.0";
openconfig-terminal-device.yang:  oc-ext:openconfig-version "0.3.1";
openconfig-transport-types.yang:  oc-ext:openconfig-version "0.3.1";
openconfig-types.yang:  oc-ext:openconfig-version "0.2.0";
openconfig-vlan.yang:  oc-ext:openconfig-version "0.1.1";
jwbensley commented 8 years ago

Can I simply SCP to the IOS-XRv device the newer OC YANG models or is there some backend stuff that needs updating that would prevent that from working?

Having said that, BGP YANG types on the IOS-XRv device (openconfig-bgp-types.yang: oc-ext:openconfig-version "1.1.0") has the same definitions as those on my client side (v2.2.0):

xr-vm_node0_RP0_CPU0:/opt/cisco/XR/packages/iosxrv-mgbl-3.0.0.0-r62117I/rp/yang$ less openconfig-bgp-types.yang 

  identity IPV4-UNICAST {
    base afi-safi-type;
    description
      "IPv4 unicast (AFI,SAFI = 1,1)";
    reference "RFC4760";
  }

  identity IPV6-UNICAST {
    base afi-safi-type;
    description
      "IPv6 unicast (AFI,SAFI = 2,1)";
    reference "RFC4760";
  }
einarnn commented 8 years ago

James,

Backend stuff is required.

Cheers,

Einar

jwbensley commented 8 years ago

@einarnn Thanks for confirming, that is what I expected. I assumed that is required so that the JSON formatted data can be ingested into a YANG module and then translated to the IOS-XR internal config data model (or a similar process). So what happens next, since this is "simply" a case of the OpenConfig modules inside IOS-XR being a bit behind do I just need to wait for them to be updated in future versions of IOS-XR?

111pontes commented 8 years ago

Let me clarify that the issue you're experiencing here doesn't have to do with the model version. It has to do with a defect (CSCvb66790). XR was encoding the identities as lower case despite the fact that they are case-sensitive and defined in upper case. The defect has been fixed and in the process of being integrated into the next official release. If you have access to pre-release images, you should see the fix in the following weeks.

jwbensley commented 8 years ago

@111pontes Ah ok, that makes sense. Thank you.

I have access to the beta builds. I will wait for a new build to come out and report back here :)

111pontes commented 7 years ago

Fixed. Expected to be released in XR 6.2.1.