How to use the pybatfish.client.session.Asserts 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 batfish / ansible / module_utils / bf_assertion_util.py View on Github external
assert_no_undefined_references:
    short_description: Assert that there are no undefined references
    description:
        - "This test will fail if any device configuration refers to a structure (e.g., ACL, prefix-list, routemap) that is not defined in the configuration."
        - "This test takes no parameters."
'''

# Map assertion-type string to Pybatfish-assertion function
_ASSERT_TYPE_TO_FUNCTION = {
    'assert_all_flows_fail': Asserts.assert_flows_fail,
    'assert_all_flows_succeed': Asserts.assert_flows_succeed,
    'assert_filter_has_no_unreachable_lines': Asserts.assert_filter_has_no_unreachable_lines,
    'assert_filter_denies': Asserts.assert_filter_denies,
    'assert_filter_permits': Asserts.assert_filter_permits,
    'assert_no_forwarding_loops': Asserts.assert_no_forwarding_loops,
    'assert_no_incompatible_bgp_sessions': Asserts.assert_no_incompatible_bgp_sessions,
    'assert_no_incompatible_ospf_sessions': Asserts.assert_no_incompatible_ospf_sessions,
    'assert_no_unestablished_bgp_sessions': Asserts.assert_no_unestablished_bgp_sessions,
    'assert_no_undefined_references': Asserts.assert_no_undefined_references,
}

ASSERT_PASS_MESSAGE = 'Assertion passed'

UNSUPPORTED_ASSERTION_PARAMETERS = {"self", "snapshot", "soft", "df_format"}


def get_assertion_issues(assertion):
    """Return the reason the assertion dictionary is valid, or return None if it is valid."""
    if not isinstance(assertion, Mapping):
        return "Assertion format is invalid, expected dictionary: {}".format(
            assertion)
github batfish / ansible / module_utils / bf_assertion_util.py View on Github external
assert_no_unestablished_bgp_sessions:
    short_description: Assert that all compatibly-configured BGP sessions are established
    description:
        - "This test fails if there are any BGP session in the snapshot that are compatibly configured but will not be established (e.g., due to ACLs)."
        - "This test takes no parameters."

assert_no_undefined_references:
    short_description: Assert that there are no undefined references
    description:
        - "This test will fail if any device configuration refers to a structure (e.g., ACL, prefix-list, routemap) that is not defined in the configuration."
        - "This test takes no parameters."
'''

# Map assertion-type string to Pybatfish-assertion function
_ASSERT_TYPE_TO_FUNCTION = {
    'assert_all_flows_fail': Asserts.assert_flows_fail,
    'assert_all_flows_succeed': Asserts.assert_flows_succeed,
    'assert_filter_has_no_unreachable_lines': Asserts.assert_filter_has_no_unreachable_lines,
    'assert_filter_denies': Asserts.assert_filter_denies,
    'assert_filter_permits': Asserts.assert_filter_permits,
    'assert_no_forwarding_loops': Asserts.assert_no_forwarding_loops,
    'assert_no_incompatible_bgp_sessions': Asserts.assert_no_incompatible_bgp_sessions,
    'assert_no_incompatible_ospf_sessions': Asserts.assert_no_incompatible_ospf_sessions,
    'assert_no_unestablished_bgp_sessions': Asserts.assert_no_unestablished_bgp_sessions,
    'assert_no_undefined_references': Asserts.assert_no_undefined_references,
}

ASSERT_PASS_MESSAGE = 'Assertion passed'

UNSUPPORTED_ASSERTION_PARAMETERS = {"self", "snapshot", "soft", "df_format"}