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 and platform module configuration #55

Merged
merged 6 commits into from Feb 25, 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
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def get_cpld_version(self):
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))
FAN_CPLD = 'None' if CPLD_4 is None else "{}.{}".format(
int(fan_cpld[0], 16), int(fan_cpld[1], 16))

cpld_version_dict = {}
cpld_version_dict.update({'CPLD_B': CPLD_B})
Expand Down Expand Up @@ -224,17 +224,15 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None):
print("Installing BMC as master mode...")
json_data["flash"] = "master"
r = requests.post(self.bmc_info_url, json=json_data)
return_data = r.json()
if r.status_code != 200 or 'success' not in return_data.get('result'):
if r.status_code != 200 or 'success' not in r.json().get('result'):
print("Failed")
return False
print("Done")
json_data["flash"] = "slave"

print("Installing BMC as %s mode..." % json_data["flash"])
r = requests.post(self.bmc_info_url, json=json_data)
return_data = r.json()
if r.status_code == 200 and 'success' in return_data.get('result'):
if r.status_code == 200 and 'success' in r.json().get('result'):
print("Done, Rebooting BMC.....")
reboot_dict = dict()
reboot_dict["reboot"] = "yes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ def input_name_selector(self, sensor_name, input_name):
"tmp75-i2c-39-48": "BTF_INLET_RIGHT",
"tmp75-i2c-39-49": "BTF_INLET_LEFT"
}.get(sensor_name, input_name)
if self.get_sys_airflow() == "FTOB" and sensor_name == "tmp75-i2c-7-4d":
input_name = "INLET_TEMP"

if self.get_sys_airflow() == "BTOF" and sensor_name == "tmp75-i2c-39-48":
input_name = "INLET_TEMP"

self.sensor_name = "TEMPERATURE"

elif 'fancpld' in sensor_name:
Expand Down
22 changes: 22 additions & 0 deletions device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,25 @@ def get_transceiver_change_event(self, timeout=0):
TBD
"""
return NotImplementedError

def tx_disable(self, port_num, disable):
"""
@param port_num index of physical port
@param disable, True -- disable port tx signal
False -- enable port tx signal
@return True when operation success, False on failure.
"""
if port_num not in range(self.port_start, self.port_end + 1) or type(disable) != bool:
return False

try:
disable = hex(1) if disable else hex(0)
port_name = self.get_port_name(port_num)
reg_file = open(
"/".join([self.PORT_INFO_PATH, port_name, "sfp_txdisable"]), "w")
reg_file.write(disable)
except IOError as e:
print "Error: unable to open file: %s" % str(e)
return False

return True
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def get_cpld_version(self):
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))
FAN_CPLD = 'None' if CPLD_4 is None else "{}.{}".format(
int(fan_cpld[0], 16), int(fan_cpld[1], 16))

cpld_version_dict = {}
cpld_version_dict.update({'CPLD_B': CPLD_B})
Expand Down Expand Up @@ -224,17 +224,15 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None):
print("Installing BMC as master mode...")
json_data["flash"] = "master"
r = requests.post(self.bmc_info_url, json=json_data)
return_data = r.json()
if r.status_code != 200 or 'success' not in return_data.get('result'):
if r.status_code != 200 or 'success' not in r.json().get('result'):
print("Failed")
return False
print("Done")
json_data["flash"] = "slave"

print("Installing BMC as %s mode..." % json_data["flash"])
r = requests.post(self.bmc_info_url, json=json_data)
return_data = r.json()
if r.status_code == 200 and 'success' in return_data.get('result'):
if r.status_code == 200 and 'success' in r.json().get('result'):
print("Done, Rebooting BMC.....")
reboot_dict = dict()
reboot_dict["reboot"] = "yes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ def input_name_selector(self, sensor_name, input_name):
"tmp75-i2c-39-48": "BTF_INLET_RIGHT",
"tmp75-i2c-39-49": "BTF_INLET_LEFT"
}.get(sensor_name, input_name)
if self.get_sys_airflow() == "FTOB" and sensor_name == "tmp75-i2c-7-4d":
input_name = "INLET_TEMP"

if self.get_sys_airflow() == "BTOF" and sensor_name == "tmp75-i2c-39-48":
input_name = "INLET_TEMP"

self.sensor_name = "TEMPERATURE"

elif 'fancpld' in sensor_name:
Expand Down Expand Up @@ -326,6 +332,7 @@ def get_all(self):

# Set sensor data.
sensor_dict = dict()

for k, v in sensor_info.items():
sensor_i_dict = dict()
sensor_data_str = v.split()
Expand Down
22 changes: 22 additions & 0 deletions device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,25 @@ def get_transceiver_change_event(self, timeout=0):
TBD
"""
return NotImplementedError

def tx_disable(self, port_num, disable):
"""
@param port_num index of physical port
@param disable, True -- disable port tx signal
False -- enable port tx signal
@return True when operation success, False on failure.
"""
if port_num not in range(self.port_start, self.port_end + 1) or type(disable) != bool:
return False

try:
disable = hex(1) if disable else hex(0)
port_name = self.get_port_name(port_num)
reg_file = open(
"/".join([self.PORT_INFO_PATH, port_name, "sfp_txdisable"]), "w")
reg_file.write(disable)
except IOError as e:
print "Error: unable to open file: %s" % str(e)
return False

return True
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def get_cpld_version(self):
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))
FAN_CPLD = 'None' if CPLD_4 is None else "{}.{}".format(
int(fan_cpld[0], 16), int(fan_cpld[1], 16))

cpld_version_dict = {}
cpld_version_dict.update({'CPLD_B': CPLD_B})
Expand Down Expand Up @@ -224,17 +224,15 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None):
print("Installing BMC as master mode...")
json_data["flash"] = "master"
r = requests.post(self.bmc_info_url, json=json_data)
return_data = r.json()
if r.status_code != 200 or 'success' not in return_data.get('result'):
if r.status_code != 200 or 'success' not in r.json().get('result'):
print("Failed")
return False
print("Done")
json_data["flash"] = "slave"

print("Installing BMC as %s mode..." % json_data["flash"])
r = requests.post(self.bmc_info_url, json=json_data)
return_data = r.json()
if r.status_code == 200 and 'success' in return_data.get('result'):
if r.status_code == 200 and 'success' in r.json().get('result'):
print("Done, Rebooting BMC.....")
reboot_dict = dict()
reboot_dict["reboot"] = "yes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def input_name_selector(self, sensor_name, input_name):
"tmp75-i2c-7-4e": "BASEBOARD_INLET_CENTER",
"tmp75-i2c-7-4d": "SWITCH_OUTLET",
"tmp75-i2c-31-48": "PSU_INLET_LEFT",
"tmp75-i2c-31-49": "PSU_INLET_RIGHT",
"tmp75-i2c-31-49": "INLET_TEMP",
"tmp75-i2c-39-48": "FANBOARD_LEFT",
"tmp75-i2c-39-49": "FANBOARD_RIGHT",
"tmp75-i2c-42-48": "LINECARD_TOP_RIGHT",
Expand Down
22 changes: 22 additions & 0 deletions device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,25 @@ def get_transceiver_change_event(self, timeout=0):
TBD
"""
return NotImplementedError

def tx_disable(self, port_num, disable):
"""
@param port_num index of physical port
@param disable, True -- disable port tx signal
False -- enable port tx signal
@return True when operation success, False on failure.
"""
if port_num not in range(self.port_start, self.port_end + 1) or type(disable) != bool:
return False

try:
disable = hex(1) if disable else hex(0)
port_name = self.get_port_name(port_num)
reg_file = open(
"/".join([self.PORT_INFO_PATH, port_name, "sfp_txdisable"]), "w")
reg_file.write(disable)
except IOError as e:
print "Error: unable to open file: %s" % str(e)
return False

return True