Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
console.setLevel(logging.ERROR)
logging.getLogger('').addHandler(console)
load_questions()
bf_init_snapshot(args.candidate, name='candidate')
bf_init_snapshot(args.failure, name='failure')
bf_set_snapshot('candidate')
csFailed = test_config_sanity(False)
cpFailed = test_controlplane(False)
dpFailed = test_dataplane(False, fromNode='leaf-3')
logging.info("\nProgress: analysing failure conditions")
bf_set_snapshot('failure')
dpFailedoutage = test_dataplane(False, fromNode='leaf-3')
rr = bfq.differentialReachability().answer(snapshot='candidate', reference_snapshot='failure')
print_reduced_rechability(rr.get('answerElements')[0])
return 0 if not any([cpFailed, dpFailed, csFailed, dpFailedoutage]) else 1
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
)
answer = bfq.differentialReachability(
headers=HeaderConstraints(dstIps='server2')
).answer(
snapshot=FAIL_SNAPSHOT_NAME,
reference_snapshot=BASE_SNAPSHOT_NAME
).frame()
if len(answer) > 0:
print("[FAIL] No reachability discovered for the following flow(s)...")
print_diff_reachability(answer)
sys.exit(1)
print("[SUCCESS] No reachability issues found after {} rounds of chaos!".format(MAX_CHAOS))