Don't use netconf's discard_changes when the device has no candidate cap (#19626)

The discard_changes netconf RPC requires the candidate capability.
We were getting an exception when configuring that kind of device.

Fixes #19529
This commit is contained in:
Leandro Lisboa Penz 2017-01-03 15:52:22 +00:00 committed by Peter Sprygada
parent c58278b1c2
commit 0296f70f07

View file

@ -136,7 +136,8 @@ def netconf_edit_config(m, xml, commit, retkwargs):
datastore = 'running'
m.lock(target=datastore)
try:
m.discard_changes()
if ":candidate" in m.server_capabilities:
m.discard_changes()
config_before = m.get_config(source=datastore)
m.edit_config(target=datastore, config=xml)
config_after = m.get_config(source=datastore)