Skip to content

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

Merged
kperumalbfn merged 4 commits intosonic-net:202411from
vdahiya12:dev/vdahiya/fix-con1
Mar 4, 2025
Merged

[ansible] Correct the formatting for linkmetadata minigraph generation for autonegotiation (#17191)#17277
kperumalbfn merged 4 commits intosonic-net:202411from
vdahiya12:dev/vdahiya/fix-con1

Conversation

@vdahiya12
Copy link
Contributor

@vdahiya12 vdahiya12 commented Mar 2, 2025

cherry-pick #17191

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

…n for autonegotiation (sonic-net#17191)

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

Signed-off-by: Vaibhav Dahiya <vdahiya@microsoft.com>

* retab

Signed-off-by: Vaibhav Dahiya <vdahiya@microsoft.com>

* rebase

Signed-off-by: Vaibhav Dahiya <vdahiya@microsoft.com>

* add more formatting

Signed-off-by: Vaibhav Dahiya <vdahiya@microsoft.com>

---------

Signed-off-by: Vaibhav Dahiya <vdahiya@microsoft.com>
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

prgeor
prgeor previously approved these changes Mar 2, 2025
Signed-off-by: Vaibhav Dahiya <vdahiya@microsoft.com>
Signed-off-by: Vaibhav Dahiya <vdahiya@microsoft.com>
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Vaibhav Dahiya <vdahiya@microsoft.com>
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@kperumalbfn kperumalbfn merged commit 588208d into sonic-net:202411 Mar 4, 2025
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.

4 participants