Skip to content

Commit 43eeb58

Browse files
vdahiya12hdwhdw
authored andcommitted
[ansible][minigraph] add support for adding autonegotiation in minigraph templates and fanout EOS (sonic-net#13990)
These changes add a support for adding auto negotiation to specific testbed based on variables defined in ansible Two things are required for autoneg support 1. autoneg_enabled : True must be enabled in inventory files 2. t0 topo file must have a port list for autoneg Example: intfs : [1, 2, 3, 4, 5, 6, 7, 8] With these changes the PR includes changes to pick the port numbering from topo file and apply minigraph parsing changes such that during deploy-mg or gen-mg the required ports have autoneg and deployment is clean with link up Signed-off-by: Vaibhav Dahiya <[email protected]>
1 parent 75e8359 commit 43eeb58

8 files changed

Lines changed: 55 additions & 2 deletions

File tree

ansible/TestbedProcessing.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def makeTestbed(data, outfile):
311311

312312

313313
def makeSonicLabLinks(data, outfile):
314-
csv_columns = "StartDevice,StartPort,EndDevice,EndPort,BandWidth,VlanID,VlanMode,SlotId"
314+
csv_columns = "StartDevice,StartPort,EndDevice,EndPort,BandWidth,VlanID,VlanMode,AutoNeg,SlotId"
315315
topology = data
316316
csv_file = outfile
317317

@@ -331,6 +331,7 @@ def makeSonicLabLinks(data, outfile):
331331
bandWidth = element.get("Bandwidth")
332332
vlanID = element.get("VlanID")
333333
vlanMode = element.get("VlanMode")
334+
AutoNeg = element.get("AutoNeg")
334335
slotId = element.get("SlotId")
335336

336337
# catch empty values
@@ -346,10 +347,13 @@ def makeSonicLabLinks(data, outfile):
346347
vlanMode = ""
347348
if not slotId:
348349
slotId = ""
350+
if not AutoNeg:
351+
AutoNeg = ""
349352

350353
row = startDevice + "," + startPort + "," + endDevice + "," + \
351354
endPort + "," + str(bandWidth) + \
352355
"," + str(vlanID) + "," + vlanMode + \
356+
"," + str(AutoNeg) + \
353357
"," + str(slotId)
354358
f.write(row + "\n")
355359
except IOError:

ansible/library/conn_graph_facts.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ def csv_to_graph_facts(self):
299299
band_width = link["BandWidth"]
300300
vlan_ID = link["VlanID"]
301301
vlan_mode = link["VlanMode"]
302+
autoneg_mode = link.get("AutoNeg", "off")
302303

303304
if start_device not in links:
304305
links[start_device] = {}
@@ -313,11 +314,13 @@ def csv_to_graph_facts(self):
313314
"peerdevice": end_device,
314315
"peerport": end_port,
315316
"speed": band_width,
317+
"autoneg": autoneg_mode,
316318
}
317319
links[end_device][end_port] = {
318320
"peerdevice": start_device,
319321
"peerport": start_port,
320322
"speed": band_width,
323+
"autoneg": autoneg_mode,
321324
}
322325

323326
port_vlans[start_device][start_port] = {

ansible/library/topo_facts.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ def get_topo_config(self, topo_name, hwsku, testbed_name, asics_present, card_ty
334334

335335
if 'DUT' in topo_definition['topology']:
336336
vm_topo_config['DUT'] = topo_definition['topology']['DUT']
337+
if 'autoneg_interfaces' in vm_topo_config['DUT']:
338+
vm_topo_config['autoneg_interfaces'] = topo_definition['topology']['DUT']['autoneg_interfaces']
337339
else:
338340
vm_topo_config['DUT'] = {}
339341

ansible/roles/fanout/templates/arista_7060_deploy.j2

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,20 @@ interface defaults
3636
{% for intf in device_port_vlans[inventory_hostname] %}
3737
interface {{ intf }}
3838
description {{ device_conn[inventory_hostname][intf]['peerdevice'] }}-{{ device_conn[inventory_hostname][intf]['peerport'] }}
39+
# TODO: Add an additional var/check in fanout devices if autoneg is enabled with the below check
40+
{% if device_conn[inventory_hostname][intf]['autoneg']|lower == "on" %}
41+
speed auto {{ device_conn[inventory_hostname][intf]['speed'] }}full
42+
{% else %}
3943
speed force {{ device_conn[inventory_hostname][intf]['speed'] }}full
44+
{% endif %}
4045
{% if device_port_vlans[inventory_hostname][intf]['mode'] == 'Trunk' %}
4146
switchport mode trunk
4247
switchport trunk allowed vlan {{ device_port_vlans[inventory_hostname][intf]['vlanids'] }}
4348
{% else %}
4449
switchport mode dot1q-tunnel
4550
switchport access vlan {{ device_port_vlans[inventory_hostname][intf]['vlanids'] }}
46-
{% if device_conn[inventory_hostname][intf]['speed'] == "100000" %}
51+
# TODO: Add an additional var/check in fanout devices if autoneg is enabled with the below check
52+
{% if device_conn[inventory_hostname][intf]['speed'] == "100000" and device_conn[inventory_hostname][intf]['autoneg']|lower == "off" %}
4753
error-correction encoding reed-solomon
4854
{% else %}
4955
no error-correction encoding

ansible/templates/minigraph_link_meta.j2

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,30 @@
5252
</Link>
5353
</LinkMetadataDeclaration>
5454
{% endif %}
55+
56+
{% if msft_an_enabled is defined %}
57+
<LinkMetadataDeclaration>
58+
<Link xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
59+
{% for if_index in vm_topo_config['autoneg_interfaces']['intfs'] %}
60+
{% set autoneg_intf = "Ethernet" ~ if_index ~ "/1" %}
61+
{% if device_conn[inventory_hostname][port_alias_map[autoneg_intf]]['autoneg']|lower == "on" %}
62+
<a:LinkMetadata>
63+
<a:Name i:nil="true"/>
64+
<a:Properties>
65+
<a:DeviceProperty>
66+
<a:Name>AutoNegotiation</a:Name>
67+
<a:Value>True</a:Value>
68+
</a:DeviceProperty>
69+
<a:DeviceProperty>
70+
<a:Name>FECDisabled</a:Name>
71+
<a:Reference i:nil="true"/>
72+
<a:Value>True</a:Value>
73+
</a:DeviceProperty>
74+
</a:Properties>
75+
<a:Key>{{ device_conn[inventory_hostname][port_alias_map[autoneg_intf]]['peerdevice'] }}:{{ device_conn[inventory_hostname][port_alias_map[autoneg_intf]]['peerport'] }};{{ inventory_hostname }}:{{ autoneg_intf }}</a:Key>
76+
</a:LinkMetadata>
77+
{% endif %}
78+
{% endfor %}
79+
</Link>
80+
</LinkMetadataDeclaration>
81+
{% endif %}

ansible/templates/minigraph_meta.j2

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@
136136
<a:Value>{{ switch_type }}</a:Value>
137137
</a:DeviceProperty>
138138
{% endif %}
139+
{% if msft_an_enabled is defined %}
140+
<a:DeviceProperty>
141+
<a:Name>AutoNegotiation</a:Name>
142+
<a:Reference i:nil="true"/>
143+
<a:Value>{{ msft_an_enabled }}</a:Value>
144+
</a:DeviceProperty>
145+
{% endif %}
139146
{% if num_asics == 1 and switch_type is defined and switch_type == 'voq' %}
140147
<a:DeviceProperty>
141148
<a:Name>SwitchId</a:Name>

ansible/vars/topo_t0-116.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ topology:
134134
- 31
135135
vm_offset: 3
136136
DUT:
137+
autoneg_interfaces:
138+
intfs: [13, 14, 15, 16]
137139
vlan_configs:
138140
default_vlan_config: one_vlan_a
139141
one_vlan_a:

ansible/vars/topo_t0.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ topology:
5151
- 31
5252
vm_offset: 3
5353
DUT:
54+
autoneg_interfaces:
55+
intfs: [7, 8, 9, 10]
5456
vlan_configs:
5557
default_vlan_config: one_vlan_a
5658
one_vlan_a:

0 commit comments

Comments
 (0)