diff --git a/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py b/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py index 32a509202b9c..15a6bafb3b4b 100644 --- a/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py +++ b/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py @@ -22,13 +22,16 @@ def __init__(self): self.bmc_info_url = "http://240.1.1.1:8080/api/sys/bmc" self.onie_config_file = "/host/machine.conf" self.cpldb_version_path = "/sys/devices/platform/%s.cpldb/getreg" % self.platform_name - self.fpga_version_path = "/sys/devices/platform/%s.switchboard/FPGA/getreg" % self.platform_name + self.fpga_version_path = "/sys/devices/platform/%s.switchboard/FPGA/getreg" % self.platform_name self.switchboard_cpld1_path = "/sys/devices/platform/%s.switchboard/CPLD1/getreg" % self.platform_name self.switchboard_cpld2_path = "/sys/devices/platform/%s.switchboard/CPLD2/getreg" % self.platform_name + self.switchboard_cpld3_path = "/sys/devices/platform/%s.switchboard/CPLD3/getreg" % self.platform_name + self.switchboard_cpld4_path = "/sys/devices/platform/%s.switchboard/CPLD4/getreg" % self.platform_name def __get_register_value(self, path, register): cmd = "echo {1} > {0}; cat {0}".format(path, register) - p = subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen( + cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) raw_data, err = p.communicate() if err is not '': return 'None' @@ -59,17 +62,37 @@ def get_cpld_version(self): CPLD_C = self.__get_register_value(self.cpldb_version_path, '0xA1E0') CPLD_1 = self.__get_register_value(self.switchboard_cpld1_path, '0x00') CPLD_2 = self.__get_register_value(self.switchboard_cpld2_path, '0x00') + CPLD_3 = self.__get_register_value(self.switchboard_cpld3_path, '0x00') + CPLD_4 = self.__get_register_value(self.switchboard_cpld4_path, '0x00') - CPLD_B = 'None' if CPLD_B is 'None' else "{}.{}".format(int(CPLD_B[2],16),int(CPLD_B[3],16)) - CPLD_C = 'None' if CPLD_C is 'None' else "{}.{}".format(int(CPLD_C[2],16),int(CPLD_C[3],16)) - CPLD_1 = 'None' if CPLD_1 is 'None' else "{}.{}".format(int(CPLD_1[2],16),int(CPLD_1[3],16)) - CPLD_2 = 'None' if CPLD_2 is 'None' else "{}.{}".format(int(CPLD_2[2],16),int(CPLD_2[3],16)) - - cpld_version_dict = {} - cpld_version_dict.update({'CPLD_B':CPLD_B}) - cpld_version_dict.update({'CPLD_C':CPLD_C}) - cpld_version_dict.update({'CPLD_1':CPLD_1}) - cpld_version_dict.update({'CPLD_2':CPLD_2}) + fan_cpld_key = "FanCPLD Version" + bmc_info_req = requests.get(self.bmc_info_url) + bmc_info_json = bmc_info_req.json() + bmc_info = bmc_info_json.get('Information') + fan_cpld = bmc_info.get(fan_cpld_key) + + CPLD_B = 'None' if CPLD_B is 'None' else "{}.{}".format( + int(CPLD_B[2], 16), int(CPLD_B[3], 16)) + CPLD_C = 'None' if CPLD_C is 'None' else "{}.{}".format( + int(CPLD_C[2], 16), int(CPLD_C[3], 16)) + CPLD_1 = 'None' if CPLD_1 is 'None' else "{}.{}".format( + int(CPLD_1[2], 16), int(CPLD_1[3], 16)) + CPLD_2 = 'None' if CPLD_2 is 'None' else "{}.{}".format( + int(CPLD_2[2], 16), int(CPLD_2[3], 16)) + CPLD_3 = 'None' if CPLD_3 is 'None' else "{}.{}".format( + int(CPLD_3[2], 16), int(CPLD_3[3], 16)) + CPLD_4 = 'None' if CPLD_4 is 'None' else "{}.{}".format( + int(CPLD_4[2], 16), int(CPLD_4[3], 16)) + FAN_CPLD = 'None' if CPLD_4 is None else "{:.1f}".format(float(fan_cpld)) + + cpld_version_dict={} + cpld_version_dict.update({'CPLD_B': CPLD_B}) + cpld_version_dict.update({'CPLD_C': CPLD_C}) + cpld_version_dict.update({'CPLD_1': CPLD_1}) + cpld_version_dict.update({'CPLD_2': CPLD_2}) + cpld_version_dict.update({'CPLD_3': CPLD_3}) + cpld_version_dict.update({'CPLD_4': CPLD_4}) + cpld_version_dict.update({'CPLD_FAN': FAN_CPLD}) return cpld_version_dict @@ -78,13 +101,13 @@ def get_bios_version(self): :returns: version string """ - bios_version = 'None' + bios_version='None' - p = subprocess.Popen( + p=subprocess.Popen( ["sudo", "dmidecode", "-s", "bios-version"], stdout=subprocess.PIPE) - raw_data = str(p.communicate()[0]) - raw_data_list = raw_data.split("\n") - bios_version = raw_data_list[0] if len( + raw_data=str(p.communicate()[0]) + raw_data_list=raw_data.split("\n") + bios_version=raw_data_list[0] if len( raw_data_list) == 1 else raw_data_list[-2] return bios_version @@ -94,14 +117,14 @@ def get_onie_version(self): :returns: version string """ - onie_verison = 'None' + onie_verison='None' - onie_version_keys = "onie_version" - onie_config_file = open(self.onie_config_file, "r") + onie_version_keys="onie_version" + onie_config_file=open(self.onie_config_file, "r") for line in onie_config_file.readlines(): if onie_version_keys in line: - onie_version_raw = line.split('=') - onie_verison = onie_version_raw[1].strip() + onie_version_raw=line.split('=') + onie_verison=onie_version_raw[1].strip() break return onie_verison @@ -109,14 +132,17 @@ def get_pcie_version(self): """Get PCiE version from SONiC :returns: version string """ - cmd = "sudo bcmcmd 'pciephy fw version'" - p = subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - raw_data, err = p.communicate() + cmd="sudo bcmcmd 'pciephy fw version'" + p=subprocess.Popen( + cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + raw_data, err=p.communicate() if err is not '': return 'None' else: - lines = raw_data.split('\n') - version = lines[0].split(':')[1].strip() + lines=raw_data.split('\n') + for line in lines: + if 'PCIe FW loader' in line: + version=line.split(':')[1].strip() return str(version) def get_fpga_version(self): @@ -124,7 +150,8 @@ def get_fpga_version(self): :returns: version string """ - version = self.__get_register_value(self.fpga_version_path, '0x00') + version=self.__get_register_value(self.fpga_version_path, '0x00') if version is not 'None': - version = "{}.{}".format(int(version[2:][:4],16), int(version[2:][4:],16)) + version="{}.{}".format( + int(version[2:][:4], 16), int(version[2:][4:], 16)) return str(version) diff --git a/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/psuutil.py b/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/psuutil.py index b37af6d2a93e..242beb570e6a 100644 --- a/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/psuutil.py +++ b/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/psuutil.py @@ -2,7 +2,7 @@ __author__ = 'Wirut G.' __license__ = "GPL" -__version__ = "0.1.1" +__version__ = "0.1.2" __status__ = "Development" import requests @@ -44,15 +44,6 @@ def get_num_psus(self): num_psus = 2 - try: - # Request and validate sensor's information - self.fru_status_list, self.psu_info_list = self.request_data() - num_psus = len(self.psu_info_list) - for psu_dict in self.psu_info_list: - num_psus = num_psus - 1 if psu_dict.keys() == [] else num_psus - except: - return num_psus - return num_psus def get_psu_status(self, index): @@ -184,7 +175,8 @@ def get_all(self): # Init data all_psu_dict = dict() all_psu_dict["Number"] = self.get_num_psus() - psu_sn_key = "Serial Number" + psu_sn_key_1 = "Serial Number" + psu_sn_key_2 = "Product Serial" psu_pn_key = "Product Name" # Request and validate sensor's information. @@ -195,14 +187,20 @@ def get_all(self): for psu_fru in self.psu_info_list: psu_data = dict() pn = psu_fru.get(psu_pn_key) - sn = psu_fru.get(psu_sn_key) + sn = psu_fru.get(psu_sn_key_1) or psu_fru.get(psu_sn_key_2) psu_data["PN"] = "N/A" if not pn or str( pn).strip() == "" else str(pn).strip() psu_data["SN"] = "N/A" if not pn or str( pn).strip() == "" else str(sn).strip() - raw_key = [v for v in psu_fru.keys() if 'PSU' in v] - if len(raw_key) > 0: - psu_idx = int(re.findall('\d+', raw_key[0])[0]) + + fru_check = [psu_fru[v] for v in psu_fru.keys() if 'FRU Info' in v] + non_fru_check = [v for v in psu_fru.keys() if 'PSU' in v] + + if len(non_fru_check) > 0: + psu_idx = int(re.findall('\d+', non_fru_check[0])[0]) + psu_info_dict[psu_idx] = psu_data + elif len(fru_check) > 0: + psu_idx = int(re.findall('\d+', fru_check[0])[0]) psu_info_dict[psu_idx] = psu_data # Set PSU status. diff --git a/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fwmgrutil.py b/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fwmgrutil.py index fcd28b028a96..498c5da98f31 100644 --- a/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fwmgrutil.py +++ b/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fwmgrutil.py @@ -22,13 +22,16 @@ def __init__(self): self.bmc_info_url = "http://240.1.1.1:8080/api/sys/bmc" self.onie_config_file = "/host/machine.conf" self.cpldb_version_path = "/sys/devices/platform/%s.cpldb/getreg" % self.platform_name - self.fpga_version_path = "/sys/devices/platform/%s.switchboard/FPGA/getreg" % self.platform_name + self.fpga_version_path = "/sys/devices/platform/%s.switchboard/FPGA/getreg" % self.platform_name self.switchboard_cpld1_path = "/sys/devices/platform/%s.switchboard/CPLD1/getreg" % self.platform_name self.switchboard_cpld2_path = "/sys/devices/platform/%s.switchboard/CPLD2/getreg" % self.platform_name + self.switchboard_cpld3_path = "/sys/devices/platform/%s.switchboard/CPLD3/getreg" % self.platform_name + self.switchboard_cpld4_path = "/sys/devices/platform/%s.switchboard/CPLD4/getreg" % self.platform_name def __get_register_value(self, path, register): cmd = "echo {1} > {0}; cat {0}".format(path, register) - p = subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen( + cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) raw_data, err = p.communicate() if err is not '': return 'None' @@ -59,17 +62,37 @@ def get_cpld_version(self): CPLD_C = self.__get_register_value(self.cpldb_version_path, '0xA1E0') CPLD_1 = self.__get_register_value(self.switchboard_cpld1_path, '0x00') CPLD_2 = self.__get_register_value(self.switchboard_cpld2_path, '0x00') + CPLD_3 = self.__get_register_value(self.switchboard_cpld3_path, '0x00') + CPLD_4 = self.__get_register_value(self.switchboard_cpld4_path, '0x00') - CPLD_B = 'None' if CPLD_B is 'None' else "{}.{}".format(int(CPLD_B[2],16),int(CPLD_B[3],16)) - CPLD_C = 'None' if CPLD_C is 'None' else "{}.{}".format(int(CPLD_C[2],16),int(CPLD_C[3],16)) - CPLD_1 = 'None' if CPLD_1 is 'None' else "{}.{}".format(int(CPLD_1[2],16),int(CPLD_1[3],16)) - CPLD_2 = 'None' if CPLD_2 is 'None' else "{}.{}".format(int(CPLD_2[2],16),int(CPLD_2[3],16)) - - cpld_version_dict = {} - cpld_version_dict.update({'CPLD_B':CPLD_B}) - cpld_version_dict.update({'CPLD_C':CPLD_C}) - cpld_version_dict.update({'CPLD_1':CPLD_1}) - cpld_version_dict.update({'CPLD_2':CPLD_2}) + fan_cpld_key = "FanCPLD Version" + bmc_info_req = requests.get(self.bmc_info_url) + bmc_info_json = bmc_info_req.json() + bmc_info = bmc_info_json.get('Information') + fan_cpld = bmc_info.get(fan_cpld_key) + + CPLD_B = 'None' if CPLD_B is 'None' else "{}.{}".format( + int(CPLD_B[2], 16), int(CPLD_B[3], 16)) + CPLD_C = 'None' if CPLD_C is 'None' else "{}.{}".format( + int(CPLD_C[2], 16), int(CPLD_C[3], 16)) + CPLD_1 = 'None' if CPLD_1 is 'None' else "{}.{}".format( + int(CPLD_1[2], 16), int(CPLD_1[3], 16)) + CPLD_2 = 'None' if CPLD_2 is 'None' else "{}.{}".format( + int(CPLD_2[2], 16), int(CPLD_2[3], 16)) + CPLD_3 = 'None' if CPLD_3 is 'None' else "{}.{}".format( + int(CPLD_3[2], 16), int(CPLD_3[3], 16)) + CPLD_4 = 'None' if CPLD_4 is 'None' else "{}.{}".format( + int(CPLD_4[2], 16), int(CPLD_4[3], 16)) + FAN_CPLD = 'None' if CPLD_4 is None else "{:.1f}".format(float(fan_cpld)) + + cpld_version_dict={} + cpld_version_dict.update({'CPLD_B': CPLD_B}) + cpld_version_dict.update({'CPLD_C': CPLD_C}) + cpld_version_dict.update({'CPLD_1': CPLD_1}) + cpld_version_dict.update({'CPLD_2': CPLD_2}) + cpld_version_dict.update({'CPLD_3': CPLD_3}) + cpld_version_dict.update({'CPLD_4': CPLD_4}) + cpld_version_dict.update({'CPLD_FAN': FAN_CPLD}) return cpld_version_dict @@ -78,13 +101,13 @@ def get_bios_version(self): :returns: version string """ - bios_version = 'None' + bios_version='None' - p = subprocess.Popen( + p=subprocess.Popen( ["sudo", "dmidecode", "-s", "bios-version"], stdout=subprocess.PIPE) - raw_data = str(p.communicate()[0]) - raw_data_list = raw_data.split("\n") - bios_version = raw_data_list[0] if len( + raw_data=str(p.communicate()[0]) + raw_data_list=raw_data.split("\n") + bios_version=raw_data_list[0] if len( raw_data_list) == 1 else raw_data_list[-2] return bios_version @@ -94,14 +117,14 @@ def get_onie_version(self): :returns: version string """ - onie_verison = 'None' + onie_verison='None' - onie_version_keys = "onie_version" - onie_config_file = open(self.onie_config_file, "r") + onie_version_keys="onie_version" + onie_config_file=open(self.onie_config_file, "r") for line in onie_config_file.readlines(): if onie_version_keys in line: - onie_version_raw = line.split('=') - onie_verison = onie_version_raw[1].strip() + onie_version_raw=line.split('=') + onie_verison=onie_version_raw[1].strip() break return onie_verison @@ -109,14 +132,17 @@ def get_pcie_version(self): """Get PCiE version from SONiC :returns: version string """ - cmd = "sudo bcmcmd 'pciephy fw version'" - p = subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - raw_data, err = p.communicate() + cmd="sudo bcmcmd 'pciephy fw version'" + p=subprocess.Popen( + cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + raw_data, err=p.communicate() if err is not '': return 'None' else: - lines = raw_data.split('\n') - version = lines[0].split(':')[1].strip() + lines=raw_data.split('\n') + for line in lines: + if 'PCIe FW loader' in line: + version=line.split(':')[1].strip() return str(version) def get_fpga_version(self): @@ -124,7 +150,8 @@ def get_fpga_version(self): :returns: version string """ - version = self.__get_register_value(self.fpga_version_path, '0x00') + version=self.__get_register_value(self.fpga_version_path, '0x00') if version is not 'None': - version = "{}.{}".format(int(version[2:][:4],16), int(version[2:][4:],16)) + version="{}.{}".format( + int(version[2:][:4], 16), int(version[2:][4:], 16)) return str(version) diff --git a/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/psuutil.py b/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/psuutil.py index b37af6d2a93e..242beb570e6a 100644 --- a/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/psuutil.py +++ b/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/psuutil.py @@ -2,7 +2,7 @@ __author__ = 'Wirut G.' __license__ = "GPL" -__version__ = "0.1.1" +__version__ = "0.1.2" __status__ = "Development" import requests @@ -44,15 +44,6 @@ def get_num_psus(self): num_psus = 2 - try: - # Request and validate sensor's information - self.fru_status_list, self.psu_info_list = self.request_data() - num_psus = len(self.psu_info_list) - for psu_dict in self.psu_info_list: - num_psus = num_psus - 1 if psu_dict.keys() == [] else num_psus - except: - return num_psus - return num_psus def get_psu_status(self, index): @@ -184,7 +175,8 @@ def get_all(self): # Init data all_psu_dict = dict() all_psu_dict["Number"] = self.get_num_psus() - psu_sn_key = "Serial Number" + psu_sn_key_1 = "Serial Number" + psu_sn_key_2 = "Product Serial" psu_pn_key = "Product Name" # Request and validate sensor's information. @@ -195,14 +187,20 @@ def get_all(self): for psu_fru in self.psu_info_list: psu_data = dict() pn = psu_fru.get(psu_pn_key) - sn = psu_fru.get(psu_sn_key) + sn = psu_fru.get(psu_sn_key_1) or psu_fru.get(psu_sn_key_2) psu_data["PN"] = "N/A" if not pn or str( pn).strip() == "" else str(pn).strip() psu_data["SN"] = "N/A" if not pn or str( pn).strip() == "" else str(sn).strip() - raw_key = [v for v in psu_fru.keys() if 'PSU' in v] - if len(raw_key) > 0: - psu_idx = int(re.findall('\d+', raw_key[0])[0]) + + fru_check = [psu_fru[v] for v in psu_fru.keys() if 'FRU Info' in v] + non_fru_check = [v for v in psu_fru.keys() if 'PSU' in v] + + if len(non_fru_check) > 0: + psu_idx = int(re.findall('\d+', non_fru_check[0])[0]) + psu_info_dict[psu_idx] = psu_data + elif len(fru_check) > 0: + psu_idx = int(re.findall('\d+', fru_check[0])[0]) psu_info_dict[psu_idx] = psu_data # Set PSU status. diff --git a/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fwmgrutil.py b/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fwmgrutil.py index 8c7029b32466..a4d202389a4e 100644 --- a/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fwmgrutil.py +++ b/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fwmgrutil.py @@ -22,7 +22,7 @@ def __init__(self): self.bmc_info_url = "http://240.1.1.1:8080/api/sys/bmc" self.onie_config_file = "/host/machine.conf" self.cpldb_version_path = "/sys/devices/platform/%s.cpldb/getreg" % self.platform_name - self.fpga_version_path = "/sys/devices/platform/%s.switchboard/FPGA/getreg" % self.platform_name + self.fpga_version_path = "/sys/devices/platform/%s.switchboard/FPGA/getreg" % self.platform_name self.switchboard_cpld1_path = "/sys/devices/platform/%s.switchboard/CPLD1/getreg" % self.platform_name self.switchboard_cpld2_path = "/sys/devices/platform/%s.switchboard/CPLD2/getreg" % self.platform_name self.switchboard_cpld3_path = "/sys/devices/platform/%s.switchboard/CPLD3/getreg" % self.platform_name @@ -30,7 +30,8 @@ def __init__(self): def __get_register_value(self, path, register): cmd = "echo {1} > {0}; cat {0}".format(path, register) - p = subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen( + cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) raw_data, err = p.communicate() if err is not '': return 'None' @@ -64,20 +65,34 @@ def get_cpld_version(self): CPLD_3 = self.__get_register_value(self.switchboard_cpld3_path, '0x00') CPLD_4 = self.__get_register_value(self.switchboard_cpld4_path, '0x00') - CPLD_B = 'None' if CPLD_B is 'None' else "{}.{}".format(int(CPLD_B[2],16),int(CPLD_B[3],16)) - CPLD_C = 'None' if CPLD_C is 'None' else "{}.{}".format(int(CPLD_C[2],16),int(CPLD_C[3],16)) - CPLD_1 = 'None' if CPLD_1 is 'None' else "{}.{}".format(int(CPLD_1[2],16),int(CPLD_1[3],16)) - CPLD_2 = 'None' if CPLD_2 is 'None' else "{}.{}".format(int(CPLD_2[2],16),int(CPLD_2[3],16)) - CPLD_3 = 'None' if CPLD_3 is 'None' else "{}.{}".format(int(CPLD_3[2],16),int(CPLD_3[3],16)) - CPLD_4 = 'None' if CPLD_4 is 'None' else "{}.{}".format(int(CPLD_4[2],16),int(CPLD_4[3],16)) - - cpld_version_dict = {} - cpld_version_dict.update({'CPLD_B':CPLD_B}) - cpld_version_dict.update({'CPLD_C':CPLD_C}) - cpld_version_dict.update({'CPLD_1':CPLD_1}) - cpld_version_dict.update({'CPLD_2':CPLD_2}) - cpld_version_dict.update({'CPLD_3':CPLD_3}) - cpld_version_dict.update({'CPLD_4':CPLD_4}) + fan_cpld_key = "FanCPLD Version" + bmc_info_req = requests.get(self.bmc_info_url) + bmc_info_json = bmc_info_req.json() + bmc_info = bmc_info_json.get('Information') + fan_cpld = bmc_info.get(fan_cpld_key) + + CPLD_B = 'None' if CPLD_B is 'None' else "{}.{}".format( + int(CPLD_B[2], 16), int(CPLD_B[3], 16)) + CPLD_C = 'None' if CPLD_C is 'None' else "{}.{}".format( + int(CPLD_C[2], 16), int(CPLD_C[3], 16)) + CPLD_1 = 'None' if CPLD_1 is 'None' else "{}.{}".format( + int(CPLD_1[2], 16), int(CPLD_1[3], 16)) + CPLD_2 = 'None' if CPLD_2 is 'None' else "{}.{}".format( + int(CPLD_2[2], 16), int(CPLD_2[3], 16)) + CPLD_3 = 'None' if CPLD_3 is 'None' else "{}.{}".format( + int(CPLD_3[2], 16), int(CPLD_3[3], 16)) + CPLD_4 = 'None' if CPLD_4 is 'None' else "{}.{}".format( + int(CPLD_4[2], 16), int(CPLD_4[3], 16)) + FAN_CPLD = 'None' if CPLD_4 is None else "{:.1f}".format(float(fan_cpld)) + + cpld_version_dict={} + cpld_version_dict.update({'CPLD_B': CPLD_B}) + cpld_version_dict.update({'CPLD_C': CPLD_C}) + cpld_version_dict.update({'CPLD_1': CPLD_1}) + cpld_version_dict.update({'CPLD_2': CPLD_2}) + cpld_version_dict.update({'CPLD_3': CPLD_3}) + cpld_version_dict.update({'CPLD_4': CPLD_4}) + cpld_version_dict.update({'CPLD_FAN': FAN_CPLD}) return cpld_version_dict @@ -86,13 +101,13 @@ def get_bios_version(self): :returns: version string """ - bios_version = 'None' + bios_version='None' - p = subprocess.Popen( + p=subprocess.Popen( ["sudo", "dmidecode", "-s", "bios-version"], stdout=subprocess.PIPE) - raw_data = str(p.communicate()[0]) - raw_data_list = raw_data.split("\n") - bios_version = raw_data_list[0] if len( + raw_data=str(p.communicate()[0]) + raw_data_list=raw_data.split("\n") + bios_version=raw_data_list[0] if len( raw_data_list) == 1 else raw_data_list[-2] return bios_version @@ -102,14 +117,14 @@ def get_onie_version(self): :returns: version string """ - onie_verison = 'None' + onie_verison='None' - onie_version_keys = "onie_version" - onie_config_file = open(self.onie_config_file, "r") + onie_version_keys="onie_version" + onie_config_file=open(self.onie_config_file, "r") for line in onie_config_file.readlines(): if onie_version_keys in line: - onie_version_raw = line.split('=') - onie_verison = onie_version_raw[1].strip() + onie_version_raw=line.split('=') + onie_verison=onie_version_raw[1].strip() break return onie_verison @@ -117,14 +132,17 @@ def get_pcie_version(self): """Get PCiE version from SONiC :returns: version string """ - cmd = "sudo bcmcmd 'pciephy fw version'" - p = subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - raw_data, err = p.communicate() + cmd="sudo bcmcmd 'pciephy fw version'" + p=subprocess.Popen( + cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + raw_data, err=p.communicate() if err is not '': return 'None' else: - lines = raw_data.split('\n') - version = lines[0].split(':')[1].strip() + lines=raw_data.split('\n') + for line in lines: + if 'PCIe FW loader' in line: + version=line.split(':')[1].strip() return str(version) def get_fpga_version(self): @@ -132,7 +150,8 @@ def get_fpga_version(self): :returns: version string """ - version = self.__get_register_value(self.fpga_version_path, '0x00') + version=self.__get_register_value(self.fpga_version_path, '0x00') if version is not 'None': - version = "{}.{}".format(int(version[2:][:4],16), int(version[2:][4:],16)) + version="{}.{}".format( + int(version[2:][:4], 16), int(version[2:][4:], 16)) return str(version) diff --git a/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/psuutil.py b/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/psuutil.py index ebc17406e353..e4910b1914b7 100644 --- a/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/psuutil.py +++ b/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/psuutil.py @@ -1,5 +1,10 @@ #!/usr/bin/env python +__author__ = 'Wirut G.' +__license__ = "GPL" +__version__ = "0.1.2" +__status__ = "Development" + import requests import re @@ -37,16 +42,7 @@ def get_num_psus(self): :return: An integer, the number of PSUs available on the device """ - num_psus = 6 - - try: - # Request and validate sensor's information - self.fru_status_list, self.psu_info_list = self.request_data() - num_psus = len(self.psu_info_list) - for psu_dict in self.psu_info_list: - num_psus = num_psus - 1 if psu_dict.keys() == [] else num_psus - except: - return num_psus + num_psus = 4 return num_psus @@ -179,7 +175,8 @@ def get_all(self): # Init data all_psu_dict = dict() all_psu_dict["Number"] = self.get_num_psus() - psu_sn_key = "Serial Number" + psu_sn_key_1 = "Serial Number" + psu_sn_key_2 = "Product Serial" psu_pn_key = "Product Name" # Request and validate sensor's information. @@ -190,14 +187,20 @@ def get_all(self): for psu_fru in self.psu_info_list: psu_data = dict() pn = psu_fru.get(psu_pn_key) - sn = psu_fru.get(psu_sn_key) + sn = psu_fru.get(psu_sn_key_1) or psu_fru.get(psu_sn_key_2) psu_data["PN"] = "N/A" if not pn or str( pn).strip() == "" else str(pn).strip() psu_data["SN"] = "N/A" if not pn or str( pn).strip() == "" else str(sn).strip() - raw_key = [v for v in psu_fru.keys() if 'PSU' in v] - if len(raw_key) > 0: - psu_idx = int(re.findall('\d+', raw_key[0])[0]) + + fru_check = [psu_fru[v] for v in psu_fru.keys() if 'FRU Info' in v] + non_fru_check = [v for v in psu_fru.keys() if 'PSU' in v] + + if len(non_fru_check) > 0: + psu_idx = int(re.findall('\d+', non_fru_check[0])[0]) + psu_info_dict[psu_idx] = psu_data + elif len(fru_check) > 0: + psu_idx = int(re.findall('\d+', fru_check[0])[0]) psu_info_dict[psu_idx] = psu_data # Set PSU status. diff --git a/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/sensorutil.py b/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/sensorutil.py index d98812bc30fb..41c42fc90ed9 100644 --- a/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/sensorutil.py +++ b/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/sensorutil.py @@ -37,10 +37,10 @@ def input_name_selector(self, sensor_name, input_name): self.sensor_name = { "syscpld-i2c-0-0d": "TEMPERATURE", - "dps1100-i2c-25-58": "PSU1", + "dps1100-i2c-27-58": "PSU1", "dps1100-i2c-26-58": "PSU2", - "dps1100-i2c-28-58": "PSU3", - "dps1100-i2c-29-58": "PSU4", + "dps1100-i2c-25-58": "PSU3", + "dps1100-i2c-24-58": "PSU4", "fancpld-i2c-8-0d": "FAN", "isl68137-i2c-17-60": "ISL68137" }.get(sensor_name, sensor_name)