Skip to content

Commit

Permalink
ios_bgp_global - Explicitly add neighbor address to every parser (#962)
Browse files Browse the repository at this point in the history
* Explicitly add neighbor address to every parser

* revert back sorting

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
KB-perByte and pre-commit-ci[bot] authored Nov 8, 2023
1 parent 617d81b commit 40f17ef
Show file tree
Hide file tree
Showing 3 changed files with 327 additions and 55 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/bgp_global_evpn_fix_2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- ios_bgp_global - Explicitly add neighbor address to every parser.
16 changes: 13 additions & 3 deletions plugins/module_utils/network/ios/facts/bgp_global/bgp_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,27 @@ def populate_facts(self, connection, ansible_facts, data=None):
data = self.get_bgp_global_data(connection)

# parse native config using the Bgp_global template
bgp_global_parser = Bgp_globalTemplate(lines=data.splitlines(), module=self._module)
bgp_global_parser = Bgp_globalTemplate(
lines=data.splitlines(),
module=self._module,
)
objs = bgp_global_parser.parse()
neighbor_list = objs.get("neighbors", {})
if neighbor_list:
objs["neighbors"] = list(neighbor_list.values())
objs["neighbors"] = sorted(
list(neighbor_list.values()),
key=lambda k, pk="neighbor_address": k[pk],
)

obj = utils.remove_empties(objs)

ansible_facts["ansible_network_resources"].pop("bgp_global", None)
params = utils.remove_empties(
bgp_global_parser.validate_config(self.argument_spec, {"config": obj}, redact=True),
bgp_global_parser.validate_config(
self.argument_spec,
{"config": obj},
redact=True,
),
)

facts["bgp_global"] = params.get("config", {})
Expand Down
Loading

0 comments on commit 40f17ef

Please sign in to comment.