Skip to content

Commit ce4ebd0

Browse files
committed
black-ified
1 parent 047f0a5 commit ce4ebd0

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

nornir_srl/connections/srlinux.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ def get_nwi_itf(self, nw_instance: str = "*") -> Dict[str, Any]:
596596

597597
res = jmespath.search(path_spec["jmespath"], resp[0])
598598
return {"nwi_itfs": res}
599-
599+
600600
def get_lag(self, lag_id: str = "*") -> Dict[str, Any]:
601601
path_spec = {
602602
"path": f"/interface[name=lag{lag_id}]",
@@ -618,16 +618,33 @@ def get_es(self) -> Dict[str, Any]:
618618
oper:"oper-state",itfs:interface[]."ethernet-interface"|join(\' \',@), vrfs:association."network-instance"[].{ni:name, "peers":"_peers"}}',
619619
"datatype": "state",
620620
}
621+
621622
def set_es_peers(resp):
622-
for bgp_inst in resp[0].get("system/network-instance/protocols/evpn/ethernet-segments", {}).get("bgp-instance", []):
623+
for bgp_inst in (
624+
resp[0]
625+
.get("system/network-instance/protocols/evpn/ethernet-segments", {})
626+
.get("bgp-instance", [])
627+
):
623628
for es in bgp_inst.get("ethernet-segment", []):
624629
for vrf in es.get("association", {}).get("network-instance", []):
625-
es_peers = vrf["bgp-instance"][0].get("computed-designated-forwarder-candidates", {}).get("designated-forwarder-candidate", [])
630+
es_peers = (
631+
vrf["bgp-instance"][0]
632+
.get("computed-designated-forwarder-candidates", {})
633+
.get("designated-forwarder-candidate", [])
634+
)
626635
vrf["_peers"] = ", ".join(
627-
f"{peer['address']} (DF)" if peer["designated-forwarder"] else peer["address"]
628-
for peer in es_peers
636+
f"{peer['address']} (DF)"
637+
if peer["designated-forwarder"]
638+
else peer["address"]
639+
for peer in es_peers
629640
)
630-
if not "evpn" in self.get(paths=["/system/features"], datatype="state")[0]["system/features"]:
641+
642+
if (
643+
not "evpn"
644+
in self.get(paths=["/system/features"], datatype="state")[0][
645+
"system/features"
646+
]
647+
):
631648
return {"es": []}
632649
resp = self.get(
633650
paths=[path_spec.get("path", "")], datatype=path_spec["datatype"]
@@ -636,7 +653,6 @@ def set_es_peers(resp):
636653
res = jmespath.search(path_spec["jmespath"], resp[0])
637654
return {"es": res}
638655

639-
640656
def get(
641657
self,
642658
paths: List[str],

nornir_srl/fsc.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ def _subinterfaces(task: Task) -> Result:
482482
i_filter=ctx.obj["i_filter"],
483483
)
484484

485+
485486
@cli.command()
486487
@click.pass_context
487488
@click.option(
@@ -500,9 +501,7 @@ def _lag(task: Task) -> Result:
500501
f_filter = (
501502
{k: v for k, v in [f.split("=") for f in field_filter]} if field_filter else {}
502503
)
503-
result = ctx.obj["target"].run(
504-
task=_lag, name="lag", raise_on_error=False
505-
)
504+
result = ctx.obj["target"].run(task=_lag, name="lag", raise_on_error=False)
506505
print_report(
507506
result=result,
508507
name="LAGs",
@@ -512,6 +511,7 @@ def _lag(task: Task) -> Result:
512511
i_filter=ctx.obj["i_filter"],
513512
)
514513

514+
515515
@cli.command()
516516
@click.pass_context
517517
@click.option(
@@ -696,6 +696,7 @@ def _lldp_neighbors(task: Task) -> Result:
696696
i_filter=ctx.obj["i_filter"],
697697
)
698698

699+
699700
@cli.command()
700701
@click.pass_context
701702
@click.option(
@@ -722,8 +723,9 @@ def _es(task: Task) -> Result:
722723
failed_hosts=result.failed_hosts,
723724
box_type=ctx.obj["box_type"],
724725
f_filter=f_filter,
725-
i_filter=ctx.obj["i_filter"]
726+
i_filter=ctx.obj["i_filter"],
726727
)
727-
728+
729+
728730
if __name__ == "__main__":
729731
cli(obj={})

0 commit comments

Comments
 (0)