How to use the pybatfish.question.bfq.nodeProperties function in pybatfish

To help you get started, we’ve selected a few pybatfish examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github networkop / arista-network-ci / tests / batfish / leaf-3.py View on Github external
def test_controlplane(isFailed):
    # Define a list of Spine switches
    spines = set(bfq.nodeProperties(nodes='spine.*').answer().frame()['Node'])
    logging.info("Progress: Analyzing control plane properties")

    # Get all BGP session status for leaf nodes
    bgp = bfq.bgpSessionStatus(nodes='leaf.*').answer().frame()
    
    # All leaves should have at least one peering with each spine
    violators = bgp.groupby('Node').filter(lambda x: set(x['Remote_Node']).difference(spines) != set([]))
    if len(violators) > 0:
        logging.error("Found leaves that do not have at least one peering to each spine")
        logging.error(violators[['Node', 'Remote_Node']])
        isFailed = True
    else:
        logging.info("All leaves have at least one peering with each spine")
   
    # All leaves should only peer with spines
    non_spines = bgp[~bgp['Remote_Node'].str.contains('spine', na=False)]