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

Update Ali platform and device plugin and bug fixes #6

Merged
merged 6 commits into from Nov 22, 2018
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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
url = https://github.com/Ingrasys-sonic/sonic-platform-modules-ingrasys
[submodule "src/sonic-platform-common"]
path = src/sonic-platform-common
url = https://github.com/Azure/sonic-platform-common
url = https://github.com/celestica-Inc/sonic-platform-common
[submodule "src/sonic-platform-daemons"]
path = src/sonic-platform-daemons
url = https://github.com/Azure/sonic-platform-daemons
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def get_num_psus(self):
# 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

Expand Down
67 changes: 36 additions & 31 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 @@ -2,14 +2,14 @@

import requests


class SensorUtil():
"""Platform-specific SensorUtil class"""

def __init__(self):
self.sensor_url = "http://[fe80::1:1%eth0.4088]:8080/api/sys/sensors"
self.sensor_info_list = None


def request_data(self):
# Reqest data from BMC if not exist.
if self.sensor_info_list is None:
Expand All @@ -18,39 +18,36 @@ def request_data(self):
self.sensor_info_list = sensor_json.get('Information')
return self.sensor_info_list


def input_type_selector(self, unit):
# Set input type.
return {
"C" : "temperature",
"V" : "voltage",
"RPM" : "fan_speed",
"A" : "current",
"W" : "power"
}.get(unit, unit)


def get_num_sensors(self):
"C": "temperature",
"V": "voltage",
"RPM": "fan_speed",
"A": "current",
"W": "power"
}.get(unit, unit)

def get_num_sensors(self):
"""
Get the number of sensors
:return: int num_sensors
"""

num_sensors = 0
try:
# Request and validate sensor's information
self.sensor_info_list = self.request_data()
# Get number of sensors.

# Get number of sensors.
num_sensors = len(self.sensor_info_list)
except:
print "Error: Unable to access sensor information"
return 0

return num_sensors


def get_sensor_input_num(self, index):
def get_sensor_input_num(self, index):
"""
Get the number of the input items of the specified sensor
:return: int input_num
Expand All @@ -67,9 +64,8 @@ def get_sensor_input_num(self, index):
except:
print "Error: Unable to access sensor information"
return 0

return input_num

return input_num

def get_sensor_name(self, index):
"""
Expand All @@ -92,7 +88,6 @@ def get_sensor_name(self, index):

return sensor_name


def get_sensor_input_name(self, sensor_index, input_index):
"""
Get the input item name of the specified input item of the
Expand All @@ -118,7 +113,6 @@ def get_sensor_input_name(self, sensor_index, input_index):

return sensor_input_name


def get_sensor_input_type(self, sensor_index, input_index):
"""
Get the item type of the specified input item of the specified sensor index,
Expand Down Expand Up @@ -146,7 +140,6 @@ def get_sensor_input_type(self, sensor_index, input_index):

return sensor_input_type


def get_sensor_input_value(self, sensor_index, input_index):
"""
Get the current value of the input item, the unit is "V" or "C"
Expand All @@ -167,14 +160,14 @@ def get_sensor_input_value(self, sensor_index, input_index):
sensor_data_key = sensor_data.keys()
sensor_input_raw = sensor_data.get(sensor_data_key[input_index-1])
sensor_data_str = sensor_input_raw.split()
sensor_input_value = float(sensor_data_str[0]) if sensor_data_str[0] != "N/A" else 0
sensor_input_value = float(
sensor_data_str[0]) if sensor_data_str[0] != "N/A" else 0
except:
print "Error: Unable to access sensor information"
return 0

return sensor_input_value


def get_sensor_input_low_threshold(self, sensor_index, input_index):
"""
Get the low threshold of the value,
Expand All @@ -196,16 +189,21 @@ def get_sensor_input_low_threshold(self, sensor_index, input_index):
sensor_data_key = sensor_data.keys()
sensor_input_raw = sensor_data.get(sensor_data_key[input_index-1])
sensor_data_str = sensor_input_raw.split()
indices = [i for i, s in enumerate(sensor_data_str) if 'min' in s or 'low' in s]
sensor_input_low_threshold = float(sensor_data_str[indices[0] + 2]) if len(indices) != 0 else 0

indices = [i for i, s in enumerate(
sensor_data_str) if 'min' in s or 'low' in s]
l_thres = float(
sensor_data_str[indices[0] + 2]) if len(indices) != 0 else 0
unit = sensor_data_str[indices[0] +
3] if len(indices) != 0 else None
if unit is not None and len(unit) > 1:
sensor_input_low_threshold = l_thres * \
1000 if str(unit[0]).lower() == 'k' else l_thres
except:
print "Error: Unable to access sensor information"
return 0

return sensor_input_low_threshold


def get_sensor_input_high_threshold(self, sensor_index, input_index):
"""
Get the high threshold of the value,
Expand All @@ -223,15 +221,22 @@ def get_sensor_input_high_threshold(self, sensor_index, input_index):
del sensor_data["name"]
del sensor_data["Adapter"]

# Get sensor's input high threshold.
# Get sensor's input high threshold.
sensor_data_key = sensor_data.keys()
sensor_input_raw = sensor_data.get(sensor_data_key[input_index-1])
sensor_data_str = sensor_input_raw.split()
indices = [i for i, s in enumerate(sensor_data_str) if 'max' in s or 'high' in s]
sensor_input_high_threshold = float(sensor_data_str[indices[0] + 2]) if len(indices) != 0 else 0
indices = [i for i, s in enumerate(
sensor_data_str) if 'max' in s or 'high' in s]
h_thres = float(
sensor_data_str[indices[0] + 2]) if len(indices) != 0 else 0
unit = sensor_data_str[indices[0] +
3] if len(indices) != 0 else None
if unit is not None and len(unit) > 1:
sensor_input_high_threshold = h_thres * \
1000 if str(unit[0]).lower() == 'k' else h_thres

except:
print "Error: Unable to access sensor information"
return 0

return sensor_input_high_threshold
return sensor_input_high_threshold
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def get_num_psus(self):
# 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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import requests


class SensorUtil():
"""Platform-specific SensorUtil class"""

def __init__(self):
self.sensor_url = "http://[fe80::1:1%eth0.4088]:8080/api/sys/sensors"
self.sensor_info_list = None


def request_data(self):
# Reqest data from BMC if not exist.
if self.sensor_info_list is None:
Expand All @@ -18,39 +18,36 @@ def request_data(self):
self.sensor_info_list = sensor_json.get('Information')
return self.sensor_info_list


def input_type_selector(self, unit):
# Set input type.
return {
"C" : "temperature",
"V" : "voltage",
"RPM" : "fan_speed",
"A" : "current",
"W" : "power"
}.get(unit, unit)


def get_num_sensors(self):
"C": "temperature",
"V": "voltage",
"RPM": "fan_speed",
"A": "current",
"W": "power"
}.get(unit, unit)

def get_num_sensors(self):
"""
Get the number of sensors
:return: int num_sensors
"""

num_sensors = 0
try:
# Request and validate sensor's information
self.sensor_info_list = self.request_data()
# Get number of sensors.

# Get number of sensors.
num_sensors = len(self.sensor_info_list)
except:
print "Error: Unable to access sensor information"
return 0

return num_sensors


def get_sensor_input_num(self, index):
def get_sensor_input_num(self, index):
"""
Get the number of the input items of the specified sensor
:return: int input_num
Expand All @@ -67,9 +64,8 @@ def get_sensor_input_num(self, index):
except:
print "Error: Unable to access sensor information"
return 0

return input_num

return input_num

def get_sensor_name(self, index):
"""
Expand All @@ -92,7 +88,6 @@ def get_sensor_name(self, index):

return sensor_name


def get_sensor_input_name(self, sensor_index, input_index):
"""
Get the input item name of the specified input item of the
Expand All @@ -118,7 +113,6 @@ def get_sensor_input_name(self, sensor_index, input_index):

return sensor_input_name


def get_sensor_input_type(self, sensor_index, input_index):
"""
Get the item type of the specified input item of the specified sensor index,
Expand Down Expand Up @@ -146,7 +140,6 @@ def get_sensor_input_type(self, sensor_index, input_index):

return sensor_input_type


def get_sensor_input_value(self, sensor_index, input_index):
"""
Get the current value of the input item, the unit is "V" or "C"
Expand All @@ -167,14 +160,14 @@ def get_sensor_input_value(self, sensor_index, input_index):
sensor_data_key = sensor_data.keys()
sensor_input_raw = sensor_data.get(sensor_data_key[input_index-1])
sensor_data_str = sensor_input_raw.split()
sensor_input_value = float(sensor_data_str[0]) if sensor_data_str[0] != "N/A" else 0
sensor_input_value = float(
sensor_data_str[0]) if sensor_data_str[0] != "N/A" else 0
except:
print "Error: Unable to access sensor information"
return 0

return sensor_input_value


def get_sensor_input_low_threshold(self, sensor_index, input_index):
"""
Get the low threshold of the value,
Expand All @@ -196,16 +189,21 @@ def get_sensor_input_low_threshold(self, sensor_index, input_index):
sensor_data_key = sensor_data.keys()
sensor_input_raw = sensor_data.get(sensor_data_key[input_index-1])
sensor_data_str = sensor_input_raw.split()
indices = [i for i, s in enumerate(sensor_data_str) if 'min' in s or 'low' in s]
sensor_input_low_threshold = float(sensor_data_str[indices[0] + 2]) if len(indices) != 0 else 0

indices = [i for i, s in enumerate(
sensor_data_str) if 'min' in s or 'low' in s]
l_thres = float(
sensor_data_str[indices[0] + 2]) if len(indices) != 0 else 0
unit = sensor_data_str[indices[0] +
3] if len(indices) != 0 else None
if unit is not None and len(unit) > 1:
sensor_input_low_threshold = l_thres * \
1000 if str(unit[0]).lower() == 'k' else l_thres
except:
print "Error: Unable to access sensor information"
return 0

return sensor_input_low_threshold


def get_sensor_input_high_threshold(self, sensor_index, input_index):
"""
Get the high threshold of the value,
Expand All @@ -223,15 +221,22 @@ def get_sensor_input_high_threshold(self, sensor_index, input_index):
del sensor_data["name"]
del sensor_data["Adapter"]

# Get sensor's input high threshold.
# Get sensor's input high threshold.
sensor_data_key = sensor_data.keys()
sensor_input_raw = sensor_data.get(sensor_data_key[input_index-1])
sensor_data_str = sensor_input_raw.split()
indices = [i for i, s in enumerate(sensor_data_str) if 'max' in s or 'high' in s]
sensor_input_high_threshold = float(sensor_data_str[indices[0] + 2]) if len(indices) != 0 else 0
indices = [i for i, s in enumerate(
sensor_data_str) if 'max' in s or 'high' in s]
h_thres = float(
sensor_data_str[indices[0] + 2]) if len(indices) != 0 else 0
unit = sensor_data_str[indices[0] +
3] if len(indices) != 0 else None
if unit is not None and len(unit) > 1:
sensor_input_high_threshold = h_thres * \
1000 if str(unit[0]).lower() == 'k' else h_thres

except:
print "Error: Unable to access sensor information"
return 0

return sensor_input_high_threshold
return sensor_input_high_threshold
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def get_num_psus(self):
# 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

Expand Down
Loading