cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2045
Views
2
Helpful
9
Replies

Using deref() to pull interfaces from the CDB after indicating a device

Andrew Horrigan
Cisco Employee
Cisco Employee

I am attempting to use deref() to generate a list of interfaces based on a previously selected device in the same service model.  Once the users select a device (which is another leafref), I want to pull the list of interfaces from the CDB and present them to the user for a second leafref using deref().  However, I am unable to get past a "make" because it keeps on resulting in:

error: bad argument value "deref()", should be of type path-arg

Obviously, either my deref is not correct or I am trying to pull the information from the wrong spot in the CDB.  Here is the relevent part of the service model:

module cspOnboard {

  namespace "http://example.com/cspOnboard";

  prefix cspOnboard;

  import ietf-inet-types {

    prefix inet;

  }

  import tailf-common {

    prefix tailf;

  }

  import tailf-ncs {

    prefix ncs;

  }

  description

    "Service to initiate VNF spinup on CSP2100";

  revision 2017-08-28 {

    description

      "Initial revision.";

  }

  augment /ncs:services {

  list cspOnboard {

    description "This is the CSP2100 VNF Onboarding Service";

    key name;

    leaf name {

      tailf:info "Unique Service Name";

      tailf:cli-allow-range;

      type string;

    }

    uses ncs:service-data;

    ncs:servicepoint cspOnboard-servicepoint;

    leaf csp-device {

      type leafref {

        path "/ncs:devices/ncs:device/ncs:name";

      }

      mandatory true;

    }

    // Service Instance onboard multiple VNFs

[...]

    list vnf-onboard {

      leaf vnic1-int {

        type leafref {

          path "deref(../csp-device)/ncs:config/";

        }

        mandatory true;

      }

      leaf vnic1-vlan {

        type uint16 {

            range 0..4096;

        }

      }

In the CDB, I am trying to get this information available to the user as options:

admin@ncs# show running-config devices device SAE-CSP1 config pnic  

devices device SAE-CSP1

config

  pnic enp10s0

   type ethernet

   sr-iov totalvfs 0

   lldp enabled

  !

  pnic enp129s0f0

   type      ethernet

   member_of po21

   sr-iov totalvfs 63

   lldp      enabled

  !

  pnic enp129s0f1

   type      ethernet

   member_of po21

   sr-iov numvfs 0

   sr-iov totalvfs 63

   sr-iov switchmode veb

   lldp      enabled

Could someone instruct me on where I am going wrong?  Thanks!

1 Accepted Solution

Accepted Solutions

Hi,

The syntax, as Ryan indicated, should be a path to the complete list that you want to filter from, and then a must statement that will filter on that list.

My only comment would be that in your statements instead of pnics:pnic, you'd probably need to use pnics:pnic/pnics:name or pnics:id (or whatever is the name of the key leaf. I don't know the model, but this needs to point to the leaf under the pnic list which is the key of that list).

Yftach

View solution in original post

9 Replies 9

ryan-hitch
Level 4
Level 4

Looks similar to what I was just trying to do here constrain list of devices associated with site

Try something like this:

leaf vnic1-int {

  type leafref {

    path "/ncs:devices/ncs:device/ncs:config/ncs:pnic";

  }

  must "current() = deref(current()/../csp-device)/../ncs:config/ncs:pnic";

}

My issue, is that no matter configuration (even the suggestion above), I cannot successfully issue a make.  Looking back, my explanation was a little convoluted, so let me try this again:

I am trying to pull the pnics into the service model as shown in the following information:

admin@ncs# show running-config devices device sae-csp2 config pnic

devices device sae-csp2

config

  pnic enp10s0

  type ethernet

  sr-iov totalvfs 0

  lldp enabled

  !

[…]

  pnic enp129s0f0

  type ethernet

  sr-iov numvfs 63

  sr-iov totalvfs 63

  sr-iov switchmode veb

  lldp enabled


In the existing YANG model, I ask them for their csp-device:

    leaf csp-device {

      type leafref {

        path "/ncs:devices/ncs:device/ncs:name";

      }

      mandatory true;

  }


My goal is to take their “answer” for csp-device and then use that to pull the right configs from the NSO CDB.

I have tried this:

      leaf vnic1-int {

        type leafref {

          path "/ncs:devices/ncs:device/deref(../csp-device)/ncs:config/pnics:pnic";

        }

      }


And this:

      leaf vnic1-int {

        type leafref {

          path "deref(../csp-device)/ncs:config/pnics:pnic";

        }

      }


However, neither is working.  Whenever I try to compile the service model, I get the following error:

[root@sae-nso src]# make

mkdir -p ../load-dir

mkdir -p java/src//

make: Warning: File `yang/cspOnboard.yang' has modification time 209 s in the future

/root/nso-4.5/bin/ncsc  `ls cspOnboard-ann.yang  > /dev/null 2>&1 && echo "-a cspOnboard-ann.yang"` \

              -c -o ../load-dir/cspOnboard.fxs yang/cspOnboard.yang

yang/cspOnboard.yang:109: error: bad argument value "deref(../csp-device)/ncs:config/pnics:pnic", should be of type path-arg

make: *** [../load-dir/cspOnboard.fxs] Error 1

[root@sae-nso src]#

Thoughts?  Thanks!

Hi,

The syntax, as Ryan indicated, should be a path to the complete list that you want to filter from, and then a must statement that will filter on that list.

My only comment would be that in your statements instead of pnics:pnic, you'd probably need to use pnics:pnic/pnics:name or pnics:id (or whatever is the name of the key leaf. I don't know the model, but this needs to point to the leaf under the pnic list which is the key of that list).

Yftach

Thanks for the advice.  I was using pnics:pnic because of the way it was displayed in the NSO GUI, but honestly, I am not entirely sure how to reference this in the xpath ...

I have the following, but now I am getting a namesapce error:

    leaf vnic1-pnic {

      type leafref {

path "/ncs:devices/ncs:device/ncs:config/pnics:pnic/pnic:name";

      }

      must "current() = deref(current()/../csp-device)/../pnics:pnic/pnic:name";

    }

[root@sae-nso src]# make

make: Warning: File `yang/cspOnboard.yang' has modification time 125 s in the future

/root/nso-4.5/bin/ncsc  `ls cspOnboard-ann.yang  > /dev/null 2>&1 && echo "-a cspOnboard-ann.yang"` \

              -c -o ../load-dir/cspOnboard.fxs yang/cspOnboard.yang

yang/cspOnboard.yang:109: error: XPath error: Invalid namespace prefix: pnics

yang/cspOnboard.yang:111: error: XPath error: Invalid namespace prefix: pnics

make: *** [../load-dir/cspOnboard.fxs] Error 1

Here is what I am trying to access in the GUI:

Screen Shot 2017-12-12 at 5.12.53 PM.png

And here is the model:

module pnic {

  namespace "http://www.cisco.com/ns/test/pnic";

  prefix pnic;

  import tailf-common {

      prefix tailf;

  }

 

  organization "Cisco Systems, Inc.";

  revision 2015-04-30 {

      description "Initial release";

  }

  container pnics {

    tailf:cli-drop-node-name;

    list pnic {

      key name;

[...]

Have you imported the pnic module in the cspOnboard module?

e.g. something like:

import pnic {

prefix pnic;

}

I have not ... because it is part of another NED.  I did try to put the import prefix into the yang, but it cannot find the module.

If it wasn't obvious, I am a bit new to this!

Just to update the thread here, I was able to get my deref() working (with some help) by making a few different changes.

Here is the final, working code:

    leaf vnic1-pnic {

      type leafref {

path "deref(../../csp-device)/../ncs:config/pnic:pnics/pnic:pnic/pnic:name"; 

      }

    }

The two other things necessary were importing the pnic module and adding a PATH to the Makefile in /src, pointing to the location of the YANG files for the CSP NED being used for the pnic information.

YANGPATH += ../../csp2100-netconf/src/ncsc-out/modules/yang

I am not running into a different, but semi-related problem.  I am using the same method to grab a different list of items from the same CSP, and for w/e reason, NSO is only displaying 1 option, as opposed to the 2 listed on the box.

CSP CLI:

resource csp-2100

ip_address          10.1.60.22

netmask             255.255.255.0

default_gw          10.1.60.1

[...]

num_service         8

rsyslog_udp_only    false

log_severity        info

storage SVS-NFV-NFS1

  storagetype            nfs

  storage_space_total_gb 200.0

  server_ip              10.1.60.251

  server_path            /var/SVS-NFV-NFS1

!

storage SAE-NFS

  storagetype            nfs

  storage_space_total_gb 200.0

  server_ip              10.1.60.251

  server_path            /var/SAE-NFS

!

!

My YANG looks very similar to the one used for the pnics:

      leaf nfs-name {

        type leafref {

      path "deref(../../csp-device)/../ncs:config/resource:resources/resource:resource/resource:storagelist/resource:storage/resource:mount_name";

        }

      }

However, this is what shows up in the GU for pnics vs nfs-name:

Screen Shot 2017-12-17 at 9.50.24 AM.pngScreen Shot 2017-12-17 at 9.50.17 AM.png

Could you enable NETCONF tracing for the device, run sync-from and share the resulting log with me?

The device was sync'd properly =(  Sorry for the confusion!