Skip to content

Commit

Permalink
Merge branch 'chateaulav-compat-ndb-1132' of https://github.com/chate…
Browse files Browse the repository at this point in the history
…aulav/pyroute2 into chateaulav-chateaulav-compat-ndb-1132
  • Loading branch information
svinota committed Oct 27, 2023
2 parents d7e0e63 + 47d74f4 commit 1b063e0
Showing 1 changed file with 39 additions and 18 deletions.
57 changes: 39 additions & 18 deletions pyroute2/ndb/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,51 @@ def ipdb_interfaces_view(ndb):
interface = record._as_dict()
interface['ipdb_scope'] = 'system'
interface['ipdb_priority'] = 0
interface['ipaddr'] = tuple(
(
(x.address, x.prefixlen)
for x in (
ndb.addresses.dump().select_records(index=record.index)
try:
interface['ipaddr'] = tuple(
(
(x.address, x.prefixlen)
for x in (
ndb.addresses.dump().select_records(index=record.index)
)
)
)
)
interface['ports'] = tuple(
(
x.index
for x in (
ndb.interfaces.dump().select_records(master=record.index)
except:
with ndb.addresses.summary() as report:
report.select_records(ifname=f"{record.ifname}")
interface['ipaddr'] = tuple(
((x.address, x.prefixlen) for x in report)
)
try:
interface['ports'] = tuple(
(
x.index
for x in (
ndb.interfaces.dump().select_records(master=record.index)
)
)
)
)
interface['neighbours'] = tuple(
(
x.dst
for x in (
ndb.neighbours.dump().select_records(ifindex=record.index)
except:
with ndb.interfaces.dump() as report:
report.select_records(ifname=f"{record.ifname}")
interface['ports'] = tuple(
(x.index for x in report)
)
try:
interface['neighbours'] = tuple(
(
x.dst
for x in (
ndb.neighbours.dump().select_records(ifindex=record.index)
)
)
)
)
except:
with ndb.neighbours.dump() as report:
report.select_records(ifindex=record.index)
interface['neighbours'] = tuple(
(x.dst for x in report)
)
ret[record.ifname] = interface

return ret

0 comments on commit 1b063e0

Please sign in to comment.