Skip to content

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
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ansible/config_sonic_basedon_testbed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,13 @@

when: "'dualtor-mixed' in topo or 'dualtor-aa' in topo"

- name: Apply device conn to config db
apply_device_conn_sonic:
Copy link
Contributor

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

Copy link
Contributor Author

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?

hostname: "{{ inventory_hostname }}"
device_conn: "{{ device_conn[inventory_hostname] }}"
become: true
when: inventory_hostname is defined and device_conn is defined and inventory_hostname in device_conn

- name: execute cli "config save -y" to save current minigraph as startup-config
become: true
shell: config save -y
Expand Down
76 changes: 76 additions & 0 deletions ansible/library/apply_device_conn_sonic.py
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

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()
2 changes: 1 addition & 1 deletion ansible/roles/fanout/tasks/sonic/fanout_sonic_202311.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@

- name: wait for SONiC update config db finish
pause:
seconds: 180
seconds: 300

- name: Shutdown arp_update process in swss (avoid fanout broadcasting it's MAC address)
shell: docker exec -i swss supervisorctl stop arp_update
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/fanout/tasks/sonic/fanout_sonic_202405.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@

- name: wait for SONiC update config db finish
pause:
seconds: 180
seconds: 300

- name: Shutdown arp_update process in swss (avoid fanout broadcasting it's MAC address)
shell: docker exec -i swss supervisorctl stop arp_update
Expand Down
4 changes: 4 additions & 0 deletions ansible/roles/fanout/templates/sonic_deploy_202405.j2
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
"mtu": "9100",
{% if fanout_hwsku == "Arista-720DT-G48S4" and (fanout_port_config[port_name]['lanes'] | int) <= 24 %}
"autoneg": "on",
{% else %}
{% if port_name in device_conn[inventory_hostname] and 'autoneg' in device_conn[inventory_hostname][port_name] %}
"autoneg": "{{ device_conn[inventory_hostname][port_name]['autoneg'] }}",
{% endif %}
{% endif %}
{% if fanout_port_config[port_name]['speed'] | default('100000') == "100000" %}
"fec" : "rs",
Expand Down
Loading