akarneliuk / pygnmi

The pure Python implementation of the gNMI client.
https://training.karneliuk.com
BSD 3-Clause "New" or "Revised" License
129 stars 44 forks source link

PYGNMI commit replace is not replacing the running config . #147

Closed dnaiga closed 8 months ago

dnaiga commented 9 months ago

Hi team ,

Observed that PYGNMI commit replace method is not replacing the running config of the node. Replace operation just replacing leaf config not the running config. When the additional config is given config is applied successfully where as removing some of the config from the running config and applying the replace is not actually happening.

Thank you .

sai1274 commented 9 months ago

Hey @dnaiga When you try to replace at a leaf level. It just updates the leaf value. But when you try to replace at a container level with leaf value then it will replace whole container config, and you will be left with only leaf value.

gnmiclient.set(prefix="openconfig-system://",replace=[("openconfig-system:system/config",{"hostname":"test"})])

The above one just replaces the leaf config

gnmiclient.set(prefix="openconfig-system://",replace=[("openconfig-system:system",{"config":{"hostname":"test",}})])

But the above statement replaces everything at node level to default values and sets the hostname to test

akarneliuk commented 8 months ago

Thanks @sai1274 for examples and explanation.

@dnaiga could you please test and confirm?

dnaiga commented 8 months ago

Hi Sai,

Thanks for your response, Yes the above config works for me . But i want to know more on , how can we replace the container with empty value so the config is removed from testbed.

As of now , though we don't send the any particular container in the json request (eg:openconfig-system:system), expecting the running config should be replaced with sent json request so that particular container (openconfig-system:system) which is not present in the json request is replaced (removed) from testbed.

currently which not happening , json request (openconfig-system:system) still remains on the testbed not removed .

Please let us know if anyway we can achieve it .

Thanks , Divya

sai1274 commented 8 months ago

Hey @dnaiga So your saying that gnmiclient.set(prefix="openconfig-system://",replace=[("openconfig-system:system",{})]) is not replacing the whole configuration right? If it's not working in ur case instead of replaces you can delete the container config itself gnmiclient.set(prefix="openconfig-system://",delete=["openconfig-system:system"]) something like this

rao-aneesh commented 8 months ago

@dnaiga gNMI replace operation is not the same as a commit replace operation. gNMI replace only replaces the configuration under the origin you have provided, not the whole running configuration.

dnaiga commented 8 months ago

Thank you Sai and AscendedEntity, got it clarified taht "gNMI replace operation is not the same as a commit replace operation."

Yes able to delete the config via delete operation !!.

Thanks , Divya