mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 05:12:45 +00: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:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user