mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 20:31:27 -07:00
Update junos cliconf plugin (#43643)
* Update junos cliconf plugin Fixes #39056 Refactor junos cliconf plugin api and other minor changes * Fix CI issue * Fix CI failure
This commit is contained in:
parent
2aaa1694ab
commit
35adc12c38
6 changed files with 146 additions and 28 deletions
|
@ -101,6 +101,11 @@ def get_capabilities(module):
|
|||
return module._junos_capabilities
|
||||
|
||||
|
||||
def is_netconf(module):
|
||||
capabilities = get_capabilities(module)
|
||||
return True if capabilities.get('network_api') == 'netconf' else False
|
||||
|
||||
|
||||
def _validate_rollback_id(module, value):
|
||||
try:
|
||||
if not 0 <= int(value) <= 49:
|
||||
|
@ -158,14 +163,16 @@ def get_configuration(module, compare=False, format='xml', rollback='0', filter=
|
|||
return reply
|
||||
|
||||
|
||||
def commit_configuration(module, confirm=False, check=False, comment=None, confirm_timeout=None, synchronize=False,
|
||||
at_time=None, exit=False):
|
||||
def commit_configuration(module, confirm=False, check=False, comment=None, confirm_timeout=None, synchronize=False, at_time=None):
|
||||
conn = get_connection(module)
|
||||
try:
|
||||
if check:
|
||||
reply = conn.validate()
|
||||
else:
|
||||
reply = conn.commit(confirmed=confirm, timeout=confirm_timeout, comment=comment, synchronize=synchronize, at_time=at_time)
|
||||
if is_netconf(module):
|
||||
reply = conn.commit(confirmed=confirm, timeout=confirm_timeout, comment=comment, synchronize=synchronize, at_time=at_time)
|
||||
else:
|
||||
reply = conn.commit(comment=comment, confirmed=confirm, at_time=at_time, synchronize=synchronize)
|
||||
except ConnectionError as exc:
|
||||
module.fail_json(msg=to_text(exc, errors='surrogate_then_replace'))
|
||||
return reply
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue