Giter VIP home page Giter VIP logo

openconfig-getting-started's Introduction

Getting Started With OpenConfig in Cisco IOS XR

This repository includes guides to get started with OpenConfig models on Cisco IOS XR devices. OpenConfig is a group of network operators that are developing common data models for network configuration and management in cooperation with vendors. Cisco IOS XR started introducing support for OpenConfig models in release 5.3.2. Each model directory in this repository includes a guide to get started using the model, along with configuration and operational examples. You can use NETCONF or gRPC to use OpenConfig models with a Cisco IOS XR device.

Additional Resources

openconfig-getting-started's People

Contributors

111pontes avatar einarnn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openconfig-getting-started's Issues

OpenConfig implementation on IOS-XRv BGP neighbor restart-timer is different

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 neighbor restart timer (when the maximum number of prefixes allowed has been received) in seconds as a 64 bit decimal figure. IOS-XRv expects an integer that is used to specify minutes.

openconfig-bgp-common-multiprotocol.yang defines the following:

  // Config groupings for common groups
  grouping bgp-common-mp-all-afi-safi-common-prefix-limit-config {
    description
      "Configuration parameters relating to prefix-limits for an
      AFI-SAFI";

    leaf max-prefixes {
      type uint32;
      description
        "Maximum number of prefixes that will be accepted
        from the neighbour";
    }

    leaf shutdown-threshold-pct {
      type oc-types:percentage;
      description
        "Threshold on number of prefixes that can be received
        from a neighbour before generation of warning messages
        or log entries. Expressed as a percentage of
        max-prefixes";
    }

    leaf restart-timer {
      type decimal64 {
        fraction-digits 2;
      }
      units "seconds";
      description
        "Time interval in seconds after which the BGP session
        is re-established after being torn down due to exceeding
        the max-prefix limit.";
    }
  }

This is the example JSON config:

bensley@ubuntu-laptop:~/Python/pyb_oc/ios-xr-grpc-python-master/examples$ cat snips/broken_restart_timer.json 
{
    "openconfig-bgp:bgp": {
        "neighbors": {
            "neighbor": [
                {
                    "neighbor-address": "193.37.144.1", 
                    "config": {
                        "neighbor-address": "193.37.144.1", 
                        "description": "i3b gmbh", 
                        "peer-as": 39912, 
                        "peer-group": "public_v4_peers"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "afi-safi-name": "openconfig-bgp-types:ipv4-unicast", 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                                }, 
                                "ipv4-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 10.00, 
                                            "max-prefixes": 200
                                        }
                                    }
                                }
                            }
                        ]
                    }
                }
            ]
        }
    }
}

Note the restart-timer value is 10.00. This produces the following error from IOS-XRv:

{u'cisco-grpc:errors': {u'error': [{u'error-type': u'protocol', u'error-severity': u'error', u'error-tag': u'bad-element', u'error-path': u"bgp:ns1:bgp/neighbors/neighbor[neighbor-address = '193.37.144.1']/afi-safis/afi-safi[afi-safi-name = 'ipv4-unicast']/ipv4-unicast/prefix-limit/config/restart-timer", u'error-info': {u'bad-element': u'restart-timer'}}]}}

Setting it to 10 works fine.

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"
            }
        ]
    }
}
Config after 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"
                                                }
                                            ]
                                        }, 
                                        "neighbors": {
                                            "neighbor": [
                                                {
                                                    "neighbor-address": "193.37.144.1", 
                                                    "remote-as": {
                                                        "as-xx": 0, 
                                                        "as-yy": 39912
                                                    }, 
                                                    "neighbor-group-add-member": "public_v4_peers", 
                                                    "description": "i3b gmbh", 
                                                    "neighbor-afs": {
                                                        "neighbor-af": [
                                                            {
                                                                "af-name": "ipv4-unicast", 
                                                                "activate": [
                                                                    null
                                                                ], 
                                                                "maximum-prefixes": {
                                                                    "discard-extra-paths": false, 
                                                                    "warning-percentage": 90, 
                                                                    "warning-only": false, 
                                                                    "prefix-limit": 200, 
                                                                    "restart-time": 10
                                                                }
                                                            }
                                                        ]
                                                    }
                                                }
                                            ]
                                        }
                                    }
                                }
                            }
                        ], 
                        "as": 0
                    }
                ], 
                "instance-name": "default"
            }
        ]
    }
}

We can see the config has been applied below. However in IOS-XRv we have configured a 10 minute restart time when a 10.0 second restart timer was desired:

RP/0/RP0/CPU0:ios#show run router bgp
Wed Nov  9 17:18:42.167 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
  !
 !
 neighbor 193.37.144.1
  remote-as 39912
  use neighbor-group public_v4_peers
  description i3b gmbh
  address-family ipv4 unicast
   maximum-prefix 200 90 restart 10
  !
 !
!

RP/0/RP0/CPU0:ios#conf t
Wed Nov  9 17:18:52.303 UTC
RP/0/RP0/CPU0:ios(config)#router bgp 65001 neighbor 193.37.144.1 address-family ipv4 unicast
RP/0/RP0/CPU0:ios(config-bgp-nbr-af)#maximum-prefix 200 90 restart ?
  <1-65535>  Time interval (min) after which peering session will be reestablished

RP/0/RP0/CPU0:ios#show bgp ipv4 unicast neighbors 193.37.144.1 | inc 10
Wed Nov  9 17:20:45.309 UTC
  Threshold for warning message 90%, restart interval 10 min

Is the OpenConfig model for this not correctly implemented in IOS-XRv 6.2.1?

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

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

OpenConfig implementation in IOS-XRv is order-specific when sending JSON over gRPC

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 with Pyangbind (v0.5.8) is producing configuration when serialized to JSON in the below order; the key point here is that in the IPv4 config "afi-safi-name": "openconfig-bgp-types:IPV4_UNICAST" comes at the end but for the IPv6 config it's roughly in the middle. The IOS-XRv device will not accept either of these orderings, unless the afi-safi-name is first:

{
    "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" ## AT THE END
                }
            }
        }
},
{
    "1::1": {
        "neighbor-address": "1::1", 
        "config": {
            ...
        }, 
        "afi-safis": {
            "afi-safi": {
                "openconfig-bgp-types:IPV6_UNICAST": {
                    "config": {
                        ...
                    }, 
                    "afi-safi-name": "openconfig-bgp-types:IPV6_UNICAST", ## IN THE MIDDLE
                    "ipv6-unicast": {
                        "prefix-limit": {
                            "config": {
                                ...
                            }
                        }
                    }
                }
            }
        }
    }
}

The below works (but I have to manually re-order the statements (also note the case sensitive issue must be corrected):

{
    "1.1.1.1": {
        "neighbor-address": "1.1.1.1", 
        "config": {
            ...
        }, 
        "afi-safis": {
            "afi-safi": {
                "afi-safi-name": "openconfig-bgp-types:ipv4-unicast", ## AT THE START
                "openconfig-bgp-types:ipv4-unicast": {
                        ...
                    }, 
                    "config": {
                        ...
                    }
                }
            }
        }
},
{
    "1::1": {
        "neighbor-address": "1::1", 
        "config": {
            ...
        }, 
        "afi-safis": {
            "afi-safi": {
                "afi-safi-name": "openconfig-bgp-types:ipv6-unicast", ## AT THE START
                "openconfig-bgp-types:ipv6-unicast": {
                    "config": {
                        ...
                    },
                    "ipv6-unicast": {
                        "prefix-limit": {
                            "config": {
                                ...
                            }
                        }
                    }
                }
            }
        }
    }
}

I am filling the OpenConfig object "in order" however this might just come down to the PyangBind serialization into an unordered dict; so I have to manually reorder the items so the the JSON is in the correct order:

from openconfig_bgp import openconfig_bgp
...
oc_bgp = openconfig_bgp()

oc_bgp.bgp.neighbors.neighbor[network["ipaddr4"]].afi_safis.afi_safi.add("openconfig-bgp-types:IPV4_UNICAST")
oc_bgp.bgp.neighbors.neighbor[network["ipaddr4"]].afi_safis.afi_safi["openconfig-bgp-types:IPV4_UNICAST"].config.afi_safi_name = "IPV4_UNICAST"
oc_bgp.bgp.neighbors.neighbor[network["ipaddr4"]].afi_safis.afi_safi["openconfig-bgp-types:IPV4_UNICAST"].config.enabled = "true"

unsorted_afi_safis = copy.deepcopy(neighbor["afi-safis"]["afi-safi"][0])
sorted_afi_safis = OrderedDict(sorted(unsorted_afi_safis.items(), key=lambda t: t[0]))
neighbor["afi-safis"]["afi-safi"][0].clear()
neighbor["afi-safis"]["afi-safi"][0] = copy.deepcopy(sorted_afi_safis)

This is the error message I get because the "config" section is before the "afi-safi-name" section:

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'missing-element', u'error-message': u'An expected element is missing.', u'error-info': {u'bad-element': u'config'}}}}

bensley@ubuntu-laptop:~/Python/pyb_oc/ios-xr-grpc-python-master/examples$ cat snips/broken_ordering.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": [
                            {
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv6-unicast"
                                },
                                "afi-safi-name": "openconfig-bgp-types:ipv6-unicast",
                                "ipv6-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 500
                                        }
                                    }
                                }
                            }
                        ]
                    }
                }
            ]
        }
    }
}
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

Are the OpenConfig YANG modules defining a strict order that the data should be sent in via JSON? I would expect all data to be sent to the gRPC server and for it evaluate it once it has received it all. It seems like it is receiving the "config" section and then generating the error, even though the "afi-safi-name" section is coming.

OpenConfig implementation on IOS-XRv not supporting several options for BGP

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

Various OpenConfig types are note supported in the IOS-XRv 6.2.1 stable VM...

From openconfig-bgp-types.yang:

  typedef peer-type {
    type enumeration {
      enum INTERNAL {
        description "internal (iBGP) peer";
      }
      enum EXTERNAL {
        description "external (eBGP) peer";
      }
    }
    description
      "labels a peer or peer group as explicitly internal or
      external";
  }

  identity REMOVE_PRIVATE_AS_OPTION {
    description
      "Base identity for options for removing private autonomous
      system numbers from the AS_PATH attribute";
  }

  identity PRIVATE_AS_REMOVE_ALL {
    base REMOVE_PRIVATE_AS_OPTION;
    description
      "Strip all private autonmous system numbers from the AS_PATH.
      This action is performed regardless of the other content of the
      AS_PATH attribute, and for all instances of private AS numbers
      within that attribute.";
  }

  identity PRIVATE_AS_REPLACE_ALL {
    base REMOVE_PRIVATE_AS_OPTION;
    description
      "Replace all instances of private autonomous system numbers in
      the AS_PATH with the local BGP speaker's autonomous system
      number. This action is performed regardless of the other
      content of the AS_PATH attribute, and for all instances of
      private AS number within that attribute.";
  }

  typedef remove-private-as-option {
    type identityref {
      base REMOVE_PRIVATE_AS_OPTION;
    }
    description
      "set of options for configuring how private AS path numbers
      are removed from advertisements";
  }

I am using the code (generated with PyandBind v0.5.8):

from openconfig_bgp import openconfig_bgp
...
oc_bgp = openconfig_bgp()

oc_bgp.bgp.neighbors.neighbor[network["ipaddr4"]].config.enabled = "true"
oc_bgp.bgp.neighbors.neighbor[network["ipaddr4"]].config.remove_private_as = "PRIVATE_AS_REMOVE_ALL"
oc_bgp.bgp.neighbors.neighbor[network["ipaddr4"]].config.peer_type = "EXTERNAL"

From the below config none the following are supported:

"enabled": true, 
"remove-private-as": "PRIVATE_AS_REMOVE_ALL", 
"peer-type": "EXTERNAL"

Example config that works once these three above options are removed:

bensley@ubuntu-laptop:~/Python/pyb_oc/ios-xr-grpc-python-master/examples$ cat snips/broken_private_as.json 
{
    "openconfig-bgp:bgp": {
        "neighbors": {
            "neighbor": [
                {
                    "neighbor-address": "193.37.144.1", 
                    "config": {
                        "neighbor-address": "193.37.144.1", 
                        "description": "i3b gmbh", 
                        "peer-as": 39912,
                        "enabled": true,
                        "peer-group": "public_v4_peers", 
                        "remove-private-as": "PRIVATE_AS_REMOVE_ALL",
                        "peer-type": "EXTERNAL"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "afi-safi-name": "openconfig-bgp-types:ipv4-unicast", 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                                }, 
                                "ipv4-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 200
                                        }
                                    }
                                }
                            }
                        ]
                    }
                }
            ]
        }
    }
}

That config returns the error:

{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'enabled'}}}}

After removing "enabled": true I get:

{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'peer-type'}}}}

After then removing "peer-type": "EXTERNAL" something really strange happens, with the only unsupported option left being the "remove-private-as": "PRIVATE_AS_REMOVE_ALL" option, for some reason the config is accepted however the remove-private-as option isn't configured and instead very strangely all of the possible BGP AFI/SAFIs are configured towards this neighbour?!?

You can also see here that all those additional address families have been enabled globally to support this new neighbor which could have a very bad effect in a live production environment:

bensley@ubuntu-laptop:~/Python/pyb_oc/ios-xr-grpc-python-master/examples$ cat snips/broken_private_as.json 
{
    "openconfig-bgp:bgp": {
        "neighbors": {
            "neighbor": [
                {
                    "neighbor-address": "193.37.144.1", 
                    "config": {
                        "neighbor-address": "193.37.144.1", 
                        "description": "i3b gmbh", 
                        "peer-as": 39912, 
                        "peer-group": "public_v4_peers", 
                        "remove-private-as": "PRIVATE_AS_REMOVE_ALL"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "afi-safi-name": "openconfig-bgp-types:ipv4-unicast", 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                                }, 
                                "ipv4-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 200
                                        }
                                    }
                                }
                            }
                        ]
                    }
                }
            ]
        }
    }
}

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"
            }
        ]
    }
}
Config after 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": "ipv4-multicast", 
                                                    "enable": [
                                                        null
                                                    ]
                                                }, 
                                                {
                                                    "af-name": "vp-nv4-unicast", 
                                                    "enable": [
                                                        null
                                                    ]
                                                }, 
                                                {
                                                    "af-name": "ipv6-unicast", 
                                                    "enable": [
                                                        null
                                                    ]
                                                }, 
                                                {
                                                    "af-name": "vp-nv6-unicast", 
                                                    "enable": [
                                                        null
                                                    ]
                                                }, 
                                                {
                                                    "af-name": "l2vpnvpls", 
                                                    "enable": [
                                                        null
                                                    ]
                                                }, 
                                                {
                                                    "af-name": "l2vpnevpn", 
                                                    "enable": [
                                                        null
                                                    ]
                                                }, 
                                                {
                                                    "af-name": "vp-nv4-multicast", 
                                                    "enable": [
                                                        null
                                                    ]
                                                }, 
                                                {
                                                    "af-name": "vp-nv6-multicast", 
                                                    "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"
                                                }
                                            ]
                                        }, 
                                        "neighbors": {
                                            "neighbor": [
                                                {
                                                    "neighbor-address": "193.37.144.1", 
                                                    "remote-as": {
                                                        "as-xx": 0, 
                                                        "as-yy": 39912
                                                    }, 
                                                    "neighbor-group-add-member": "public_v4_peers", 
                                                    "description": "i3b gmbh", 
                                                    "neighbor-afs": {
                                                        "neighbor-af": [
                                                            {
                                                                "af-name": "ipv4-unicast", 
                                                                "activate": [
                                                                    null
                                                                ], 
                                                                "maximum-prefixes": {
                                                                    "discard-extra-paths": false, 
                                                                    "warning-percentage": 90, 
                                                                    "warning-only": false, 
                                                                    "prefix-limit": 200, 
                                                                    "restart-time": 1
                                                                }
                                                            }, 
                                                            {
                                                                "af-name": "ipv4-multicast", 
                                                                "activate": [
                                                                    null
                                                                ]
                                                            }, 
                                                            {
                                                                "af-name": "vp-nv4-unicast", 
                                                                "activate": [
                                                                    null
                                                                ]
                                                            }, 
                                                            {
                                                                "af-name": "ipv6-unicast", 
                                                                "activate": [
                                                                    null
                                                                ]
                                                            }, 
                                                            {
                                                                "af-name": "vp-nv6-unicast", 
                                                                "activate": [
                                                                    null
                                                                ]
                                                            }, 
                                                            {
                                                                "af-name": "l2vpnvpls", 
                                                                "activate": [
                                                                    null
                                                                ]
                                                            }, 
                                                            {
                                                                "af-name": "l2vpnevpn", 
                                                                "activate": [
                                                                    null
                                                                ]
                                                            }, 
                                                            {
                                                                "af-name": "vp-nv4-multicast", 
                                                                "activate": [
                                                                    null
                                                                ]
                                                            }, 
                                                            {
                                                                "af-name": "vp-nv6-multicast", 
                                                                "activate": [
                                                                    null
                                                                ]
                                                            }
                                                        ]
                                                    }
                                                }
                                            ]
                                        }
                                    }
                                }
                            }
                        ], 
                        "as": 0
                    }
                ], 
                "instance-name": "default"
            }
        ]
    }
}

Renaming that option to be called "remove-private-as-option" as per this OpenConfig typdef:


  typedef remove-private-as-option {
    type identityref {
      base REMOVE_PRIVATE_AS_OPTION;
    }
    description
      "set of options for configuring how private AS path numbers
      are removed from advertisements";
  }

just returns the error:

{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'remove-private-as-option'}}}}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.