mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-18 06:11:07 -07:00
Fix fetch configuration in junos_command (#26392)
* Fix fetch configuration in junos_command Fixes #26358 Add support to fetch configuration from device in `xml`, `text`, `json`, `set` display format. * Add error message if set display is not supported * Throw error in case of warning for show commands
This commit is contained in:
parent
07b097af7c
commit
43bd993fac
2 changed files with 47 additions and 14 deletions
|
@ -37,7 +37,7 @@ except ImportError:
|
|||
NS_MAP = {'nc': "urn:ietf:params:xml:ns:netconf:base:1.0"}
|
||||
|
||||
|
||||
def send_request(module, obj, check_rc=True):
|
||||
def send_request(module, obj, check_rc=True, ignore_warning=True):
|
||||
request = tostring(obj)
|
||||
rc, out, err = exec_command(module, request)
|
||||
if rc != 0 and check_rc:
|
||||
|
@ -54,7 +54,7 @@ def send_request(module, obj, check_rc=True):
|
|||
message = rpc_error.find('./nc:error-message', NS_MAP).text
|
||||
severity = rpc_error.find('./nc:error-severity', NS_MAP).text
|
||||
|
||||
if severity == 'warning':
|
||||
if severity == 'warning' and ignore_warning:
|
||||
warnings.append(message)
|
||||
else:
|
||||
module.fail_json(msg=str(err))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue