Skip to content

Commit

Permalink
Merge pull request #17 from srl-labs/feat-arp
Browse files Browse the repository at this point in the history
add network-instance to 'arp' report
  • Loading branch information
wdesmedt authored Jan 25, 2024
2 parents 6b0eb8c + 116fc6b commit f85cbe9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion nornir_srl/connections/srlinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,15 +672,25 @@ def set_es_peers(resp):
def get_arp(self) -> Dict[str, Any]:
path_spec = {
"path": f"/interface[name=*]/subinterface[index=*]/ipv4/arp/neighbor",
"jmespath": '"interface"[*].subinterface[].{interface:"_subitf", entries:ipv4.arp.neighbor[].{IPv4:"ipv4-address",MAC:"link-layer-address",Type:origin,expiry:"_rel_expiry" }}',
"jmespath": '"interface"[*].subinterface[].{interface:"_subitf", NI:"_ni"|to_string(@), entries:ipv4.arp.neighbor[].{IPv4:"ipv4-address",MAC:"link-layer-address",Type:origin,expiry:"_rel_expiry" }}',
"datatype": "state",
}
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
for ni_itf in ni.get("interface", []):
if ni_itf["name"] not in ni_itf_map:
ni_itf_map[ni_itf["name"]] = []
ni_itf_map[ni_itf["name"]].append(ni["name"])
resp = self.get(
paths=[path_spec.get("path", "")], datatype=path_spec["datatype"]
)
for itf in resp[0].get("interface", []):
for subitf in itf.get("subinterface", []):
subitf["_subitf"] = f"{itf['name']}.{subitf['index']}"
subitf["_ni"] = ni_itf_map.get(subitf["_subitf"], [])
for arp_entry in (
subitf.get("ipv4", {}).get("arp", {}).get("neighbor", [])
):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nornir-srl"
version = "0.2.6"
version = "0.2.7"
description = "Nornir connection plugin for SRLinux"
authors = ["Walter De Smedt <walter.de.smedt@gmail.com>"]
readme = "README.md"
Expand Down

0 comments on commit f85cbe9

Please sign in to comment.