Skip to content

Commit

Permalink
fix: address_prefix should be list of type dict (#124)
Browse files Browse the repository at this point in the history
See #116 for commentary.

Fixes #118
  • Loading branch information
Michael Richardson authored and shinmog committed Oct 6, 2020
1 parent 261633b commit bd02fd0
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions plugins/modules/panos_bgp_policy_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@
default: True
address_prefix:
description:
- List of address prefix strings or dicts with "name"/"exact" keys.
- List of dicts with "name"/"exact" keys.
- Using the dict form for address prefixes should only be used with
I(policy_type=aggregate).
type: list
elements: str
elements: dict
match_afi:
description:
- Address Family Identifier.
Expand Down Expand Up @@ -228,7 +228,7 @@ def setup_args():
match_as_path_regex=dict(type='str'),
match_community_regex=dict(type='str'),
match_extended_community_regex=dict(type='str'),
address_prefix=dict(type='list', elements='str'),
address_prefix=dict(type='list', elements='dict'),
)


Expand Down Expand Up @@ -298,15 +298,10 @@ def main():

# Handle address prefixes.
for x in module.params['address_prefix']:
if isinstance(x, dict):
if 'name' not in x:
module.fail_json(msg='Address prefix dict requires "name": {0}'.format(x))
obj.add(BgpPolicyAddressPrefix(
to_text(x['name'], encoding='utf-8', errors='surrogate_or_strict'),
None if x.get('exact') is None else module.boolean(x['exact']),
))
else:
obj.add(BgpPolicyAddressPrefix(to_text(x, encoding='utf-8', errors='surrogate_or_strict')))
obj.add(BgpPolicyAddressPrefix(
to_text(x['name'], encoding='utf-8', errors='surrogate_or_strict'),
None if x.get('exact') is None else module.boolean(x['exact']),
))

if module.params['state'] == 'return-object':
module.deprecate('state=return-object is deprecated', version='3.0.0', collection_name='paloaltonetworks.panos')
Expand Down

0 comments on commit bd02fd0

Please sign in to comment.