To retrieve configured data in operational mode

Hi,

I have done yang model to configure a particular component in a system. For Eg:
container computer {
leaf monitor {
type string;
}
leaf mouse {
type string;
}
leaf keyboard {
type string;
}
}
So, I am configuring a PC by using above yang model in configuration mode and committed to cdb.

Then, I need to retrieve the data of configured PC in operational mode of confd.

How this can be achieved??

Any idea…please suggest…

Thanks in advance,
Banumoorthy M

Hi Banumoorthy,

You can’t dynamically change your YANG module from configuration to operational data.

If you are doing it just for development purpose in order to test out having some operational data in CDB without writing code, you can do the following:

Initial YANG model with configuration data:

$ cat pc.yang
module pc {
  namespace "http://tail-f.com/ns/example/pc";
  prefix pc;

  container computer {
    leaf monitor {
      type string;
    }
    leaf mouse {
      type string;
    }
    leaf keyboard {
      type string;
    }
  }
}

You can build the above YANG model with confdc and then start confd with the pc.fxs file. You can then use a cli session to configure the test data and save the configuration file in xml format as follows:

admin connected from 127.0.0.1 using console on WAITAI-M-K092
WAITAI-M-K092# show running-config computer 
% No entries found.
WAITAI-M-K092# config 
Entering configuration mode terminal
WAITAI-M-K092(config)# computer keyboard abc monitor def mouse ghi
WAITAI-M-K092(config)# commit
Commit complete.
WAITAI-M-K092(config)# save pc-init.xml xml computer 
Saving parts of the configuration.
WAITAI-M-K092(config)# exit
WAITAI-M-K092# exit
$ cat pc-init.xml
<config xmlns="http://tail-f.com/ns/config/1.0">
  <computer xmlns="http://tail-f.com/ns/example/pc">
    <monitor>def</monitor>
    <mouse>ghi</mouse>
    <keyboard>abc</keyboard>
  </computer>
</config>

You can now modify the YANG model to make the data operational as follows:

$ cat pc.yang
module pc {
namespace "http://tail-f.com/ns/example/pc";
prefix pc;

container computer {
  config false;
  leaf monitor {
    type string;
  }
  leaf mouse {
    type string;
  }
  leaf keyboard {
    type string;
  }
}
}

Recompile this new YANG model and restart confd with it. You can now load the initial operational data into CDB with the confd_load command as follows:

admin connected from 127.0.0.1 using console on WAITAI-M-K092
WAITAI-M-K092# show computer 
% No entries found.

$ confd_load -C pc-init.xml 

admin connected from 127.0.0.1 using console on WAITAI-M-K092
WAITAI-M-K092# show computer 
computer monitor def
computer mouse ghi
computer keyboard abc
WAITAI-M-K092#

You can now retrieve the data from ConfD as operational data.

Regards,

Wai

Hi Wai,

Thank you for your reply…

I got answer for my question from your reply…

Thanks,
Banumoorthy M

Hi wai,

I have followed the steps you have given…

After changing the node to config fasle,
I am getting CDB boot error, while starting confd with respect to my computers.xml, saying that
CDB boot error: failed to load ./var/confd/cdb/computers.xml:1: object is not writable: /test123:computers Daemon died status=10

Thanks in advance,
Banumoorthy M

Hi Banumoorthy,

You will not be able to preload operational data using your computers.xml file at ConfD startup time. You need to use the confd_load command with the -C option I have shown in my previous posting to load operational data into CDB after ConfD has been started.

Regards,

Wai

Thank you wai for your kind reply…