Skip to content

VxLAN

ANTA catalog for VxLAN tests

Test functions related to VXLAN

VerifyVxlan

Bases: AntaTest

Verifies if Vxlan1 interface is configured, and is up/up

Source code in anta/tests/vxlan.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class VerifyVxlan(AntaTest):
    """
    Verifies if Vxlan1 interface is configured, and is up/up
    """

    name = "VerifyVxlan"
    description = "Verifies Vxlan1 status"
    categories = ["vxlan"]
    commands = [AntaCommand(command="show interfaces description", ofmt="json")]

    @AntaTest.anta_test
    def test(self) -> None:
        """Run VerifyVxlan validation"""

        command_output = self.instance_commands[0].json_output

        if "Vxlan1" not in command_output["interfaceDescriptions"]:
            self.result.is_skipped("Vxlan1 interface is not configured")
        elif (
            command_output["interfaceDescriptions"]["Vxlan1"]["lineProtocolStatus"] == "up"
            and command_output["interfaceDescriptions"]["Vxlan1"]["interfaceStatus"] == "up"
        ):
            self.result.is_success()
        else:
            self.result.is_failure(
                f"Vxlan1 interface is {command_output['interfaceDescriptions']['Vxlan1']['lineProtocolStatus']}"
                f"/{command_output['interfaceDescriptions']['Vxlan1']['interfaceStatus']}"
            )

test

test() -> None

Run VerifyVxlan validation

Source code in anta/tests/vxlan.py
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
@AntaTest.anta_test
def test(self) -> None:
    """Run VerifyVxlan validation"""

    command_output = self.instance_commands[0].json_output

    if "Vxlan1" not in command_output["interfaceDescriptions"]:
        self.result.is_skipped("Vxlan1 interface is not configured")
    elif (
        command_output["interfaceDescriptions"]["Vxlan1"]["lineProtocolStatus"] == "up"
        and command_output["interfaceDescriptions"]["Vxlan1"]["interfaceStatus"] == "up"
    ):
        self.result.is_success()
    else:
        self.result.is_failure(
            f"Vxlan1 interface is {command_output['interfaceDescriptions']['Vxlan1']['lineProtocolStatus']}"
            f"/{command_output['interfaceDescriptions']['Vxlan1']['interfaceStatus']}"
        )

VerifyVxlanConfigSanity

Bases: AntaTest

Verifies that there are no VXLAN config-sanity issues flagged

Source code in anta/tests/vxlan.py
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
class VerifyVxlanConfigSanity(AntaTest):
    """
    Verifies that there are no VXLAN config-sanity issues flagged
    """

    name = "VerifyVxlanConfigSanity"
    description = "Verifies VXLAN config-sanity"
    categories = ["vxlan"]
    commands = [AntaCommand(command="show vxlan config-sanity", ofmt="json")]

    @AntaTest.anta_test
    def test(self) -> None:
        """Run VerifyVxlanConfigSanity validation"""

        command_output = self.instance_commands[0].json_output

        if "categories" not in command_output or len(command_output["categories"]) == 0:
            self.result.is_skipped("VXLAN is not configured on this device")
            return

        failed_categories = {
            category: content
            for category, content in command_output["categories"].items()
            if category in ["localVtep", "mlag", "pd"] and content["allCheckPass"] is not True
        }

        if len(failed_categories) > 0:
            self.result.is_failure(f"Vxlan config sanity check is not passing: {failed_categories}")
        else:
            self.result.is_success()

test

test() -> None

Run VerifyVxlanConfigSanity validation

Source code in anta/tests/vxlan.py
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
@AntaTest.anta_test
def test(self) -> None:
    """Run VerifyVxlanConfigSanity validation"""

    command_output = self.instance_commands[0].json_output

    if "categories" not in command_output or len(command_output["categories"]) == 0:
        self.result.is_skipped("VXLAN is not configured on this device")
        return

    failed_categories = {
        category: content
        for category, content in command_output["categories"].items()
        if category in ["localVtep", "mlag", "pd"] and content["allCheckPass"] is not True
    }

    if len(failed_categories) > 0:
        self.result.is_failure(f"Vxlan config sanity check is not passing: {failed_categories}")
    else:
        self.result.is_success()

Last update: July 19, 2023