Skip to content

Implement attribute based infra for transceiver onboarding#21042

Merged
prgeor merged 7 commits intosonic-net:masterfrom
mihirpat1:transceiver-attribute-infra
Mar 7, 2026
Merged

Implement attribute based infra for transceiver onboarding#21042
prgeor merged 7 commits intosonic-net:masterfrom
mihirpat1:transceiver-attribute-infra

Conversation

@mihirpat1
Copy link
Contributor

@mihirpat1 mihirpat1 commented Oct 20, 2025

Description of PR

Code changes to support the attribute infra per #20230 for onboarding transceivers

Summary:
Fixes # (issue)

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • New Test case
    • Skipped for non-supported platforms
  • Test case improvement

Back port request

  • 202205
  • 202305
  • 202311
  • 202405
  • 202411
  • 202505

Approach

What is the motivation for this PR?

Code changes to support the attribute infra per #20230 for onboarding transceivers

How did you do it?

  • Add attribute_manager.py for layered attribute merging
  • Add config_parser.py for transceiver configuration parsing
  • Add dut_info_loader.py for DUT inventory loading
  • Add port_spec.py for port specification expansion
  • Add comprehensive test suite with 17 passing tests
  • Add conftest.py for test fixtures
  • Add a basic test to validate transceiver EEPROM
  • Added transceiver_attribute_infra_test.py file to manually test the attribute infrastructure. Usage details has been captured in the file itself

How did you verify/test it?

Ensured that the sonic-mgmt test passes

Any platform specific information?

Supported testbed topology if it's a new test case?

Documentation

#20230

ADO - 35139411

@mssonicbld
Copy link
Collaborator

/azp run

@mihirpat1 mihirpat1 requested a review from Copilot October 20, 2025 22:09
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements an attribute-based infrastructure for transceiver onboarding, introducing a layered configuration system that merges base port attributes with category-specific attributes (e.g., EEPROM) using a priority-based resolution mechanism. The infrastructure supports deployment template validation to ensure required attributes are present.

Key changes:

  • Multi-layer attribute merging system with 8 priority levels (defaults → platform → hwsku → deployment → vendor → part number → platform overrides → DUT-specific)
  • Port specification expansion supporting ranges, steps, and mixed formats
  • Comprehensive test suite with 17 tests validating core functionality and error scenarios

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/transceiver/infra/utils.py Utility function for formatting nested dictionaries in log output
tests/transceiver/infra/test_transceiver_attribute_infra.py Comprehensive test suite covering attribute loading, merging, validation, and error handling
tests/transceiver/infra/template_validator.py Validates port attributes against deployment templates with compliance reporting
tests/transceiver/infra/port_spec.py Expands port specifications (ranges, steps, lists) into individual port names
tests/transceiver/infra/paths.py Centralized path constants for inventory structure
tests/transceiver/infra/exceptions.py Custom exception classes for attribute infrastructure
tests/transceiver/infra/dut_info_loader.py Loads and processes dut_info.json to build base port attributes
tests/transceiver/infra/config_parser.py Parses transceiver configuration strings into structured components
tests/transceiver/infra/attribute_manager.py Merges category attributes with base attributes using priority resolution
tests/transceiver/eeprom/test_eeprom_basic.py Test validating EEPROM content via CLI against expected attributes
tests/transceiver/conftest.py Pytest fixtures for attribute infrastructure initialization and validation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mihirpat1 mihirpat1 requested a review from Copilot October 20, 2025 23:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mihirpat1 mihirpat1 force-pushed the transceiver-attribute-infra branch from 04c5faa to 7fc2181 Compare October 21, 2025 00:13
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mihirpat1 mihirpat1 requested a review from Copilot October 21, 2025 00:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@mihirpat1 mihirpat1 marked this pull request as ready for review October 22, 2025 21:41


# Root directory (relative to repository root)
REL_TRANSCEIVER_INV_DIR = os.path.join('ansible', 'files', 'transceiver', 'inventory')
Copy link
Contributor

@az-pz az-pz Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it cause issue if the test is run from different directory? Have we thought about using pathlib.Path(__file__) and then traversing from there to get to the root directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@az-pz I have addressed this now

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mihirpat1 mihirpat1 force-pushed the transceiver-attribute-infra branch from d12be9d to 473ca8a Compare January 2, 2026 20:41
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

- Add attribute_manager.py for layered attribute merging
- Add config_parser.py for transceiver configuration parsing
- Add dut_info_loader.py for DUT inventory loading
- Add port_spec.py for port specification expansion
- Add comprehensive test suite with 17 passing tests
- Add eeprom attribute validation tests
- Add conftest.py for test fixtures

Signed-off-by: Mihir Patel <patelmi@microsoft.com>
Signed-off-by: Mihir Patel <patelmi@microsoft.com>
Signed-off-by: Mihir Patel <patelmi@microsoft.com>
Signed-off-by: Mihir Patel <patelmi@microsoft.com>
Signed-off-by: Mihir Patel <patelmi@microsoft.com>
@mihirpat1 mihirpat1 force-pushed the transceiver-attribute-infra branch from 473ca8a to a4d41df Compare January 2, 2026 20:42
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Mihir Patel <patelmi@microsoft.com>
@mihirpat1 mihirpat1 force-pushed the transceiver-attribute-infra branch from 1e1be4b to e1bb47b Compare March 6, 2026 23:09
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Mihir Patel <patelmi@microsoft.com>
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@prgeor prgeor merged commit 25422ec into sonic-net:master Mar 7, 2026
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants