Skip to content

Commit

Permalink
Merge pull request #18 from srl-labs/fix-es
Browse files Browse the repository at this point in the history
FIX: es-report
  • Loading branch information
wdesmedt authored Feb 5, 2024
2 parents f85cbe9 + 7af9d14 commit 211585b
Show file tree
Hide file tree
Showing 3 changed files with 211 additions and 197 deletions.
17 changes: 11 additions & 6 deletions nornir_srl/connections/srlinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ def get_es(self) -> Dict[str, Any]:
path_spec = {
"path": f"/system/network-instance/protocols/evpn/ethernet-segments",
"jmespath": '"system/network-instance/protocols/evpn/ethernet-segments"."bgp-instance"[]."ethernet-segment"[].{name:name, esi:esi, "mh-mode":"multi-homing-mode",\
oper:"oper-state",itfs:interface[]."ethernet-interface"|join(\' \',@), vrfs:association."network-instance"[].{ni:name, "peers":"_peers"}}',
oper:"oper-state",itf:interface[]."ethernet-interface"|join(\' \',@), "ni-peers":association."network-instance"[]."_ni_peers"|join(\', \',@) }',
"datatype": "state",
}

Expand All @@ -642,18 +642,23 @@ def set_es_peers(resp):
.get("bgp-instance", [])
):
for es in bgp_inst.get("ethernet-segment", []):
for vrf in es.get("association", {}).get("network-instance", []):
if not "association" in es:
es["association"] = {}
if not "network-instance" in es["association"]:
es["association"]["network-instance"] = []
for vrf in es["association"]["network-instance"]:
es_peers = (
vrf["bgp-instance"][0]
.get("computed-designated-forwarder-candidates", {})
.get("designated-forwarder-candidate", [])
)
vrf["_peers"] = ", ".join(
f"{peer['address']} (DF)"
vrf["_peers"] = " ".join(
f"{peer['address']}(DF)"
if peer["designated-forwarder"]
else peer["address"]
for peer in es_peers
)
vrf["_ni_peers"] = f"{vrf['name']}:[{vrf['_peers']}]"

if (
not "evpn"
Expand All @@ -678,8 +683,8 @@ def get_arp(self) -> Dict[str, Any]:
ni_itfs = self.get(paths=["/network-instance[name=*]"], datatype="config")
ni_itf_map: Dict[str, List[str]] = {}
for ni in ni_itfs[0].get("network-instance", []):
# if ni.get("type", "") == "mac-vrf":
# continue
# if ni.get("type", "") == "mac-vrf":
# continue
for ni_itf in ni.get("interface", []):
if ni_itf["name"] not in ni_itf_map:
ni_itf_map[ni_itf["name"]] = []
Expand Down
Loading

0 comments on commit 211585b

Please sign in to comment.