Skip to content

[ansible] Correct the formatting for linkmetadata minigraph generation for autonegotiation#17191

Merged
bingwang-ms merged 4 commits intosonic-net:masterfrom
vdahiya12:dev/vdahiya/fix-t
Feb 27, 2025
Merged

[ansible] Correct the formatting for linkmetadata minigraph generation for autonegotiation#17191
bingwang-ms merged 4 commits intosonic-net:masterfrom
vdahiya12:dev/vdahiya/fix-t

Conversation

@vdahiya12
Copy link
Contributor

Description of PR

This PR refactors minigraph_link_meta.j2 by:

  • Replacing link_metadata_defined with Jinja2 namespace (ns) for better variable scoping.
  • Optimizing auto-negotiation detection using selectattr() to reduce looping.
  • Improving code readability with structured formatting and consistent indentation.
    These changes enhance efficiency and maintainability without altering functionality.

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

  • 202012
  • 202205
  • 202305
  • 202311
  • 202405
  • 202411

Approach

What is the motivation for this PR?

Correct the minigraph generation For autoneg in SONiC

How did you do it?

How did you verify/test it?

This minigraph is generated

<LinkMetadataDeclaration>
    <Link xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
                <a:LinkMetadata>
                    <a:Name i:nil="true"/>
                    <a:Properties>
                        <a:DeviceProperty>
                            <a:Name>AutoNegotiation</a:Name>
                            <a:Value>True</a:Value>
                        </a:DeviceProperty>
                        <a:DeviceProperty>
                            <a:Name>FECDisabled</a:Name>
                            <a:Reference i:nil="true"/>
                            <a:Value>True</a:Value>
                        </a:DeviceProperty>
                    </a:Properties>
                    <a:Key>fanout1:Ethernet39/1;sonic1:Ethernet7/1</a:Key>
                </a:LinkMetadata>
                <a:LinkMetadata>
                    <a:Name i:nil="true"/>
                    <a:Properties>
                        <a:DeviceProperty>
                            <a:Name>AutoNegotiation</a:Name>
                            <a:Value>True</a:Value>
                        </a:DeviceProperty>
                        <a:DeviceProperty>
                            <a:Name>FECDisabled</a:Name>
                            <a:Reference i:nil="true"/>
                            <a:Value>True</a:Value>
                        </a:DeviceProperty>
                    </a:Properties>
                    <a:Key>fanout1:Ethernet40/1;sonic1:Ethernet8/1</a:Key>
                </a:LinkMetadata>
                <a:LinkMetadata>
                    <a:Name i:nil="true"/>
                    <a:Properties>
                        <a:DeviceProperty>
                            <a:Name>AutoNegotiation</a:Name>
                            <a:Value>True</a:Value>
                        </a:DeviceProperty>
                        <a:DeviceProperty>
                            <a:Name>FECDisabled</a:Name>
                            <a:Reference i:nil="true"/>
                            <a:Value>True</a:Value>
                        </a:DeviceProperty>
                    </a:Properties>
                    <a:Key>fanout1:Ethernet41/1;sonic1:Ethernet9/1</a:Key>
                </a:LinkMetadata>
                <a:LinkMetadata>
                    <a:Name i:nil="true"/>
                    <a:Properties>
                        <a:DeviceProperty>
                            <a:Name>AutoNegotiation</a:Name>
                            <a:Value>True</a:Value>
                        </a:DeviceProperty>
                        <a:DeviceProperty>
                            <a:Name>FECDisabled</a:Name>
                            <a:Reference i:nil="true"/>
                            <a:Value>True</a:Value>
                        </a:DeviceProperty>
                    </a:Properties>
                    <a:Key>fanout1:Ethernet42/1;sonic1:Ethernet10/1</a:Key>
                </a:LinkMetadata>
  </Link>
</LinkMetadataDeclaration>

Any platform specific information?

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

Documentation

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Vaibhav Dahiya <[email protected]>
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Vaibhav Dahiya <[email protected]>
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Vaibhav Dahiya <[email protected]>
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

@vdahiya12 PR conflicts with 202411 branch

vdahiya12 added a commit to vdahiya12/sonic-mgmt that referenced this pull request Mar 2, 2025
…n for autonegotiation (sonic-net#17191)

* [ansible] Correct the formatting for linkmetadata minigraph generation for autonegotiation

Signed-off-by: Vaibhav Dahiya <[email protected]>

* retab

Signed-off-by: Vaibhav Dahiya <[email protected]>

* rebase

Signed-off-by: Vaibhav Dahiya <[email protected]>

* add more formatting

Signed-off-by: Vaibhav Dahiya <[email protected]>

---------

Signed-off-by: Vaibhav Dahiya <[email protected]>
kperumalbfn pushed a commit that referenced this pull request Mar 4, 2025
…n for autonegotiation (#17191) (#17277)

[ansible] Correct the formatting for linkmetadata minigraph generation for autonegotiation
nissampa pushed a commit to nissampa/sonic-mgmt_dpu_test that referenced this pull request Mar 4, 2025
…n for autonegotiation (sonic-net#17191)

* [ansible] Correct the formatting for linkmetadata minigraph generation for autonegotiation

Signed-off-by: Vaibhav Dahiya <[email protected]>

* retab

Signed-off-by: Vaibhav Dahiya <[email protected]>

* rebase

Signed-off-by: Vaibhav Dahiya <[email protected]>

* add more formatting

Signed-off-by: Vaibhav Dahiya <[email protected]>

---------

Signed-off-by: Vaibhav Dahiya <[email protected]>
nnelluri-cisco pushed a commit to nnelluri-cisco/sonic-mgmt that referenced this pull request Mar 15, 2025
…n for autonegotiation (sonic-net#17191)

* [ansible] Correct the formatting for linkmetadata minigraph generation for autonegotiation

Signed-off-by: Vaibhav Dahiya <[email protected]>

* retab

Signed-off-by: Vaibhav Dahiya <[email protected]>

* rebase

Signed-off-by: Vaibhav Dahiya <[email protected]>

* add more formatting

Signed-off-by: Vaibhav Dahiya <[email protected]>

---------

Signed-off-by: Vaibhav Dahiya <[email protected]>
@mssonicbld
Copy link
Collaborator

@vdahiya12 PR conflicts with 202411 branch

@mssonicbld
Copy link
Collaborator

Cherry-pick PR to msft-202405: Azure/sonic-mgmt.msft#170

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants