Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[device/alibaba] - Update device plugins. #29

Merged
merged 3 commits into from Jan 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 56 additions & 29 deletions device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -94,37 +117,41 @@ 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

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):
"""Get FPGA version from SONiC
: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)
28 changes: 13 additions & 15 deletions device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/psuutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__author__ = 'Wirut G.<wgetbumr@celestica.com>'
__license__ = "GPL"
__version__ = "0.1.1"
__version__ = "0.1.2"
__status__ = "Development"

import requests
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
85 changes: 56 additions & 29 deletions device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fwmgrutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -94,37 +117,41 @@ 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

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):
"""Get FPGA version from SONiC
: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)
28 changes: 13 additions & 15 deletions device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/psuutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__author__ = 'Wirut G.<wgetbumr@celestica.com>'
__license__ = "GPL"
__version__ = "0.1.1"
__version__ = "0.1.2"
__status__ = "Development"

import requests
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
Loading