cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
518
Views
10
Helpful
1
Replies

Reference interfaces from netconf device in yang module

Hi all,

 

I'm trying to convert my service from using CLI-based NEDs to purely NETCONF-based. In my YANG module I'm referencing the list of interfaces that the selected device has available;

 

(abbreviated version):

module l3vpn {
  namespace "http://com/example/l3vpn";
  prefix l3vpn;

  import ietf-inet-types {
    prefix inet;
  }
  import tailf-ncs {
    prefix ncs;
  }
  import tailf-common {
    prefix tailf;
  }
  import tailf-ned-cisco-ios-xr {
    prefix cisco-ios-xr;
  }
  augment "/ncs:services" {
    list l3vpn {
      key "name";
      unique "vpn-id";

      uses ncs:service-data;
      ncs:servicepoint "l3vpn";

      leaf name {
        tailf:info "VRF Name";
        mandatory true;
        type string;
      }
      leaf customer {
        tailf:info "Customer name";
        type string;
      }
      leaf vpn-id {
        tailf:info "Unique VPN ID, used for RD/RT";
        mandatory true;
        type uint32 {
          range "1..65535";
        }
      }
      list link {
        tailf:info "Attachment Circuits to VPN";

        key "ac-name";
        unique "ac-name";

        leaf ac-name {
            tailf:info "AC connection ID - ie. AC123456";
            mandatory true;
            type string;
        }
        leaf device {
          tailf:info "PE Router";
          mandatory true;
          type leafref {
            path "/ncs:devices/ncs:device/ncs:name";
          }
        }
        container iosxr {
          when "/ncs:devices/ncs:device[ncs:name=current()/../device]/ncs:device-type/ncs:cli/ncs:ned-id='cisco-ios-xr-id:cisco-ios-xr'" {
            tailf:dependency "../device";
            tailf:dependency "/ncs:devices/ncs:device/ncs:device-type";
          }
          choice interface-type {
            case GigabitEthernet {
              leaf xr-GigabitEthernet {
                type leafref {
                  path "deref(../../device)/../ncs:config/cisco-ios-xr:interface/cisco-ios-xr:GigabitEthernet/cisco-ios-xr:id";
                }
              }
} } } } } }

In the new YANG definition, I'm omitting the 'import tailf-ned-cisco-ios-xr' and changes the IOSXR container to:

 

container iosxr {
  when "/ncs:devices/ncs:device[ncs:name=current()/../device]/ncs:device-type/ncs:netconf/ncs:ned-id='XR-nc-6.3:XR-nc-6.3'" {
    tailf:dependency "../device";
    tailf:dependency "/ncs:devices/ncs:device/ncs:device-type";
    }

    leaf xr-interface {
      type leafref {
        path "deref(../../device)/../ncs:config/interface-configurations/interface-configuration/interface-name";
      }
    }
}

The XPATH string I'm basing it on looks like this:

root@ncs# show running-config devices device A9K config interface-configurations interface-configuration act TenGigE0/0/2/0 | display xpath
/devices/device[name='A9K']/config/ifmgr-cfg:interface-configurations/interface-configuration[active='act'][interface-name='TenGigE0/0/2/0']/cdp-cfg:cdp/enable

And the JSON structure looks like this:

root@ncs# show running-config devices device A9K config interface-configurations interface-configuration act TenGigE0/0/2/0 | display json
{
  "data": {
    "tailf-ncs:devices": {
      "device": [
        {
          "name": "A9K",
          "config": {
            "Cisco-IOS-XR-ifmgr-cfg:interface-configurations": {
              "interface-configuration": [
                {
                  "active": "act",
                  "interface-name": "TenGigE0/0/2/0",
                  "Cisco-IOS-XR-cdp-cfg:cdp": {"": "enable"
                  }
                }
              ]
            }
          }
        }
      ]
    }
  }
}

While troubleshooting, I've tried to import the Cisco-IOS-XR-ifmgr-cfg module and use it as a prefix for the elements in the XPATH, however when I try to compile this I'm getting an error that the module doesn't have the 'interface-configurations' element.

 

Any ideas or clues?

 

Best regards

-J

1 Accepted Solution

Accepted Solutions

Ok, so I managed to figure this one out myself after several hours debugging. After scouring all the folders for the interface-configurations container, I found that the modules in the ncsc-out subfolder augmented the ncs:config element.

 

In my Makefile I had both the ../src/yang and the ../src/ncsc-out/modules/yang. I omitted the ../src/yang path from the YANGPATH, included the 'import Cisco-IOS-XR-ifmgr-cfg { prefix ifmgr-cfg; }' statement in the service yang definition and added the ifmgr-cfg prefix to all elements in the 'xr-interface' XPATH statement.

View solution in original post

1 Reply 1

Ok, so I managed to figure this one out myself after several hours debugging. After scouring all the folders for the interface-configurations container, I found that the modules in the ncsc-out subfolder augmented the ncs:config element.

 

In my Makefile I had both the ../src/yang and the ../src/ncsc-out/modules/yang. I omitted the ../src/yang path from the YANGPATH, included the 'import Cisco-IOS-XR-ifmgr-cfg { prefix ifmgr-cfg; }' statement in the service yang definition and added the ifmgr-cfg prefix to all elements in the 'xr-interface' XPATH statement.