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 plugin to support new platformutil #36

Merged
merged 1 commit into from Jan 29, 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
35 changes: 22 additions & 13 deletions device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fanutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

__author__ = 'Wirut G.<[email protected]>'
__license__ = "GPL"
__version__ = "0.1.1"
__version__ = "0.1.2"
__status__ = "Development"

import re
import requests
import re


class FanUtil():
Expand Down Expand Up @@ -249,27 +249,33 @@ def get_all(self):

# Set fan FRU data.
fan_fru_dict = dict()
fan_raw_idx = 1
for fan_fru in self.fru_data_list:
if len(fan_fru) == 0:
continue
fru_dict = dict()
fan_key = fan_fru[0].split()
fan_ps = False

if str(fan_key[-1]).lower() == "absent":
fan_idx = int(re.findall('\d+', fan_key[0])[0])
if len(fan_fru) == 0:
fan_idx = fan_raw_idx
else:
fan_idx = int(re.findall('\d+', fan_key[-1])[0])
fan_ps = True
pn = [s for s in fan_fru if "Part" in s]
sn = [s for s in fan_fru if "Serial" in s]
fan_pn = pn[0].split(":")[-1].strip() if len(pn) > 0 else 'N/A'
fan_sn = sn[0].split(":")[-1].strip() if len(sn) > 0 else 'N/A'
fan_key = fan_fru[0].split()
if str(fan_key[-1]).lower() == "absent":
fan_idx = int(re.findall('\d+', fan_key[0])[0])

else:
fan_idx = int(re.findall('\d+', fan_key[-1])[0])
fan_ps = True
pn = [s for s in fan_fru if "Part" in s]
sn = [s for s in fan_fru if "Serial" in s]
fan_pn = pn[0].split(
":")[-1].strip() if len(pn) > 0 else 'N/A'
fan_sn = sn[0].split(
":")[-1].strip() if len(sn) > 0 else 'N/A'

fru_dict["PN"] = "N/A" if not fan_pn or fan_pn == "" else fan_pn
fru_dict["SN"] = "N/A" if not fan_sn or fan_sn == "" else fan_sn
fru_dict["Present"] = fan_ps
fan_fru_dict[fan_idx] = fru_dict
fan_raw_idx += 1

# Set fan sensor data.
for sensor_data in self.sensor_data_list:
Expand All @@ -291,6 +297,9 @@ def get_all(self):
fan_dict["HighThd"] = fan_sp_list[2]
fan_dict["PN"] = fan_fru_dict[f_index]["PN"]
fan_dict["SN"] = fan_fru_dict[f_index]["SN"]
fan_dict["AirFlow"] = "FTOB" if "R1241-F9001" in fan_dict["PN"] else "Unknown"
fan_dict["AirFlow"] = "BTOF" if "R1241-F9002" in fan_dict["PN"] else fan_dict["AirFlow"]
fan_dict["Status"] = True if fan_dict["AirFlow"] != "Unknown" else False
fan_name = 'FAN{}_{}'.format(f_index, pos)
all_fan_dict[fan_name] = fan_dict
break
Expand Down
20 changes: 19 additions & 1 deletion 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.<[email protected]>'
__license__ = "GPL"
__version__ = "0.1.2"
__version__ = "0.1.3"
__status__ = "Development"

import requests
Expand Down Expand Up @@ -36,6 +36,15 @@ def request_data(self):
self.psu_info_list = psu_info_json.get('Information')
return self.fru_status_list, self.psu_info_list

def airflow_selector(self, pn):
# Set input type.
return {
"DPS-1100FB": "FTOB",
"DPS-1100AB": "BTOF",
"FSJ026-A20G": "FTOB",
"FSJ038-A20G": "BTOF"
}.get(pn, "Unknown")

def get_num_psus(self):
"""
Retrieves the number of PSUs available on the device
Expand Down Expand Up @@ -213,12 +222,21 @@ def get_all(self):
"Present")).strip() == "Present" else False
psu_pw_status = True if str(fru_status.get(
"Power Status")).strip() == "OK" else False
psu_pw_type = str(fru_status.get(
"Power Type")).strip()
ac_status = True if str(fru_status.get(
"AC Status")).strip().upper() == "OK" else False

psu_status_dict["Present"] = psu_ps_status
if psu_ps_status:
psu_status_dict["PowerStatus"] = psu_pw_status
psu_status_dict["PN"] = psu_info_dict[psu_idx]["PN"]
psu_status_dict["SN"] = psu_info_dict[psu_idx]["SN"]
psu_status_dict["InputType"] = psu_pw_type
psu_status_dict["InputStatus"] = True if psu_pw_status and psu_ps_status else False
psu_status_dict["OutputStatus"] = ac_status
psu_status_dict["AirFlow"] = self.airflow_selector(
psu_status_dict["PN"].split()[0])
all_psu_dict[find_psu[0]] = psu_status_dict

return all_psu_dict
24 changes: 24 additions & 0 deletions device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/sensorutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class SensorUtil():

def __init__(self):
self.sensor_url = "http://240.1.1.1:8080/api/sys/sensors"
self.sys_fruid_url = "http://240.1.1.1:8080/api/sys/fruid/sys"
self.sensor_info_list = None

def request_data(self):
Expand All @@ -21,6 +22,9 @@ def request_data(self):
sensor_data_req = requests.get(self.sensor_url)
sensor_json = sensor_data_req.json()
self.sensor_info_list = sensor_json.get('Information')
sys_fruid_req = requests.get(self.sys_fruid_url)
sys_fruid_json = sys_fruid_req.json()
self.sys_fruid_list = sys_fruid_json.get('Information')
return self.sensor_info_list

def input_type_selector(self, unit):
Expand Down Expand Up @@ -291,6 +295,22 @@ def get_sensor_input_high_threshold(self, sensor_index, input_index):

return sensor_input_high_threshold

def get_sys_airflow(self):
sys_air_flow = "Unknown"
sys_pn_data = [
v.split(":") for v in self.sys_fruid_list if "Product Part Number" in v]

if len(sys_pn_data) == 0:
return sys_air_flow

sys_pn = sys_pn_data[0][1]
if "R1241-F0001" in sys_pn:
sys_air_flow = "FTOB"
elif"R1241-F0002" in sys_pn:
sys_air_flow = "BTOF"

return sys_air_flow

def get_all(self):

all_sensor_dict = dict()
Expand Down Expand Up @@ -336,4 +356,8 @@ def get_all(self):

all_sensor_dict[self.sensor_name].update(sensor_dict)

sensor_dict = dict()
sensor_dict["Sys_AirFlow"] = self.get_sys_airflow()
all_sensor_dict["TEMPERATURE"].update(sensor_dict)

return all_sensor_dict
35 changes: 22 additions & 13 deletions device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fanutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

__author__ = 'Wirut G.<[email protected]>'
__license__ = "GPL"
__version__ = "0.1.1"
__version__ = "0.1.2"
__status__ = "Development"

import re
import requests
import re


class FanUtil():
Expand Down Expand Up @@ -249,27 +249,33 @@ def get_all(self):

# Set fan FRU data.
fan_fru_dict = dict()
fan_raw_idx = 1
for fan_fru in self.fru_data_list:
if len(fan_fru) == 0:
continue
fru_dict = dict()
fan_key = fan_fru[0].split()
fan_ps = False

if str(fan_key[-1]).lower() == "absent":
fan_idx = int(re.findall('\d+', fan_key[0])[0])
if len(fan_fru) == 0:
fan_idx = fan_raw_idx
else:
fan_idx = int(re.findall('\d+', fan_key[-1])[0])
fan_ps = True
pn = [s for s in fan_fru if "Part" in s]
sn = [s for s in fan_fru if "Serial" in s]
fan_pn = pn[0].split(":")[-1].strip() if len(pn) > 0 else 'N/A'
fan_sn = sn[0].split(":")[-1].strip() if len(sn) > 0 else 'N/A'
fan_key = fan_fru[0].split()
if str(fan_key[-1]).lower() == "absent":
fan_idx = int(re.findall('\d+', fan_key[0])[0])

else:
fan_idx = int(re.findall('\d+', fan_key[-1])[0])
fan_ps = True
pn = [s for s in fan_fru if "Part" in s]
sn = [s for s in fan_fru if "Serial" in s]
fan_pn = pn[0].split(
":")[-1].strip() if len(pn) > 0 else 'N/A'
fan_sn = sn[0].split(
":")[-1].strip() if len(sn) > 0 else 'N/A'

fru_dict["PN"] = "N/A" if not fan_pn or fan_pn == "" else fan_pn
fru_dict["SN"] = "N/A" if not fan_sn or fan_sn == "" else fan_sn
fru_dict["Present"] = fan_ps
fan_fru_dict[fan_idx] = fru_dict
fan_raw_idx += 1

# Set fan sensor data.
for sensor_data in self.sensor_data_list:
Expand All @@ -291,6 +297,9 @@ def get_all(self):
fan_dict["HighThd"] = fan_sp_list[2]
fan_dict["PN"] = fan_fru_dict[f_index]["PN"]
fan_dict["SN"] = fan_fru_dict[f_index]["SN"]
fan_dict["AirFlow"] = "FTOB" if "R1241-F9001" in fan_dict["PN"] else "Unknown"
fan_dict["AirFlow"] = "BTOF" if "R1241-F9002" in fan_dict["PN"] else fan_dict["AirFlow"]
fan_dict["Status"] = True if fan_dict["AirFlow"] != "Unknown" else False
fan_name = 'FAN{}_{}'.format(f_index, pos)
all_fan_dict[fan_name] = fan_dict
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__author__ = 'Wirut G.<[email protected]>'
__license__ = "GPL"
__version__ = "0.1.2"
__version__ = "0.1.3"
__status__ = "Development"

import requests
Expand Down Expand Up @@ -36,6 +36,15 @@ def request_data(self):
self.psu_info_list = psu_info_json.get('Information')
return self.fru_status_list, self.psu_info_list

def airflow_selector(self, pn):
# Set input type.
return {
"DPS-1100FB": "FTOB",
"DPS-1100AB": "BTOF",
"FSJ026-A20G": "FTOB",
"FSJ038-A20G": "BTOF"
}.get(pn, "Unknown")

def get_num_psus(self):
"""
Retrieves the number of PSUs available on the device
Expand Down Expand Up @@ -213,12 +222,21 @@ def get_all(self):
"Present")).strip() == "Present" else False
psu_pw_status = True if str(fru_status.get(
"Power Status")).strip() == "OK" else False
psu_pw_type = str(fru_status.get(
"Power Type")).strip()
ac_status = True if str(fru_status.get(
"AC Status")).strip().upper() == "OK" else False

psu_status_dict["Present"] = psu_ps_status
if psu_ps_status:
psu_status_dict["PowerStatus"] = psu_pw_status
psu_status_dict["PN"] = psu_info_dict[psu_idx]["PN"]
psu_status_dict["SN"] = psu_info_dict[psu_idx]["SN"]
psu_status_dict["InputType"] = psu_pw_type
psu_status_dict["InputStatus"] = True if psu_pw_status and psu_ps_status else False
psu_status_dict["OutputStatus"] = ac_status
psu_status_dict["AirFlow"] = self.airflow_selector(
psu_status_dict["PN"].split()[0])
all_psu_dict[find_psu[0]] = psu_status_dict

return all_psu_dict
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class SensorUtil():

def __init__(self):
self.sensor_url = "http://240.1.1.1:8080/api/sys/sensors"
self.sys_fruid_url = "http://240.1.1.1:8080/api/sys/fruid/sys"
self.sensor_info_list = None

def request_data(self):
Expand All @@ -21,6 +22,9 @@ def request_data(self):
sensor_data_req = requests.get(self.sensor_url)
sensor_json = sensor_data_req.json()
self.sensor_info_list = sensor_json.get('Information')
sys_fruid_req = requests.get(self.sys_fruid_url)
sys_fruid_json = sys_fruid_req.json()
self.sys_fruid_list = sys_fruid_json.get('Information')
return self.sensor_info_list

def input_type_selector(self, unit):
Expand Down Expand Up @@ -291,6 +295,22 @@ def get_sensor_input_high_threshold(self, sensor_index, input_index):

return sensor_input_high_threshold

def get_sys_airflow(self):
sys_air_flow = "Unknown"
sys_pn_data = [
v.split(":") for v in self.sys_fruid_list if "Product Part Number" in v]

if len(sys_pn_data) == 0:
return sys_air_flow

sys_pn = sys_pn_data[0][1]
if "R1241-F0001" in sys_pn:
sys_air_flow = "FTOB"
elif"R1241-F0002" in sys_pn:
sys_air_flow = "BTOF"

return sys_air_flow

def get_all(self):

all_sensor_dict = dict()
Expand Down Expand Up @@ -336,4 +356,8 @@ def get_all(self):

all_sensor_dict[self.sensor_name].update(sensor_dict)

sensor_dict = dict()
sensor_dict["Sys_AirFlow"] = self.get_sys_airflow()
all_sensor_dict["TEMPERATURE"].update(sensor_dict)

return all_sensor_dict
Loading