Skip to content

MLAG

ANTA catalog for mlag tests

Test functions related to Multi-Chassis LAG

verify_mlag_config_sanity(device, result) async

Verifies there is no MLAG config-sanity inconsistencies.

Parameters:

Name Type Description Default
device InventoryDevice

InventoryDevice instance containing all devices information.

required

Returns:

Type Description
TestResult

TestResult instance with

TestResult
  • result = “unset” if the test has not been executed
TestResult
  • result = “success” if there is no MLAG config-sanity inconsistencies
TestResult
  • result = “failure” otherwise.
TestResult
  • result = “error” if any exception is caught
Source code in anta/tests/mlag.py
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
@anta_test
async def verify_mlag_config_sanity(
    device: InventoryDevice, result: TestResult
) -> TestResult:
    """
    Verifies there is no MLAG config-sanity inconsistencies.

    Args:
        device (InventoryDevice): InventoryDevice instance containing all devices information.

    Returns:
        TestResult instance with
        * result = "unset" if the test has not been executed
        * result = "success" if there is no MLAG config-sanity inconsistencies
        * result = "failure" otherwise.
        * result = "error" if any exception is caught

    """
    response = await device.session.cli(command="show mlag config-sanity", ofmt="json")

    if "mlagActive" not in response.keys():
        result.is_error("incorrect JSON response")
    elif response["mlagActive"] is False:
        # MLAG is not running
        result.is_skipped("MLAG is disabled")
    elif (
        len(response["globalConfiguration"]) > 0
        or len(response["interfaceConfiguration"]) > 0
    ):
        result.is_failure()
        if len(response["globalConfiguration"]) > 0:
            result.is_failure(
                "MLAG config-sanity returned some Global inconsistencies: "
                f"{response['response']['globalConfiguration']}"
            )
        if len(response["interfaceConfiguration"]) > 0:
            result.is_failure(
                "MLAG config-sanity returned some Interface inconsistencies: "
                f"{response['response']['interfaceConfiguration']}"
            )
    else:
        result.is_success()

    return result

verify_mlag_interfaces(device, result) async

Verifies there is no inactive or active-partial MLAG interfaces.

Parameters:

Name Type Description Default
device InventoryDevice

InventoryDevice instance containing all devices information.

required

Returns:

Type Description
TestResult

TestResult instance with

TestResult
  • result = “unset” if the test has not been executed
TestResult
  • result = “success” if there is no inactive or active-partial MLAG interfaces.
TestResult
  • result = “failure” otherwise.
TestResult
  • result = “error” if any exception is caught
Source code in anta/tests/mlag.py
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
@anta_test
async def verify_mlag_interfaces(device: InventoryDevice, result: TestResult) -> TestResult:
    """
    Verifies there is no inactive or active-partial MLAG interfaces.

    Args:
        device (InventoryDevice): InventoryDevice instance containing all devices information.

    Returns:
        TestResult instance with
        * result = "unset" if the test has not been executed
        * result = "success" if there is no inactive or active-partial MLAG interfaces.
        * result = "failure" otherwise.
        * result = "error" if any exception is caught

    """
    response = await device.session.cli(command="show mlag", ofmt="json")

    if response["state"] == "disabled":
        result.is_skipped("MLAG is disabled")
    elif (
        response["mlagPorts"]["Inactive"] != 0
        or response["mlagPorts"]["Active-partial"] != 0
    ):
        result.is_failure(f"MLAG status is not OK: {response['mlagPorts']}")
    else:
        result.is_success()

    return result

verify_mlag_status(device, result) async

Verifies the MLAG status: state is active, negotiation status is connected, local int is up, peer link is up.

Parameters:

Name Type Description Default
device InventoryDevice

InventoryDevice instance containing all devices information.

required

Returns:

Type Description
TestResult

TestResult instance with

TestResult
  • result = “unset” if the test has not been executed
TestResult
  • result = “success” if the MLAG status is OK
TestResult
  • result = “failure” otherwise.
TestResult
  • result = “error” if any exception is caught
Source code in anta/tests/mlag.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
@anta_test
async def verify_mlag_status(device: InventoryDevice, result: TestResult) -> TestResult:
    """
    Verifies the MLAG status:
    state is active, negotiation status is connected, local int is up, peer link is up.

    Args:
        device (InventoryDevice): InventoryDevice instance containing all devices information.

    Returns:
        TestResult instance with
        * result = "unset" if the test has not been executed
        * result = "success" if the MLAG status is OK
        * result = "failure" otherwise.
        * result = "error" if any exception is caught

    """
    response = await device.session.cli(command="show mlag", ofmt="json")

    if response["state"] == "disabled":
        result.is_skipped("MLAG is disabled")
    elif (
        response["state"] != "active"
        or response["negStatus"] != "connected"
        or response["localIntfStatus"] != "up"
        or response["peerLinkStatus"] != "up"
    ):
        result.is_failure(f"MLAG status is not OK: {response}")
    else:
        result.is_success()

    return result

Last update: September 5, 2022