-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
75 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
## cloned from Julio Perez batfish scripts ## | ||
|
||
from datetime import datetime | ||
from pybatfish.client.commands import ( | ||
bf_session, | ||
bf_init_snapshot, | ||
bf_set_network, | ||
) | ||
from pybatfish.client.session import Session | ||
from pybatfish.question import load_questions | ||
from pybatfish.client.asserts import ( | ||
assert_no_duplicate_router_ids, | ||
assert_no_incompatible_bgp_sessions, | ||
assert_no_unestablished_bgp_sessions, | ||
) | ||
from rich.console import Console | ||
|
||
|
||
console = Console(color_system="truecolor") | ||
|
||
|
||
def test_duplicate_rtr_ids(snap): | ||
"""Testing for duplicate router IDs""" | ||
console.print( | ||
":white_exclamation_mark: [bold yellow]Testing for duplicate router IDs[/bold yellow] :white_exclamation_mark:" | ||
) | ||
assert_no_duplicate_router_ids( | ||
snapshot=snap, | ||
protocols={"ospf", "bgp"}, | ||
) | ||
console.print( | ||
":green_heart: [bold green]No duplicate router IDs found[/bold green] :green_heart:" | ||
) | ||
|
||
|
||
def test_bgp_compatibility(snap): | ||
"""Testing for incompatible BGP sessions""" | ||
console.print( | ||
":white_exclamation_mark: [bold yellow]Testing for incompatible BGP sessions[/bold yellow] :white_exclamation_mark:" | ||
) | ||
assert_no_incompatible_bgp_sessions( | ||
snapshot=snap, | ||
) | ||
console.print( | ||
":green_heart: [bold green]All BGP sessions compatible![/bold green] :green_heart:" | ||
) | ||
|
||
|
||
def test_bgp_unestablished(snap): | ||
"""Testing for BGP sessions that are not established""" | ||
console.print( | ||
":white_exclamation_mark: [bold yellow]Testing for unestablished BGP sessions[/bold yellow] :white_exclamation_mark:" | ||
) | ||
assert_no_unestablished_bgp_sessions( | ||
snapshot=snap, | ||
) | ||
console.print( | ||
":green_heart: [bold green]All BGP sessions are established![/bold green] :green_heart:" | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
NETWORK_NAME = "eos_lab" | ||
SNAPSHOT_NAME = f"snapshot-{datetime.today().strftime('%Y-%m-%d')}" | ||
SNAPSHOT_DIR = "./snapshots" | ||
|
||
bf_session.host = "192.168.0.200" | ||
bf_set_network(NETWORK_NAME) | ||
init_snap = bf_init_snapshot(SNAPSHOT_DIR, name=SNAPSHOT_NAME, overwrite=True) | ||
load_questions() | ||
test_duplicate_rtr_ids(init_snap) | ||
test_bgp_compatibility(init_snap) | ||
test_bgp_unestablished(init_snap) |