Skip to content

Commit

Permalink
Merge pull request #520 from rahkumar651991/rpc_ignore_warn
Browse files Browse the repository at this point in the history
Adding ignore warning argument in juniper_junos_rpc
  • Loading branch information
Nitin Kr committed Aug 21, 2020
2 parents 3cbea9c + 97d34ab commit 7ff4e07
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion library/juniper_junos_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@
- format
- display
- output
ignore_warning:
description:
- A boolean, string or list of strings. If the value is C(true),
ignore all warnings regardless of the warning message. If the value
is a string, it will ignore warning(s) if the message of each warning
matches the string. If the value is a list of strings, ignore
warning(s) if the message of each warning matches at least one of the
strings in the list. The value of the I(ignore_warning) option is
applied to the load and commit operations performed by this module.
required: false
default: none
type: bool, str, or list of str
kwargs:
description:
- The keyword arguments and values to the RPCs specified by the
Expand Down Expand Up @@ -411,6 +423,9 @@ def main():
type='path',
aliases=['destination_dir', 'destdir'],
default=None),
ignore_warning=dict(required=False,
type='list',
default=None),
return_output=dict(required=False,
type='bool',
default=True)
Expand All @@ -430,6 +445,9 @@ def main():
if rpcs is None:
junos_module.fail_json(msg="The rpcs option must have a value.")

# Parse ignore_warning value
ignore_warning = junos_module.parse_ignore_warning_option()

# Check over formats
formats = junos_module.params.get('formats')
if formats is None:
Expand Down Expand Up @@ -519,6 +537,8 @@ def main():
'filter_xml=%s, options=%s, '
'kwargs=%s',
filter, str(attr), str(kwarg))
# not adding ignore_warning as we don't expect to get rpc-error
# with severity warning during get_config
resp = junos_module.dev.rpc.get_config(filter_xml=filter,
options=attr, **kwarg)
result['msg'] = 'The "get-config" RPC executed successfully.'
Expand All @@ -544,7 +564,7 @@ def main():
rpc,
pretty_print=True))
resp = junos_module.dev.rpc(rpc,
normalize=bool(format == 'xml'))
normalize=bool(format == 'xml'), ignore_warning=ignore_warning)
result['msg'] = 'The RPC executed successfully.'
junos_module.logger.debug('RPC "%s" executed successfully.',
junos_module.etree.tostring(
Expand Down

0 comments on commit 7ff4e07

Please sign in to comment.