sysrepo-archive / yang

YANG modules developed for the use with sysrepo datastore
3 stars 0 forks source link

How to fill augmented model parameter using libyang in sysrepo #1

Open Neeraj0019 opened 3 years ago

Neeraj0019 commented 3 years ago

Hi, I have a model which augments ietf-harware model by adding some additional fields to the hardware component.

augment "/hw:hardware/hw:component" { when "(derived-from-or-self(hw:class, 'o-ran-hw:O-RAN-RADIO')) or (derived-from-or-self(hw:class, 'o-ran-hw:O-RAN-HW-COMPONENT'))"; description "New O-RAN parameters for o-ran hardware";

leaf product-code { type string; config false; mandatory true; description "O-RAN term that is distinct from model-name in ietf-hardware."; }

Now I want to fill this "product-code" value inside my sysrepo plugin. I tried below 2 ways but its not working. Same way i am able to get the data for ietf-harware specific parameters.

  1. lyd_new_leaf(oruComp,NULL,"product-code xmlns=\"urn:o-ran:hardware:1.0\"",get_product_code());

  2. lyd_new_leaf(oruComp,NULL,"o-ran-hw:product-code",get_product_code());

some other augmented node were added using sysrepocfg edit command and that works(able to get it via netopeer-cli option).

O-RU o-ran-hw:O-RAN-RADIO 0 O-RU
Neeraj0019 commented 3 years ago

Tried with below option... seems to work. lyd_new_leaf(oruComp,ly_ctx_get_module(sr_get_context(sr_session_get_connection(session)),"o-ran-hardware",NULL,1), "product-code", get_product_code());

But is this the right way to do it for augmented nodes?