Skip to content

[action] [PR:17191] [ansible] Correct the formatting for linkmetadata minigraph generation for autonegotiation#170

Merged
mssonicbld merged 1 commit intoAzure:202405from
mssonicbld:cherry/msft-202405/17191
Mar 26, 2025
Merged

[action] [PR:17191] [ansible] Correct the formatting for linkmetadata minigraph generation for autonegotiation#170
mssonicbld merged 1 commit intoAzure:202405from
mssonicbld:cherry/msft-202405/17191

Conversation

@mssonicbld
Copy link
Copy Markdown
Collaborator

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

<!--
Please make sure you've read and understood our contributing guidelines;
https://github.com/sonic-net/SONiC/blob/gh-pages/CONTRIBUTING.md

Please provide following information to help code review process a bit easier:
-->
### 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.
<!--
- Please include a summary of the change and which issue is fixed.
- Please also include relevant motivation and context. Where should reviewer start? background context?
- List any dependencies that are required for this change.
-->

Summary:
Fixes # (issue)

### Type of change

<!--
- Fill x for your type of change.
- e.g.
- [x] Bug fix
-->

- [ ] 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
<!--
(If it's a new feature, new test case)
Did you update documentation/Wiki relevant to your implementation?
Link to the wiki page?
-->
@mssonicbld
Copy link
Copy Markdown
Collaborator Author

Original PR: sonic-net/sonic-mgmt#17191

@mssonicbld
Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

@mssonicbld mssonicbld merged commit b61a9d8 into Azure:202405 Mar 26, 2025
4 checks passed
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.

1 participant