Skip to content

Commit

Permalink
Merge branch 'sonic-net:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
abdosi authored Oct 8, 2024
2 parents 2d140c7 + 5b83ba9 commit fb344dc
Show file tree
Hide file tree
Showing 72 changed files with 1,874 additions and 1,102 deletions.
6 changes: 5 additions & 1 deletion ansible/TestbedProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def makeTestbed(data, outfile):


def makeSonicLabLinks(data, outfile):
csv_columns = "StartDevice,StartPort,EndDevice,EndPort,BandWidth,VlanID,VlanMode,SlotId"
csv_columns = "StartDevice,StartPort,EndDevice,EndPort,BandWidth,VlanID,VlanMode,AutoNeg,SlotId"
topology = data
csv_file = outfile

Expand All @@ -331,6 +331,7 @@ def makeSonicLabLinks(data, outfile):
bandWidth = element.get("Bandwidth")
vlanID = element.get("VlanID")
vlanMode = element.get("VlanMode")
AutoNeg = element.get("AutoNeg")
slotId = element.get("SlotId")

# catch empty values
Expand All @@ -346,10 +347,13 @@ def makeSonicLabLinks(data, outfile):
vlanMode = ""
if not slotId:
slotId = ""
if not AutoNeg:
AutoNeg = ""

row = startDevice + "," + startPort + "," + endDevice + "," + \
endPort + "," + str(bandWidth) + \
"," + str(vlanID) + "," + vlanMode + \
"," + str(AutoNeg) + \
"," + str(slotId)
f.write(row + "\n")
except IOError:
Expand Down
3 changes: 3 additions & 0 deletions ansible/library/conn_graph_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ def csv_to_graph_facts(self):
band_width = link["BandWidth"]
vlan_ID = link["VlanID"]
vlan_mode = link["VlanMode"]
autoneg_mode = link.get("AutoNeg", "off")

if start_device not in links:
links[start_device] = {}
Expand All @@ -313,11 +314,13 @@ def csv_to_graph_facts(self):
"peerdevice": end_device,
"peerport": end_port,
"speed": band_width,
"autoneg": autoneg_mode,
}
links[end_device][end_port] = {
"peerdevice": start_device,
"peerport": start_port,
"speed": band_width,
"autoneg": autoneg_mode,
}

port_vlans[start_device][start_port] = {
Expand Down
2 changes: 2 additions & 0 deletions ansible/library/topo_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ def get_topo_config(self, topo_name, hwsku, testbed_name, asics_present, card_ty

if 'DUT' in topo_definition['topology']:
vm_topo_config['DUT'] = topo_definition['topology']['DUT']
if 'autoneg_interfaces' in vm_topo_config['DUT']:
vm_topo_config['autoneg_interfaces'] = topo_definition['topology']['DUT']['autoneg_interfaces']
else:
vm_topo_config['DUT'] = {}

Expand Down
20 changes: 18 additions & 2 deletions ansible/module_utils/port_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,24 @@ def get_port_alias_to_name_map(hwsku, asic_name=None):
elif hwsku in ["Arista-7800R3-48CQ2-C48", "Arista-7800R3-48CQM2-C48"]:
for i in range(1, 49):
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 1) * 4)
elif hwsku == "Arista-7800R3A-36DM2-C36" or hwsku == "Arista-7800R3A-36DM2-D36":
for i in range(1, 36):
elif hwsku in ["Arista-7800R3A-36DM2-C36",
"Arista-7800R3AK-36DM2-C36",
"Arista-7800R3A-36DM2-D36"]:
for i in range(1, 37):
sonic_name = "Ethernet%d" % ((i - 1) * 8)
port_alias_to_name_map["Ethernet{}/{}".format(i, 1)] = sonic_name
elif hwsku == "Arista-7800R3A-36DM2-C72" or\
hwsku == "Arista-7800R3A-36D-C72" or\
hwsku == "Arista-7800R3A-36P-C72" or\
hwsku == "Arista-7800R3AK-36DM2-C72" or\
hwsku == "Arista-7800R3AK-36D2-C72" or\
hwsku == "Arista-7800R3A-36D2-C72":

intf_idx = 0
for i in range(1, 37):
for j in [1, 5]:
port_alias_to_name_map["Ethernet%d/%d" % (i, j)] = "Ethernet%d" % intf_idx
intf_idx += 4
elif hwsku == "INGRASYS-S9100-C32":
for i in range(1, 33):
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 1) * 4)
Expand Down Expand Up @@ -410,6 +424,8 @@ def get_port_alias_to_name_map(hwsku, asic_name=None):
for i in range(1, 33):
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 1) * 8)
else:
if "Arista-7800" in hwsku:
assert False, "Please add port_alias_to_name_map for new modular SKU %s." % hwsku
for i in range(0, 128, 4):
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % i

Expand Down
8 changes: 7 additions & 1 deletion ansible/roles/fanout/templates/arista_7060_deploy.j2
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,20 @@ interface defaults
{% for intf in device_port_vlans[inventory_hostname] %}
interface {{ intf }}
description {{ device_conn[inventory_hostname][intf]['peerdevice'] }}-{{ device_conn[inventory_hostname][intf]['peerport'] }}
# TODO: Add an additional var/check in fanout devices if autoneg is enabled with the below check
{% if device_conn[inventory_hostname][intf]['autoneg']|lower == "on" %}
speed auto {{ device_conn[inventory_hostname][intf]['speed'] }}full
{% else %}
speed force {{ device_conn[inventory_hostname][intf]['speed'] }}full
{% endif %}
{% if device_port_vlans[inventory_hostname][intf]['mode'] == 'Trunk' %}
switchport mode trunk
switchport trunk allowed vlan {{ device_port_vlans[inventory_hostname][intf]['vlanids'] }}
{% else %}
switchport mode dot1q-tunnel
switchport access vlan {{ device_port_vlans[inventory_hostname][intf]['vlanids'] }}
{% if device_conn[inventory_hostname][intf]['speed'] == "100000" %}
# TODO: Add an additional var/check in fanout devices if autoneg is enabled with the below check
{% if device_conn[inventory_hostname][intf]['speed'] == "100000" and device_conn[inventory_hostname][intf]['autoneg']|lower == "off" %}
error-correction encoding reed-solomon
{% else %}
no error-correction encoding
Expand Down
6 changes: 3 additions & 3 deletions ansible/roles/test/files/ptftests/arista.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,10 +594,10 @@ def change_bgp_route(self, cfg_map):
self.do_cmd(item)
self.do_cmd('exit')

def change_bgp_neigh_state(self, asn, is_up=True):
def change_bgp_neigh_state(self, bgp_info, is_up=True):
state = ['shut', 'no shut']
self.do_cmd('configure')
self.do_cmd('router bgp %s' % asn)
self.do_cmd('router bgp %s' % bgp_info['asn'])
if self.veos_version < 4.20:
self.do_cmd('%s' % state[is_up])
else:
Expand All @@ -619,7 +619,7 @@ def verify_bgp_neigh_state(self, dut=None, state="Active"):
data = '\n'.join(output.split('\r\n')[1:-1])
obj = json.loads(data)

if state == 'down':
if 'down' in state:
if 'vrfs' in obj:
# return True when obj['vrfs'] is empty which is the case when the bgp state is 'down'
bgp_state[ver] = not obj['vrfs']
Expand Down
9 changes: 9 additions & 0 deletions ansible/roles/test/files/ptftests/fib_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,15 @@ def get_src_and_exp_ports(self, dst_ip):
continue
if self.switch_type == "chassis-packet":
exp_port_lists = self.check_same_asic(src_port, exp_port_lists)
elif self.single_fib == "single-fib-single-hop" and exp_port_lists[0]:
dest_port_dut_index = self.ptf_test_port_map[str(exp_port_lists[0][0])]['target_dut'][0]
src_port_dut_index = self.ptf_test_port_map[str(src_port)]['target_dut'][0]
if src_port_dut_index == 0 and dest_port_dut_index == 0:
ptf_non_upstream_ports = []
for ptf_port, ptf_port_info in self.ptf_test_port_map.items():
if ptf_port_info['target_dut'][0] != 0:
ptf_non_upstream_ports.append(ptf_port)
src_port = int(random.choice(ptf_non_upstream_ports))
logging.info('src_port={}, exp_port_lists={}, active_dut_indexes={}'.format(
src_port, exp_port_lists, active_dut_indexes))
break
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/test/files/ptftests/host_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def run(self):
def verify_neigh_lag_no_flap(self):
raise NotImplementedError

def change_bgp_neigh_state(self, asn, is_up=True):
def change_bgp_neigh_state(self, bgp_info, is_up=True):
raise NotImplementedError

def change_bgp_route(self, cfg_map):
Expand Down
9 changes: 9 additions & 0 deletions ansible/roles/test/files/ptftests/py3/IP_decap_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,15 @@ def get_src_and_exp_ports(self, dst_ip):
if src_port in exp_port_list:
break
else:
if self.single_fib == "single-fib-single-hop" and exp_port_lists[0]:
dest_port_dut_index = self.ptf_test_port_map[str(exp_port_lists[0][0])]['target_dut'][0]
src_port_dut_index = self.ptf_test_port_map[str(src_port)]['target_dut'][0]
if src_port_dut_index == 0 and dest_port_dut_index == 0:
ptf_non_upstream_ports = []
for ptf_port, ptf_port_info in self.ptf_test_port_map.items():
if ptf_port_info['target_dut'][0] != 0:
ptf_non_upstream_ports.append(ptf_port)
src_port = int(random.choice(ptf_non_upstream_ports))
logging.info('src_port={}, exp_port_lists={}, active_dut_index={}'.format(
src_port, exp_port_lists, active_dut_indexes))
break
Expand Down
1 change: 1 addition & 0 deletions ansible/roles/test/files/ptftests/py3/advanced-reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def __init__(self):
self.check_param('asic_type', '', required=False)
self.check_param('logfile_suffix', None, required=False)
self.check_param('neighbor_type', 'eos', required=False)
self.check_param('port_channel_intf_idx', [], required=False)
if not self.test_params['preboot_oper'] or self.test_params['preboot_oper'] == 'None':
self.test_params['preboot_oper'] = None
if not self.test_params['inboot_oper'] or self.test_params['inboot_oper'] == 'None':
Expand Down
10 changes: 10 additions & 0 deletions ansible/roles/test/files/ptftests/py3/hash_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ def get_src_and_exp_ports(self, dst_ip):
if src_port in exp_port_list:
break
else:
if self.single_fib == "single-fib-single-hop" and exp_port_lists[0]:
dest_port_dut_index = self.ptf_test_port_map[str(exp_port_lists[0][0])]['target_dut'][0]
src_port_dut_index = self.ptf_test_port_map[str(src_port)]['target_dut'][0]
if src_port_dut_index == 0 and dest_port_dut_index == 0:
ptf_non_upstream_ports = []
for ptf_port, ptf_port_info in self.ptf_test_port_map.items():
if ptf_port_info['target_dut'][0] != 0:
ptf_non_upstream_ports.append(ptf_port)
src_port = int(random.choice(ptf_non_upstream_ports))

break
return src_port, exp_port_lists, next_hops

Expand Down
29 changes: 19 additions & 10 deletions ansible/roles/test/files/ptftests/sad_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import random

from arista import Arista
from sonic import Sonic
from device_connection import DeviceConnection


Expand Down Expand Up @@ -63,6 +64,7 @@ def __init__(self, oper_type, vm_list, portchannel_ports, vm_dut_map, test_args,
alt_password=test_args.get('alt_password'))
self.vlan_ports = vlan_ports
self.ports_per_vlan = ports_per_vlan
self.neighbor_type = self.test_args['neighbor_type']
self.vlan_if_port = self.test_args['vlan_if_port']
self.neigh_vms = []
self.neigh_names = dict()
Expand Down Expand Up @@ -138,7 +140,10 @@ def down_neigh_port(self):

def vm_connect(self):
for neigh_vm in self.neigh_vms:
self.vm_handles[neigh_vm] = Arista(neigh_vm, None, self.test_args)
if self.neighbor_type == "sonic":
self.vm_handles[neigh_vm] = Sonic(neigh_vm, None, self.test_args)
else:
self.vm_handles[neigh_vm] = Arista(neigh_vm, None, self.test_args)
self.vm_handles[neigh_vm].connect()

def __del__(self):
Expand Down Expand Up @@ -227,18 +232,17 @@ def populate_bgp_state(self):
[self.dut_needed.setdefault(vm, self.dut_bgps[vm])
for vm in self.neigh_vms]
if self.oper_type == 'neigh_bgp_down':
self.neigh_bgps['changed_state'] = 'down'
self.neigh_bgps['changed_state'] = 'down,Idle (Admin)'
self.dut_bgps['changed_state'] = 'Active'
[self.dut_needed.update({vm: None}) for vm in self.neigh_vms]
elif self.oper_type == 'dut_bgp_down':
self.neigh_bgps['changed_state'] = 'Active,OpenSent,Connect'
self.dut_bgps['changed_state'] = 'Idle'
elif 'neigh_lag' in self.oper_type:
# on the DUT side, bgp states are different pre and post boot. hence passing multiple values
self.neigh_bgps['changed_state'] = 'Idle'
self.neigh_bgps['changed_state'] = 'Active,Idle'
self.dut_bgps['changed_state'] = 'Connect,Active,Idle'
elif 'dut_lag' in self.oper_type:
self.neigh_bgps['changed_state'] = 'Idle'
self.neigh_bgps['changed_state'] = 'Active,Idle'
self.dut_bgps['changed_state'] = 'Active,Connect,Idle'

def sad_setup(self, is_up=True):
Expand Down Expand Up @@ -288,8 +292,9 @@ def sad_setup(self, is_up=True):
for vm in self.neigh_vms:
self.log.append('Changing state of AS %s to shut' %
self.neigh_bgps[vm]['asn'])
bgp_info = self.dut_bgps[vm] if self.neighbor_type == 'sonic' else self.neigh_bgps[vm]
self.vm_handles[vm].change_bgp_neigh_state(
self.neigh_bgps[vm]['asn'], is_up=is_up)
bgp_info, is_up=is_up)
elif self.oper_type == 'dut_bgp_down':
self.change_bgp_dut_state(is_up=is_up)
time.sleep(30)
Expand Down Expand Up @@ -560,10 +565,14 @@ def populate_lag_member_down(self, neigh_name):
self.neigh_lag_members_down[neigh_name] = self.vm_dut_map[neigh_name]['neigh_ports']

def populate_lag_state(self):
if 'neigh_lag' in self.oper_type:
self.neigh_lag_state = 'disabled,notconnect'
elif 'dut_lag' in self.oper_type:
self.neigh_lag_state = 'notconnect'
if self.neighbor_type == 'sonic':
if 'neigh_lag' in self.oper_type or 'dut_lag' in self.oper_type:
self.neigh_lag_state = 'down'
else:
if 'neigh_lag' in self.oper_type:
self.neigh_lag_state = 'disabled,notconnect'
elif 'dut_lag' in self.oper_type:
self.neigh_lag_state = 'notconnect'

for neigh_name in self.neigh_names.values():
self.populate_lag_member_down(neigh_name)
Expand Down
Loading

0 comments on commit fb344dc

Please sign in to comment.