cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
259
Views
0
Helpful
3
Replies
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

Everyone's tags (2)
3 REPLIES 3
Highlighted
Beginner

Re: Fetch and display Interface Description

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";
      }
    }

 

Cisco Employee

Re: Fetch and display Interface Description

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?

Cisco Employee

Re: Fetch and display Interface Description

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.