Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
NETWORK_NAME = "ebgp-spine-leaf-network1"
BASE_SNAPSHOT_NAME = "ebgp-spine-leaf-snapshot1"
SNAPSHOT_PATH = sys.argv[1]
BATFISH_SERVICE_IP = "172.29.236.139"
MAX_CHAOS = 15
bf_session.host = BATFISH_SERVICE_IP
load_questions()
print("[*] Initializing BASE_SNAPSHOT")
bf_set_network(NETWORK_NAME)
bf_init_snapshot(SNAPSHOT_PATH, name=BASE_SNAPSHOT_NAME, overwrite=True)
print("[*] Collecting link data")
links = bfq.edges(nodes="/spine|leaf/",remoteNodes="/spine|leaf/").answer(BASE_SNAPSHOT_NAME).frame()
print("[*] Releasing the Chaos Monkey")
for i in range(MAX_CHAOS):
failed_link1_index = random.randint(0, len(links) - 1)
failed_link2_index = random.randint(0, len(links) - 1)
print(" - Deactivating Links:{} + {}".format(links.loc[failed_link1_index].Interface,
links.loc[failed_link2_index].Interface))
FAIL_SNAPSHOT_NAME = "fail_snapshot"
bf_fork_snapshot(
BASE_SNAPSHOT_NAME,
FAIL_SNAPSHOT_NAME,
deactivate_interfaces=[links.loc[failed_link1_index].Interface,
links.loc[failed_link2_index].Interface],
overwrite=True
)