cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2681
Views
0
Helpful
3
Replies

NSO: When statement with xpath on yang file

Maurizio Bau
Level 1
Level 1

Hi All

 

i want to deploy a Yang file on NSO service with following schema

- IF DeviceA are IOS TYPE, then 1 container; 

I tried with the following pattern

when "/ncs:devices/ncs:device[ncs:name=current()/../deviceA]/ncs:platform/ncs:name = 'ios'";

but when I launch the make command, i've this logs

[nso@itminso src]$ make
/home/nso/NSO-4.3.6/bin/ncsc `ls OPM-IF-ann.yang > /dev/null 2>&1 && echo "-a OPM-IF-ann.yang"` \
-c -o ../load-dir/OPM-IF.fxs yang/OPM-IF.yang
yang/OPM-IF.yang:15: error: module 'tailf-ned-cisco-ios' not found
yang/OPM-IF.yang:19: error: module 'tailf-ned-cisco-ios-xr' not found
yang/OPM-IF.yang:53: error: the node 'deviceA' from module 'OPM-IF' (in node 'services' from 'tailf-ncs') is not found
yang/OPM-IF.yang:56: error: the node 'interface' from module 'tailf-ned-cisco-ios' (in node 'config' from 'tailf-ncs') is not found

 

Any Idea?

Thanks for all support

Maurizio

 

import tailf-ned-cisco-ios {
    prefix ios;
}   

  import tailf-ned-cisco-ios-xr {
    prefix cisco-iosxr;
}

augment /ncs:services {
list OPM-IF {
key name;

uses ncs:service-data;
ncs:servicepoint "OPM-IF";

leaf name {
type string;
}

// Scelta del Device.
leaf deviceA {
type leafref {
path "/ncs:devices/ncs:device/ncs:name";
}
}

leaf vlan-id {
     tailf:info "VLAN ID";
      mandatory true;
      type int32 {
        range "2 .. 4094" {
          error-message "Invalid value for VLAN ID";
        }
      }
   }
// Sezione Interfaccia
  choice interfaceA {
        case ios {
when "/ncs:devices/ncs:device[ncs:name=current()/../deviceA]/ncs:platform/ncs:name = 'ios'";
// /devices/device[name='IOS-CO']/platform/name ios
          leaf Giga_ios {
            type leafref {
              path "/ncs:devices/ncs:device[ncs:name=current()/../deviceA]/ncs:config/ios:interface/ios:GigabitEthernet/ios:name";
            }
          }
        }
case ios-xr {
when "/ncs:devices/ncs:device[ncs:name=current()/../deviceA]/ncs:platform/ncs:name = 'ios-xr'";
          leaf Giga_xr {
            type leafref {
              path "/ncs:devices/ncs:device[ncs:name=current()/../deviceA]/ncs:config/cisco-iosxr:interface/cisco-iosxr:GigabitEthernet/cisco-iosxr:id";
            }
          }
        }
      }

}
3 Replies 3

Jan Lindblad
Cisco Employee
Cisco Employee

There are two issues here. The first one is in the Makefile (which you are not showing). You need to add to the YANGPATH so that the compiler can find the modules you are importing. In a standard NSO example Makefile, you can add at the top (for each NED you are importing):

YANGPATH += ../../<ned-name>/src/ncsc-out/modules

 

The other problem is that the when expression path to deviceA is incorrect. You need to remove ../ after your call to current. I know this may not be completely intuitive, but choice and case don't count as data nodes (do a get-config and see for yourself).

when "/ncs:devices/ncs:device[ncs:name=current()/deviceA]/ncs:platform/ncs:name = 'ios'";

 

Hi Jan

 

thanks for your replay.

I corrected makefile and yang file, please see the attached rar files for check.

My neds folder are showed in the following screen schot

Ned Folder.jpg

When i re-try make command, following error

 

[nso@itminso src]$ make
/home/nso/NSO-4.3.6/bin/ncsc  `ls OPM-IF-ann.yang  > /dev/null 2>&1 && echo "-a OPM-IF-ann.yang"` \
             --yangpath ../../cisco-ios/src/ncsc-out/modules/yang --yangpath ../../cisco-ios-xr/src/yang -c -o ../load-dir/OPM-IF.fxs yang/OPM-IF.yang
../../cisco-ios/src/ncsc-out/modules/yang/tailf-ned-cisco-ios.yang:114976: warning: when tailf:cli-drop-node-name is given, it is recommended that tailf:cli-suppress-mode is used in combination. using tailf:cli-drop-nodename in a list child without using tailf:cli-suppress-mode on the list, might lead to confusing behaviour, where the user enters the submode without being able to give further configuration.
../../cisco-ios/src/ncsc-out/modules/yang/tailf-ned-cisco-ios.yang:124245: warning: when tailf:cli-drop-node-name is given, it is recommended that tailf:cli-suppress-mode is used in combination. using tailf:cli-drop-nodename in a list child without using tailf:cli-suppress-mode on the list, might lead to confusing behaviour, where the user enters the submode without being able to give further configuration.
yang/OPM-IF.yang:19: error: module 'tailf-ned-cisco-iosxr' not found
yang/OPM-IF.yang:65: error: the node 'interface' from module 'tailf-ned-cisco-iosxr' (in node 'config' from 'tailf-ncs') is not found
make: *** [../load-dir/OPM-IF.fxs] Error 1
[nso@itminso src]$ 

Do you any idea?

Thanks a lot

Maurizio

Hi Jan and Hi All
i found a solution about Jan's indication and in particular
- Correct yang xpath statement on when condition
- Insert in a make file following section
...
YANGPATH += /home/nso/NSO-4.3.6/packages/neds/cisco-ios/src/yang \
/home/nso/NSO-4.3.6/packages/neds/cisco-iosxr/src/yang \
/home/nso/NSO-4.3.6/packages/neds/cisco-ios/src/ncsc-out/modules/yang \
/home/nso/NSO-4.3.6/packages/neds/cisco-iosxr/src/ncsc-out/modules/yang

....

With this section, when i lanch a make command, i've more warning but nothing error and the packages work fine.

Thanks Jan
Bye
Maurizio
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: