ConfD User Community

Value update on CDB

Hello experts,

In my case i need to update the value in CDB.

EX:
hosts HH ip 10.0.0.2 netmask 255.255.255.0 ==> in running config

Here i need to update IP address from 10.0.0.2 to some what xx.xx.xx.xx.

Can any one please share your ideas on that

Thanks

Using what northbound interface? C-style CLI? NETCONF? MAAPI? etc.

Using Mappi i want to achieve that

Guessing here since you did not post the YANG model, but if the “IP address” is a key in the list “HH” you can use maapi_move() for that. See the confd_lib_maapi(3) man page for details.

This is my yang model.

list hosts {
tailf:callpoint trans-hosts {
tailf:transaction-hook subtree {
tailf:invocation-mode per-transaction;
}
}
key name;
leaf name {
type string;
}
leaf ip {
tailf:callpoint ip-mask {
tailf:set-hook node;
}
type inet:ipv4-address;
}
leaf netmask {
tailf:callpoint ip-mask {
tailf:set-hook node;
}
type inet:ipv4-address;
}

}

Using this am getting the input from user as
host test ip 10.0.0.4 netmask 255.255.255.0

I will make some calculation with netmask and ip in my python script. After that I need to replace the
host test ip 10.0.0.4 netmask 255.255.255.0 with my calculated ip adddress in the running-config

Thanks

There is a bunch of Python code examples on this site showing how to do stuff like that; I guess a good start are Jason’s Maagic Examples, in particular those using the single_write_trans function might be relevant for you (note he uses ncs API - but that is pretty much identical to confd, just replace ncs with confd in his code). ConfD distribution also contains several examples showing how to talk to ConfD from Python.