-
Notifications
You must be signed in to change notification settings - Fork 851
Increase timeout and set port AutonNeg according to the links file #16647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Pterosaur
wants to merge
5
commits into
sonic-net:master
Choose a base branch
from
Pterosaur:device_conn_autoneg
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
82224ef
Increase timeout and set autoneg according to links file
Pterosaur 9617015
Set autoneg on for both SP3 and SP4
Pterosaur e58b945
Remove SP3 SP4 specific code in fanout template
Pterosaur d697a79
Remove SP3 SP4 specific code in dut
Pterosaur 1ed25a8
Refactor autoneg via minigraph of DPU
Pterosaur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Pterosaur This file change is not needed. The link file has the AN column and the minigraph should be able to generate the configuration for the AN enabled port. @vdahiya12 can you point to that? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/usr/bin/env python | ||
|
||
from ansible.module_utils.basic import AnsibleModule | ||
import traceback | ||
import subprocess | ||
import shlex | ||
|
||
|
||
def get_port_lists(): | ||
cmd = "show interfaces description | grep Ethernet | awk '{print $1}'" | ||
ps = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | ||
output = ps.communicate()[0].decode('utf-8') | ||
port_list = [line for line in output.split('\n') if line.strip()] | ||
return port_list | ||
|
||
|
||
def get_platform(): | ||
cmd = "redis-cli --raw -n 4 hget 'DEVICE_METADATA|localhost' 'platform'" | ||
ps = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | ||
output = ps.communicate()[0].decode('utf-8') | ||
return output.strip() | ||
|
||
|
||
def set_autoneg(port, value): | ||
if value == "on": | ||
value = "enabled" | ||
elif value == "off": | ||
value = "disabled" | ||
else: | ||
raise Exception("Invalid autoneg value: %s" % value) | ||
cmd = "config interface autoneg %s %s" % (port, value) | ||
ps = subprocess.Popen(shlex.split(cmd), shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | ||
(_, stderr) = ps.communicate() | ||
if ps.returncode != 0: | ||
if stderr: | ||
stderr = stderr.decode('utf-8') | ||
raise Exception("Failed to set autoneg for port %s: %s" % (port, stderr)) | ||
|
||
|
||
def apply_device_conn(module, platform, port_list, device_conn): | ||
# Apply Autoneg | ||
for port in port_list: | ||
if port in device_conn: | ||
attribute = device_conn[port] | ||
if "autoneg" in attribute: | ||
autoneg_value = attribute["autoneg"] | ||
module.warn("Set autoneg for port %s to %s" % (port, autoneg_value)) | ||
set_autoneg(port, autoneg_value) | ||
|
||
|
||
def main(): | ||
module = AnsibleModule( | ||
argument_spec=dict( | ||
hostname=dict(required=False), | ||
device_conn=dict(required=True, type=dict) | ||
) | ||
) | ||
|
||
platform = get_platform() | ||
port_list = get_port_lists() | ||
device_conn = module.params['device_conn'] | ||
|
||
apply_device_conn(module, platform, port_list, device_conn) | ||
|
||
try: | ||
pass | ||
except Exception as detail: | ||
module.fail_json(msg="ERROR: %s, TRACEBACK: %s" % | ||
(repr(detail), traceback.format_exc())) | ||
module.exit_json( | ||
ansible_facts=dict() | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this for applying sonic config?
much of the config DB config will happen via #13990
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure the AutoNeg value in minigraph will be applied into the config DB?