Skip to content

Multicast

ANTA catalog for multicast tests

Test functions related to multicast

VerifyIGMPSnoopingGlobal

Bases: AntaTest

Verifies the IGMP snooping global configuration.

Source code in anta/tests/multicast.py
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
class VerifyIGMPSnoopingGlobal(AntaTest):
    """
    Verifies the IGMP snooping global configuration.
    """

    name = "VerifyIGMPSnoopingGlobal"
    description = "Verifies the IGMP snooping global configuration."
    categories = ["multicast", "igmp"]
    commands = [AntaCommand(command="show ip igmp snooping")]

    class Input(AntaTest.Input):  # pylint: disable=missing-class-docstring
        enabled: bool
        """Expected global IGMP snooping configuration (True=enabled, False=disabled)"""

    @AntaTest.anta_test
    def test(self) -> None:
        command_output = self.instance_commands[0].json_output
        self.result.is_success()
        igmp_state = command_output["igmpSnoopingState"]
        if igmp_state != "enabled" if self.inputs.enabled else igmp_state != "disabled":
            self.result.is_failure(f"IGMP state is not valid: {igmp_state}")

Input

Bases: Input

Source code in anta/tests/multicast.py
56
57
58
class Input(AntaTest.Input):  # pylint: disable=missing-class-docstring
    enabled: bool
    """Expected global IGMP snooping configuration (True=enabled, False=disabled)"""

enabled instance-attribute

enabled: bool

Expected global IGMP snooping configuration (True=enabled, False=disabled)

VerifyIGMPSnoopingVlans

Bases: AntaTest

Verifies the IGMP snooping configuration for some VLANs.

Source code in anta/tests/multicast.py
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
class VerifyIGMPSnoopingVlans(AntaTest):
    """
    Verifies the IGMP snooping configuration for some VLANs.
    """

    name = "VerifyIGMPSnoopingVlans"
    description = "Verifies the IGMP snooping configuration for some VLANs."
    categories = ["multicast", "igmp"]
    commands = [AntaCommand(command="show ip igmp snooping")]

    class Input(AntaTest.Input):  # pylint: disable=missing-class-docstring
        vlans: Dict[Vlan, bool]
        """Dictionary of VLANs with associated IGMP configuration status (True=enabled, False=disabled)"""

    @AntaTest.anta_test
    def test(self) -> None:
        command_output = self.instance_commands[0].json_output
        self.result.is_success()
        for vlan, enabled in self.inputs.vlans.items():
            if str(vlan) not in command_output["vlans"]:
                self.result.is_failure(f"Supplied vlan {vlan} is not present on the device.")
                continue

            igmp_state = command_output["vlans"][str(vlan)]["igmpSnoopingState"]
            if igmp_state != "enabled" if enabled else igmp_state != "disabled":
                self.result.is_failure(f"IGMP state for vlan {vlan} is {igmp_state}")

Input

Bases: Input

Source code in anta/tests/multicast.py
28
29
30
class Input(AntaTest.Input):  # pylint: disable=missing-class-docstring
    vlans: Dict[Vlan, bool]
    """Dictionary of VLANs with associated IGMP configuration status (True=enabled, False=disabled)"""

vlans instance-attribute

vlans: Dict[Vlan, bool]

Dictionary of VLANs with associated IGMP configuration status (True=enabled, False=disabled)


Last update: August 18, 2023