Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion nodescraper/plugins/inband/switch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
###############################################################################
from .scale_out_arista import ScaleOutAristaPlugin
from .scale_out_dell import ScaleOutDellPlugin
from .scale_up_sonic import ScaleUpSonicPlugin

__all__ = ["ScaleOutAristaPlugin", "ScaleOutDellPlugin"]
__all__ = ["ScaleOutAristaPlugin", "ScaleOutDellPlugin", "ScaleUpSonicPlugin"]
28 changes: 28 additions & 0 deletions nodescraper/plugins/inband/switch/scale_up_sonic/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
###############################################################################
#
# MIT License
#
# Copyright (c) 2026 Advanced Micro Devices, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
###############################################################################
from .scale_up_sonic_plugin import ScaleUpSonicPlugin

__all__ = ["ScaleUpSonicPlugin"]
47 changes: 47 additions & 0 deletions nodescraper/plugins/inband/switch/scale_up_sonic/analyzer_args.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
###############################################################################
#
# MIT License
#
# Copyright (c) 2026 Advanced Micro Devices, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
###############################################################################
from typing import List, Optional

from pydantic import Field

from nodescraper.models import AnalyzerArgs


class ScaleUpSonicAnalyzerArgs(AnalyzerArgs):
"""Arguments for the scale up SONiC switch analyzer."""

analysis_ports: Optional[List[str]] = Field(
default=None,
description=(
"Restrict per-port analysis to the given full port names "
"(e.g. ['Ethernet1', 'Ethernet31']). "
"When omitted, every port present in the data is analyzed."
),
)
expected_port_speed: str = Field(
default="400G",
description=("Expected interface speed from show interface status "),
)
40 changes: 40 additions & 0 deletions nodescraper/plugins/inband/switch/scale_up_sonic/collector_args.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
###############################################################################
#
# MIT License
#
# Copyright (c) 2026 Advanced Micro Devices, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
###############################################################################
from pydantic import Field

from nodescraper.models import CollectorArgs


class ScaleUpSonicCollectorArgs(CollectorArgs):
"""Arguments for the scale up SONiC switch collector."""

html_view: bool = Field(
default=True,
description=(
"When true, include logged command artifacts in command_artifacts.html "
"using human-readable output."
),
)
29 changes: 29 additions & 0 deletions nodescraper/plugins/inband/switch/scale_up_sonic/port_names.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
###############################################################################
#
# MIT License
#
# Copyright (c) 2026 Advanced Micro Devices, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
###############################################################################

import re

PORT_TOKEN_RE = re.compile(r"^(Ethernet\d+)$")
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
###############################################################################
#
# MIT License
#
# Copyright (c) 2026 Advanced Micro Devices, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
###############################################################################

import re
from typing import Any, ClassVar

from pydantic import BaseModel

from nodescraper.interfaces import DataAnalyzer

from ..switch_analyzer_base import SwitchAnalyzerBase
from .analyzer_args import ScaleUpSonicAnalyzerArgs
from .port_names import PORT_TOKEN_RE
from .scaleupsonicdata import ScaleUpSonicDataModel, SonicPortData


class ScaleUpSonicAnalyzer(
SwitchAnalyzerBase[ScaleUpSonicDataModel],
DataAnalyzer[ScaleUpSonicDataModel, ScaleUpSonicAnalyzerArgs],
):
"""Check scale up SONiC switch data for errors and warnings.

Walks every model in the collected :class:`ScaleUpSonicDataModel` and checks
each ``error_fields`` / ``warning_fields`` ClassVar against an optional
``ports`` filter.
"""

VENDOR_NAME: ClassVar[str] = "SONiC"
DATA_MODEL = ScaleUpSonicDataModel

PORT_NAME_RE: ClassVar[re.Pattern] = PORT_TOKEN_RE
PORT_FORMAT_HINT: ClassVar[str] = "expected full port name 'Ethernet<N>' (e.g. 'Ethernet1')"

def _extra_port_findings(self, port_name: str, port_data: BaseModel) -> list[dict[str, Any]]:
if not isinstance(port_data, SonicPortData):
return []

args = self._analyzer_args
if not isinstance(args, ScaleUpSonicAnalyzerArgs):
args = ScaleUpSonicAnalyzerArgs()

status = port_data.interface_status
if status is None:
return []

finding = self._port_field_mismatch(
port_name,
"interface_status",
"speed",
status.speed,
args.expected_port_speed,
"SonicInterfaceStatus",
)
return [finding] if finding else []
Loading
Loading