Skip to content

Commit 7ebbe7c

Browse files
fixes for commit in candidate datastore
Signed-off-by: rohitthakur2590 <rohitthakur2590@outlook.com>
1 parent 92f79a6 commit 7ebbe7c

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

plugins/module_utils/network/netconf/netconf.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,3 @@ def sanitize_xml(data):
132132
if key not in IGNORE_XML_ATTRIBUTE:
133133
attribute.pop(key)
134134
return to_text(tostring(tree), errors="surrogate_then_replace").strip()
135-
136-
def copy_config(module, source, target):
137-
conn = get_connection(module)
138-
try:
139-
response = conn.copy_config(source=source, target=target)
140-
except ConnectionError as e:
141-
module.fail_json(msg=to_text(e, errors="surrogate_then_replace").strip())
142-
return response
143-

plugins/modules/netconf_config.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ def main():
493493
save = module.params["save"]
494494
filter = module.params["get_filter"]
495495
format = module.params["format"]
496+
commit = module.params["commit"]
496497

497498
try:
498499
filter_data, filter_type = validate_and_normalize_data(filter)
@@ -598,7 +599,7 @@ def main():
598599
conn.validate(target)
599600
if source:
600601
if not module.check_mode:
601-
conn.copy_config(source, target)
602+
conn.copy(source, target)
602603
result["changed"] = True
603604
elif delete:
604605
if not module.check_mode:
@@ -689,6 +690,18 @@ def main():
689690
"before": sanitized_before,
690691
"after": sanitized_after,
691692
}
693+
elif not config and commit:
694+
if not module.check_mode:
695+
confirm_timeout = confirm if confirm > 0 else None
696+
commit_rpc = f"""
697+
<commit xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
698+
<confirmed/>
699+
<confirm-timeout>{confirm_timeout}</confirm-timeout>
700+
</commit>
701+
"""
702+
response = conn.dispatch(commit_rpc.strip())
703+
else:
704+
conn.discard_changes()
692705

693706
except ConnectionError as e:
694707
module.fail_json(msg=to_text(e, errors="surrogate_then_replace").strip())

0 commit comments

Comments
 (0)