Skip to content

Commit

Permalink
Fix bgp_communities facts handling for empty member lists. (#319)
Browse files Browse the repository at this point in the history
* Fix bgp_communities facts handling for empty member lists.

* Add a changelog fragment file for this fix.

* Corrected the tense for this changelog fragment.

* Added details for this changelog fragment.

* Add automated unit and integration testing for empty bgp community member list config handling; Add the standard module name prefix to the fragment file for this PR.
  • Loading branch information
kerry-meyer authored Jan 3, 2024
1 parent fd97e36 commit 63e2ea8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- sonic_bgp_communities - Fix incorrect "facts" handling for parsing of a BGP community list configured with an empty "members" list (https://github.com/ansible-collections/dellemc.enterprise_sonic/pull/319).
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,14 @@ def get_bgp_communities(self):
result['permit'] = True
if members:
result['type'] = 'expanded' if 'REGEX' in members[0] else 'standard'
if result['type'] == 'expanded':
members = [':'.join(i.split(':')[1:]) for i in members]
members.sort()
result['members'] = {'regex': members}
if result['type'] == 'expanded':
members = [':'.join(i.split(':')[1:]) for i in members]
members.sort()
result['members'] = {'regex': members}
else:
result['type'] = 'standard'

if result['type'] == 'standard':
result['local_as'] = None
result['no_advertise'] = None
result['no_export'] = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ tests:
- "13"
- name: test2
type: standard
permit: false
match: ALL
no_export: true
no_peer: true
- name: test_case_05
description: Delete1 BGP properties
state: deleted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ merged_01:
- path: "data/openconfig-routing-policy:routing-policy/defined-sets/openconfig-bgp-policy:bgp-defined-sets/community-sets"
response:
code: 200
value:
openconfig-bgp-policy:community-sets:
community-set:
- community-set-name: 'test2'
config:
community-set-name: 'test2'
openconfig-bgp-policy-ext:action: 'PERMIT'
match-set-options: 'ALL'
expected_config_requests:
- path: "data/openconfig-routing-policy:routing-policy/defined-sets/openconfig-bgp-policy:bgp-defined-sets/community-sets"
method: "patch"
Expand Down

0 comments on commit 63e2ea8

Please sign in to comment.