Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
localIP = loopbacks[loopbacks['Node'] == fromNode]['IP'][0]
leaves = set(loopbacks[loopbacks['Node'].str.contains('leaf')]['IP'])
leaves.remove(localIP)
spines = set(loopbacks[loopbacks['Node'].str.contains('spine')]['IP'])
mpath = len(spines)
logging.info("Progress: Analyzing traceroute from Leaf-3 to Leaf-1 and Leaf-2")
# Set up the resulting data structure
troute = dict()
for leaf in leaves:
troute[leaf] = dict()
# Build headers for traceroute flows
for leaf in leaves:
troute[leaf]['header'] = header(srcIps=localIP,dstIps=leaf)
# Ask questions about traceroute
for leaf,data in troute.items():
troute[leaf]['trace'] = bfq.traceroute(startLocation=fromNode, headers=data['header']).answer()
# Get first flow disposition for traces
for leaf,data in troute.items():
troute[leaf]['result'] = data['trace'].get('answerElements')[0]['rows'][0]['Traces'][0]['disposition']
# Get traceroute paths to reach Leaf-1 and Leaf-2
for leaf,data in troute.items():
troute[leaf]['paths'] = data['trace'].get('answerElements')[0]['rows'][0]['Traces']
# Get traceroute hops to reach Leaf-1 and Leaf-2
for leaf,data in troute.items():
troute[leaf]['hops'] = data['trace'].get('answerElements')[0]['rows'][0]['Traces'][0].get('hops',[])
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))