From 0296f70f07fb536e9ed52884ce373cb4bdb5bfe3 Mon Sep 17 00:00:00 2001 From: Leandro Lisboa Penz Date: Tue, 3 Jan 2017 15:52:22 +0000 Subject: [PATCH] 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 --- lib/ansible/modules/network/netconf/netconf_config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/network/netconf/netconf_config.py b/lib/ansible/modules/network/netconf/netconf_config.py index 7ed79a908b5..5955063085f 100755 --- a/lib/ansible/modules/network/netconf/netconf_config.py +++ b/lib/ansible/modules/network/netconf/netconf_config.py @@ -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)