Skip to content

Commit

Permalink
[vendor_data] Refactor ASIC checks to use dut facts (#1531)
Browse files Browse the repository at this point in the history
Summary: Adds a helper method to duthost for getting the ASIC type of the DUT

Signed-off-by: Danny Allen <daall@microsoft.com>
  • Loading branch information
daall authored Apr 3, 2020
1 parent edc1d5c commit c4929c6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 17 deletions.
7 changes: 2 additions & 5 deletions tests/common/broadcom_data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
SWITCH_HWSKUS = ["Force10-S6000", "Accton-AS7712-32X", "Celestica-DX010-C32",
"Seastone-DX010", "Celestica-E1031-T48S4"]

def is_broadcom_device(hwsku):
return hwsku in SWITCH_HWSKUS
def is_broadcom_device(dut):
return dut.get_asic_type() == "broadcom"
4 changes: 4 additions & 0 deletions tests/common/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,10 @@ def get_image_info(self):
ret['installed_list'] = images
return ret

def get_asic_type(self):
return dut.facts["asic_type"]


class EosHost(AnsibleHostBase):
"""
@summary: Class for Eos switch
Expand Down
4 changes: 1 addition & 3 deletions tests/common/fixtures/advanced_reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ def __buildTestbedData(self):
self.rebootData['lo_v6_prefix'] = str(ipaddress.ip_interface(intf['addr'] + '/64').network)
break

self.rebootData['minigraph_hwsku'] = self.mgFacts['minigraph_hwsku']

def __updateNextHopIps(self):
'''
Update next hop IPs
Expand Down Expand Up @@ -240,7 +238,7 @@ def __handleMellanoxDut(self):
'''
if self.newSonicImage is not None and \
self.rebootType == 'fast-reboot' and \
isMellanoxDevice(self.rebootData['minigraph_hwsku']):
isMellanoxDevice(self.duthost):
logger.info('Handle Mellanox platform')
nextImage = self.duthost.shell('sonic_installer list | grep Next | cut -f2 -d " "')['stdout']
if 'SONiC-OS-201803' in self.currentImage and 'SONiC-OS-201811' in nextImage:
Expand Down
4 changes: 2 additions & 2 deletions tests/common/mellanox_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,5 +551,5 @@
}
}

def is_mellanox_device(hwsku):
return hwsku in SWITCH_HWSKUS
def is_mellanox_device(dut):
return dut.get_asic_type() == "mellanox"
10 changes: 3 additions & 7 deletions tests/common/system_utils/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,12 @@ def swap_syncd(dut, registry_file=SONIC_DOCKER_REGISTRY):
registry_file (str): The registry file describing where to download the RPC image.
"""

minigraph_facts = dut.minigraph_facts(host=dut.hostname)["ansible_facts"]
hw_sku = minigraph_facts["minigraph_hwsku"]

# TODO: Getting the vendor identifier should be a common utility
if is_broadcom_device(hw_sku):
if is_broadcom_device(dut):
vendor_id = "brcm"
elif is_mellanox_device(hw_sku):
elif is_mellanox_device(dut):
vendor_id = "mlnx"
else:
error_message = "HW SKU \"{}\" is not currently supported".format(hw_sku)
error_message = "\"{}\" is not currently supported".format(dut.get_asic_type())
_LOGGER.error(error_message)
raise ValueError(error_message)

Expand Down

0 comments on commit c4929c6

Please sign in to comment.