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

Fetch and display Interface Description

Hi Experts;

I need to fetch interface description of selected interface in service creations.

 

Below code lists the GigabitEthernet interfaces

 

leaf intf-number {
tailf:info "GigabitEthernet Interface ID";
mandatory true;
type leafref {
path "deref(../../device)/../ncs:config/ios:interface/ios:GigabitEthernet/ios:name";
}
}

 

 

I am trying below code but unable to fetch description, Once interface is selected in "intf-number"; need to fetch and display its description in leaf "Interface-Description"

 

 

leaf Interface-Description {
tailf:info "Interface specific description";
type leafref {
path "deref(../../device)/../ncs:config/ios:interface/ios:GigabitEthernet[ios:name='../intf-number']/ios:description"; (not working)
}
}

 

 

xPath for Interface-Description is path /devices/device[name='IOSPE']/config/ios:interface/GigabitEthernet[name='0/0']/description

 

I need help; how can i get interface description based on interface selection..

 

Regards,

Bjron

5 REPLIES 5
Highlighted
Beginner

You can use the following xpath function current() to set the path back to the current node, in this case Interface-Description.  You went ../name/.. to get out of the list and into the ncs:config. Using current()/../intf-number will bring you back to the Interface-Description then up one back to intf-number to get value.

 

leaf Interface-Description {
      tailf:info "Interface specific description";
      type leafref {
        path "deref(../name)/../ncs:config/ios:interface/ios:GigabitEthernet[ios:name=current()/../intf-number]/ios:description";
      }
    }

 

Highlighted

I think it is time to take a step back and explain what it is you want to achieve. A leafref to a specific interface description is very unlikely to be useful so I am guessing that what you want is something else?

Highlighted
Cisco Employee

Hi,

 

Maybe you need to think on using the "tailf:link" extension.

 

Roque

 

tailf:link target

This statement specifies that the data node should be implemented as a link to another data node, called the target data node. This means that whenever the node is modified, the system modifies the target data node instead, and whenever the data node is read, the system returns the value of target data node.

Note that if the data node is a leaf, the target node MUST also be a leaf, and if the data node is a leaf-list, the target node MUST also be a leaf-list.

Note that the type of the data node MUST be the same as the target data node. Currently the compiler cannot check this.

Using link inside a choice is discouraged due to the limitations of the construct. Updating the target of the link does not affect the active case in the source.

Example:

container source {
  choice source-choice {
    leaf a {
      type string;
      tailf:link "/target/a";
    }
    leaf b {
      type string;
      tailf:link "/target/b";
    }
  }
}

container target {
  choice target-choice {
    leaf a {
      type string;
    }
    leaf b {
      type string;
    }
  }
}

Setting /target/a will not activate the case of /source/a. Reading the value of /source/a will not return a value until the case is activated. Setting /source/a will activate both the case of /source/a and /target/a.

The argument is an XPath absolute location path. If the target lies within lists, all keys must be specified. A key either has a value, or is a reference to a key in the path of the source node, using the function current() as starting point for an XPath location path. For example:

/a/b[k1='paul'][k2=current()/../k]/c

The link statement can be used in: leaf and leaf-list.

The following substatements can be used:

tailf:inherit-set-hook This statement specifies that a 'tailf:set-hook' statement should survive through symlinks. If set to true a set hook gets called as soon as the value is set via a symlink but also during commit. The normal behaviour is to only call the set hook during commit time. 
Highlighted

I tried using tailf:link to assign first node data to other node. 

        container IOSXR {
          when "/ncs:devices/ncs:device[ncs:name=current()/../Switch]/ncs:platform/ncs:name='ios-xr'";
          list GigabitEthernet {
            key "GigabitEthernet";
            leaf GigabitEthernet {
              tailf:info "GigabitEthernet Interface ID";
              mandatory true;
              type leafref {
                path "deref(../../../Switch)/../ncs:config/cisco-ios-xr:interface/cisco-ios-xr:GigabitEthernet/cisco-ios-xr:id";
              }
            }
            uses Trunk;
          }

Using above code for leaf GigabitEthernet, I can have drop-down list of interfaces.

Let say if i have selected "0/0/0/0"... I want to use the same node data "0/0/0/0" to other leaf "intf-number"

 

        grouping Trunk {
          list BD-ID {
            key "bridge-domain-id";
            leaf bridge-domain-id {
              tailf:info "Bridge Domain ID";
              mandatory true;
              type uint32 {
                range "1..65535";
              }
            }
	leaf intf-number {
              tailf:info "GigabitEthernet Interface ID";
              mandatory true;
              type leafref {
                path "deref(../../../../../../Switch)/../ncs:config/cisco-ios-xr:interface/cisco-ios-xr:GigabitEthernet/cisco-ios-xr:id";
              }
            }
            leaf Bridge-Domain-Description {
              tailf:info "Interface Description";
              type string {
                tailf:info "LINE;;Up to 50 characters describing this interface";
                length "0..50";
              }
            }
          }
        }

I tried below code ...

 

leaf intf-number {
 {
tailf:link "/ncs:devices/ncs:device[name=current()/../../../Switch]/ncs:config/cisco-ios-xr:interface/GigabitEthernet[id=current()/cisco-ios-xr:id]";
tailf:info "GigabitEthernet Interface ID"; mandatory true; type leafref { path "deref(../../../../../../Switch)/../ncs:config/cisco-ios-xr:interface/cisco-ios-xr:GigabitEthernet/cisco-ios-xr:id"; } }

but facing below error.

yang/my-service.yang:324: error: the node 'GigabitEthernet' from module 'my-service' (in node 'interface' in module 'tailf-ned-cisco-ios-xr' from 'tailf-ned-cisco-ios-xr') is not found

 

How can i use the any leaf (node) data for other leaf (node) using YANG modeling....like below;

 

GigabitEthernet=0/0/0/0

inft-number=GigabitEthernet

 

Someone please suggest.

 

Regards,

BMork

Highlighted

Anyone please suggest. Thanks 

Regards,

Bjron