cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1966
Views
15
Helpful
8
Replies

Selecting a NED-ID in a service or an action

lweddewer
Level 5
Level 5

Hello,

I want to select a specific ned-id of the Cisco-IOS NED in a service and an action.
Found this pattern:

 

leaf default-ned-id {
    type string;
    tailf:non-strict-leafref {
       path "/ncs:packages/ncs:package/ncs:name";
    }
    must "starts-with(.,'cisco-ios-cli')";
}

This works fine in the service.

 

When using this in input of a action this doesn't work.

 

I've also tryed to find a workaround by using a pattern for the string but it looks like it is not possible to combine string pattern and tailf:non-strict-leafref! Is that "works at designed?"

 

Using NSO 5.2.1.2.

 

Regards

Lothar

8 Replies 8

tsiemers1
Spotlight
Spotlight

Looks like an open issue with yang 1.1

 

http://svn.tools.ietf.org/svn/wg/netmod/yang-1.1/issues.html#sec-3

 

Can't find if it was ever moved from REVIEW to DONE. I wasn't able to get it to work with action input as well so thinking its still in REVIEW.

gmuloche
Cisco Employee
Cisco Employee

Hello,

 

Looking at RFCs it looks like it made it to the standard (at least in the RPC section and the Notification section):

YANG 1.0: https://tools.ietf.org/html/rfc6020#section-7.13.2

YANG 1.1: https://tools.ietf.org/html/rfc7950#section-7.14.2

 

The new action sectionhttps://tools.ietf.org/html/rfc7950#section-7.15 uses input/output from the RCP section so similarly I am led to understand that it should be supported.

 

If you look inside your NSO install you can get the man page for ncsc and at the end you have a section about YANG 1.1 support (NSO 5.2.1.2 example below):

user@server# man ncsc
[... truncated...] YANG 1.1 NCS supports YANG 1.1, as defined in RFC 7950, with the following exceptions: o Type empty in unions and in list keys is not supported. o Type leafref in unions are not validated, and treated as a string internally. o anydata is not supported. o The new scoping rules for submodules are not implemented. Specifically, a submodule must still include other submodules in order to access definitions defined there. o The new XPath functions derived-from() and derived-from-or-self() can only be used with literal strings in the second argument. o Leafref paths without prefixes in top-level typedefs are handled as in YANG 1.

I have made a dummy action (NSO 5.2.1.2) to try this out (notice the use of yang-version 1.1 at the top):

 

module must-input-action-1-1 {

  yang-version 1.1;
  namespace "http://example.com/must-input-action-1-1";
  prefix must-input-action-1-1;

  import ietf-inet-types {
    prefix inet;
  }
  import tailf-common {
    prefix tailf;
  }
  import tailf-ncs {
    prefix ncs;
  }

  description
    "Bla bla...";

  revision 2016-01-01 {
    description
      "Initial revision.";
  }

  container action {
    tailf:action double {
      tailf:actionpoint must-input-action-1-1-action;
      input {
        leaf test {
          type string;
          must "starts-with(., 'TEST')";
        }
      }
      output {
        leaf result {
          type string;
        }
      }
    }
  }
}

And when I try it in the CLI:

 

admin@ncs# action double test SOMETHING
Error: 'action double test' (value "SOMETHING"): the 'must' expression "starts-with(., 'TEST')" failed
admin@ncs# action double test TEST
result TEST_TEST

So it seems to be working here..

 

Maybe that can help ?

 

Regards

rogaglia
Cisco Employee
Cisco Employee

Just adding to this thread, I took the simple-mpls-vpn example where device/name is a leafref to the device name and got this to work in a teamplate:

 

<?if {derived-from-or-self(deref(device)/../ncs:device-type/ncs:cli/ncs:ned-id,'cisco-ios-cli:cisco-ios-cli') ?>

 

This matches any cisco-ios-cli NED.

Now in NSO5.8, a new option was added too " if-ned-id-match" where you can use a regexp.

 

Hi Roque

Can you please give an example for the "if-ned-id-match"? Whatever I do, I always get an error

Invalid parameters for processing instruction if-ned-id-match

It must be within the devices config in the template /devices/device/config subtree then defined in the package-meta. 


The if-ned-id-match and elif-ned-id-match processing instructions work similarly to if-ned-id and elif-ned-id but they accept a regular expression as argument instead of a list of ned-ids. The regular expression is matched against all of the ned-ids supported by the package. If the if-ned-id-match processing instruction is nested inside of another if-ned-id-match or if-ned-id processing instruction, then the regular expression will only be matched against the subset of ned-ids matched by the encompassing processing instruction. The if-ned-id-match and elif-ned-id-match processing instructions are only allowed inside a device's mounted configuration subtree rooted at /devices/device/config.

Template (https://developer.cisco.com/docs/nso/guides/#!templates)

 

<?xml version="1.0"?>
<config-template xmlns="http://tail-f.com/ns/config/1.0">
  <devices xmlns="http://tail-f.com/ns/ncs">
    <device>
      <name>{/device}</name>
      <config>
       <?if-ned-id-match <REGEX>?>
        <vrf xmlns="urn:ios">
          <definition>
            <name>{/vrf/name}</name>
            <rd>{/vrf/rd}</rd>
          </definition>
        </vrf>
        <?end?>
      </config>
    </device>
  </devices>
</config-template>

 

 

package-meta.xml (https://developer.cisco.com/docs/nso/guides/#!nso-6-0-development-guide-nso-packages/the-package-meta-data-xml-file)

  • <supported-ned-id-match>router-nc-1.\d+:router-nc-1.\d+</supported-ned-id-match>

Nabsch
Spotlight
Spotlight

Hello ,

 

if you are using NSO 5.4 and later . You can use supported-ned-id. You need to specify list of the  supported-bed-is in the package-meta-data.xml

Hi Nabil

I also need to specify list of supported-ned-ids in the package-metadata.xml file. But I could not find any documentation that would give me an example/syntax how to add that piece of information. Could you please share an example?

Thanks

Hello , 

 

Here an example

 

<ncs-package xmlns="http://tail-f.com/ns/ncs-packages">
<name>l3vpn</name>
<package-version>1.0</package-version>
<description>Skeleton for a resource facing service - RFS</description>
<ncs-min-version>3.0</ncs-min-version>
<supported-ned-id xmlns:cisco-ios-cli-3.0="http://tail-f.com/ns/ned-id/cisco-ios-cli-3.0">cisco-ios-cli-3.0:cisco-ios-cli-3.0</supported-ned-id>
<supported-ned-id xmlns:cisco-ios-cli-3.8="http://tail-f.com/ns/ned-id/cisco-ios-cli-3.8">cisco-ios-cli-3.8:cisco-ios-cli-3.8</supported-ned-id>
<supported-ned-id xmlns:cisco-iosxr-cli-3.0="http://tail-f.com/ns/ned-id/cisco-iosxr-cli-3.0">cisco-iosxr-cli-3.0:cisco-iosxr-cli-3.0</supported-ned-id>
</ncs-package>

It should be something like 

 

<supported-ned-id xmlns:$NED-ID="http://tail-f.com/ns/ned-id/$NED-ID">$NED-ID:$NED-ID</supported-ned-id>

 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community: