Skip to content

Commit c4929c6

Browse files
authored
[vendor_data] Refactor ASIC checks to use dut facts (#1531)
Summary: Adds a helper method to duthost for getting the ASIC type of the DUT Signed-off-by: Danny Allen <daall@microsoft.com>
1 parent edc1d5c commit c4929c6

5 files changed

Lines changed: 12 additions & 17 deletions

File tree

tests/common/broadcom_data.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
SWITCH_HWSKUS = ["Force10-S6000", "Accton-AS7712-32X", "Celestica-DX010-C32",
2-
"Seastone-DX010", "Celestica-E1031-T48S4"]
3-
4-
def is_broadcom_device(hwsku):
5-
return hwsku in SWITCH_HWSKUS
1+
def is_broadcom_device(dut):
2+
return dut.get_asic_type() == "broadcom"

tests/common/devices.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,10 @@ def get_image_info(self):
333333
ret['installed_list'] = images
334334
return ret
335335

336+
def get_asic_type(self):
337+
return dut.facts["asic_type"]
338+
339+
336340
class EosHost(AnsibleHostBase):
337341
"""
338342
@summary: Class for Eos switch

tests/common/fixtures/advanced_reboot.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ def __buildTestbedData(self):
127127
self.rebootData['lo_v6_prefix'] = str(ipaddress.ip_interface(intf['addr'] + '/64').network)
128128
break
129129

130-
self.rebootData['minigraph_hwsku'] = self.mgFacts['minigraph_hwsku']
131-
132130
def __updateNextHopIps(self):
133131
'''
134132
Update next hop IPs
@@ -240,7 +238,7 @@ def __handleMellanoxDut(self):
240238
'''
241239
if self.newSonicImage is not None and \
242240
self.rebootType == 'fast-reboot' and \
243-
isMellanoxDevice(self.rebootData['minigraph_hwsku']):
241+
isMellanoxDevice(self.duthost):
244242
logger.info('Handle Mellanox platform')
245243
nextImage = self.duthost.shell('sonic_installer list | grep Next | cut -f2 -d " "')['stdout']
246244
if 'SONiC-OS-201803' in self.currentImage and 'SONiC-OS-201811' in nextImage:

tests/common/mellanox_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,5 +551,5 @@
551551
}
552552
}
553553

554-
def is_mellanox_device(hwsku):
555-
return hwsku in SWITCH_HWSKUS
554+
def is_mellanox_device(dut):
555+
return dut.get_asic_type() == "mellanox"

tests/common/system_utils/docker.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,12 @@ def swap_syncd(dut, registry_file=SONIC_DOCKER_REGISTRY):
117117
registry_file (str): The registry file describing where to download the RPC image.
118118
"""
119119

120-
minigraph_facts = dut.minigraph_facts(host=dut.hostname)["ansible_facts"]
121-
hw_sku = minigraph_facts["minigraph_hwsku"]
122-
123-
# TODO: Getting the vendor identifier should be a common utility
124-
if is_broadcom_device(hw_sku):
120+
if is_broadcom_device(dut):
125121
vendor_id = "brcm"
126-
elif is_mellanox_device(hw_sku):
122+
elif is_mellanox_device(dut):
127123
vendor_id = "mlnx"
128124
else:
129-
error_message = "HW SKU \"{}\" is not currently supported".format(hw_sku)
125+
error_message = "\"{}\" is not currently supported".format(dut.get_asic_type())
130126
_LOGGER.error(error_message)
131127
raise ValueError(error_message)
132128

0 commit comments

Comments
 (0)