Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

announcer: use 'yanet-cli neighbor show' for check neighbor MAC address #118

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 36 additions & 8 deletions yanet-announcer.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,26 +254,54 @@ def check_default_v6(route):
raise Exception(f"check_default_v6('{route}')")


@Decorator.logger_function
@Decorator.skip_function()
def check_neighbor_v4(address_row, neighbors):
for neighbor_row in neighbors:
if (
address_row["module"] == neighbor_row["route_name"]
and address_row["interface"] == neighbor_row["interface_name"]
and address_row["neighbor_v4"] == neighbor_row["ip_address"]
):
return True
return False


@Decorator.logger_function
@Decorator.skip_function()
def check_neighbor_v6(address_row, neighbors):
for neighbor_row in neighbors:
if (
address_row["module"] == neighbor_row["route_name"]
and address_row["interface"] == neighbor_row["interface_name"]
and address_row["neighbor_v6"] == neighbor_row["ip_address"]
):
return True
return False


@Decorator.logger_function
@Decorator.skip_function()
def check_interfaces_neighbor_v4():
interfaces = Executer.get("yanet-cli route interface")
neighbors = Executer.get("yanet-cli neighbor show")
for row in interfaces:
if row["neighbor_mac_address_v4"] != "n/s":
return

raise Exception(f"check_interfaces_neighbor_v4()")
if row["neighbor_v4"] != "n/s":
if not check_neighbor_v4(row, neighbors):
raise Exception(f"check_interfaces_neighbor_v4(): {row}")
return


@Decorator.logger_function
@Decorator.skip_function()
def check_interfaces_neighbor_v6():
interfaces = Executer.get("yanet-cli route interface")
neighbors = Executer.get("yanet-cli neighbor show")
for row in interfaces:
if row["neighbor_mac_address_v6"] != "n/s":
return

raise Exception(f"check_interfaces_neighbor_v6()")
if row["neighbor_v6"] != "n/s":
if not check_neighbor_v6(row, neighbors):
raise Exception(f"check_interfaces_neighbor_v6(): {row}")
return


@Decorator.logger_function
Expand Down
Loading