summaryrefslogtreecommitdiffstats
path: root/anta/tests/ptp.py
blob: 9db810da9437dca7f792d02493a8e40595c03b8d (plain)
1
2
3
4
5
6
7
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
# Copyright (c) 2023-2024 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the LICENSE file.
"""
Test functions related to PTP (Precision Time Protocol) in EOS
"""
from __future__ import annotations

from anta.models import AntaCommand, AntaTest


class VerifyPtpStatus(AntaTest):
    """
    Verifies whether the PTP agent is enabled globally.

    Expected Results:
        * success: The test will pass if the PTP agent is enabled globally.
        * failure: The test will fail if the PTP agent is enabled globally.
    """

    name = "VerifyPtpStatus"
    description = "Verifies if the PTP agent is enabled."
    categories = ["ptp"]
    commands = [AntaCommand(command="show ptp")]

    @AntaTest.anta_test
    def test(self) -> None:
        command_output = self.instance_commands[0].json_output

        if "ptpMode" in command_output.keys():
            self.result.is_success()
        else:
            self.result.is_failure("PTP agent disabled")