forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[device/alibaba]: Update firmware_program api to install cpld on cpu
- Loading branch information
1 parent
a5600a1
commit 37274e1
Showing
3 changed files
with
87 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -669,28 +669,26 @@ def firmware_program(self, fw_type, fw_path, fw_extra=None): | |
"Failed: Invalid extra information string %s" % data[1]) | ||
break | ||
|
||
# Uploading image to BMC | ||
print("Uploading image to BMC...") | ||
upload_file = self.upload_file_bmc(fw_path) | ||
if not upload_file: | ||
print("%s failed: Unable to upload image to BMC" % | ||
data[1]) | ||
continue | ||
|
||
filename_w_ext = os.path.basename(fw_path) | ||
json_data = dict() | ||
json_data["image_path"] = "[email protected]:/home/root/%s" % filename_w_ext | ||
json_data["password"] = bmc_pwd | ||
json_data["device"] = "cpld" | ||
json_data["reboot"] = "no" | ||
json_data["type"] = fw_extra_str | ||
|
||
# Call BMC api to install cpld image | ||
# Install cpld image via ispvm tool | ||
print("Installing...") | ||
r = requests.post(self.fw_upgrade_url, json=json_data) | ||
if r.status_code != 200: | ||
print("%s failed: BMC API report error code %d" % | ||
(data[1], r.status_code)) | ||
command = 'ispvm %s' % fw_path | ||
if fw_extra_str in ["top_lc", "bottom_lc"]: | ||
option = 1 if fw_extra_str == "top_lc" else 2 | ||
command = "ispvm -c %d %s" % (option, | ||
os.path.abspath(fw_path)) | ||
print("Running command : %s" % command) | ||
process = subprocess.Popen( | ||
command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
|
||
while True: | ||
output = process.stdout.readline() | ||
if output == '' and process.poll() is not None: | ||
break | ||
|
||
rc = process.returncode | ||
if rc != 0: | ||
print("Failed: Unable to install CPLD") | ||
continue | ||
|
||
print("%s upgrade completed\n" % fw_extra_str) | ||
|
@@ -720,11 +718,13 @@ def firmware_refresh(self, fpga_list, cpld_list, fw_extra=None): | |
No operation if the power cycle is not needed. | ||
Example: | ||
self.firmware_refresh(["FPGA"], ["BASE_CPLD", "LC_CPLD"],"/tmp/fw/refresh.vme") | ||
self.firmware_refresh( | ||
["FPGA"], ["BASE_CPLD", "LC_CPLD"],"/tmp/fw/refresh.vme") | ||
or | ||
self.firmware_refresh(["FPGA"], None, None) | ||
or | ||
self.firmware_refresh(None, ["FAN_CPLD", "LC1_CPLD", "BASE_CPLD"], "/tmp/fw/fan_refresh.vme:none:/tmp/fw/base_refresh.vme") | ||
self.firmware_refresh(None, ["FAN_CPLD", "LC1_CPLD", "BASE_CPLD"], | ||
"/tmp/fw/fan_refresh.vme:none:/tmp/fw/base_refresh.vme") | ||
""" | ||
upgrade_list = [] | ||
if not fpga_list and not cpld_list: | ||
|
@@ -772,6 +772,13 @@ def firmware_refresh(self, fpga_list, cpld_list, fw_extra=None): | |
if r.status_code != 200: | ||
print("Failed: %d Unable to load new FPGA" % r.status_code) | ||
return False | ||
elif cpld_list: | ||
json_data = dict() | ||
json_data["data"] = "echo cpu_cpld > /tmp/cpld_refresh" | ||
r = requests.post(self.bmc_raw_command_url, json=json_data) | ||
if r.status_code != 200: | ||
print("Failed: %d Unable to load new CPLD" % r.status_code) | ||
return False | ||
else: | ||
print("Failed: Invalid input") | ||
return False | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -669,28 +669,26 @@ def firmware_program(self, fw_type, fw_path, fw_extra=None): | |
"Failed: Invalid extra information string %s" % data[1]) | ||
break | ||
|
||
# Uploading image to BMC | ||
print("Uploading image to BMC...") | ||
upload_file = self.upload_file_bmc(fw_path) | ||
if not upload_file: | ||
print("%s failed: Unable to upload image to BMC" % | ||
data[1]) | ||
continue | ||
|
||
filename_w_ext = os.path.basename(fw_path) | ||
json_data = dict() | ||
json_data["image_path"] = "[email protected]:/home/root/%s" % filename_w_ext | ||
json_data["password"] = bmc_pwd | ||
json_data["device"] = "cpld" | ||
json_data["reboot"] = "no" | ||
json_data["type"] = fw_extra_str | ||
|
||
# Call BMC api to install cpld image | ||
# Install cpld image via ispvm tool | ||
print("Installing...") | ||
r = requests.post(self.fw_upgrade_url, json=json_data) | ||
if r.status_code != 200: | ||
print("%s failed: BMC API report error code %d" % | ||
(data[1], r.status_code)) | ||
command = 'ispvm %s' % fw_path | ||
if fw_extra_str in ["top_lc", "bottom_lc"]: | ||
option = 1 if fw_extra_str == "top_lc" else 2 | ||
command = "ispvm -c %d %s" % (option, | ||
os.path.abspath(fw_path)) | ||
print("Running command : %s" % command) | ||
process = subprocess.Popen( | ||
command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
|
||
while True: | ||
output = process.stdout.readline() | ||
if output == '' and process.poll() is not None: | ||
break | ||
|
||
rc = process.returncode | ||
if rc != 0: | ||
print("Failed: Unable to install CPLD") | ||
continue | ||
|
||
print("%s upgrade completed\n" % fw_extra_str) | ||
|
@@ -720,11 +718,13 @@ def firmware_refresh(self, fpga_list, cpld_list, fw_extra=None): | |
No operation if the power cycle is not needed. | ||
Example: | ||
self.firmware_refresh(["FPGA"], ["BASE_CPLD", "LC_CPLD"],"/tmp/fw/refresh.vme") | ||
self.firmware_refresh( | ||
["FPGA"], ["BASE_CPLD", "LC_CPLD"],"/tmp/fw/refresh.vme") | ||
or | ||
self.firmware_refresh(["FPGA"], None, None) | ||
or | ||
self.firmware_refresh(None, ["FAN_CPLD", "LC1_CPLD", "BASE_CPLD"], "/tmp/fw/fan_refresh.vme:none:/tmp/fw/base_refresh.vme") | ||
self.firmware_refresh(None, ["FAN_CPLD", "LC1_CPLD", "BASE_CPLD"], | ||
"/tmp/fw/fan_refresh.vme:none:/tmp/fw/base_refresh.vme") | ||
""" | ||
upgrade_list = [] | ||
if not fpga_list and not cpld_list: | ||
|
@@ -772,6 +772,13 @@ def firmware_refresh(self, fpga_list, cpld_list, fw_extra=None): | |
if r.status_code != 200: | ||
print("Failed: %d Unable to load new FPGA" % r.status_code) | ||
return False | ||
elif cpld_list: | ||
json_data = dict() | ||
json_data["data"] = "echo cpu_cpld > /tmp/cpld_refresh" | ||
r = requests.post(self.bmc_raw_command_url, json=json_data) | ||
if r.status_code != 200: | ||
print("Failed: %d Unable to load new CPLD" % r.status_code) | ||
return False | ||
else: | ||
print("Failed: Invalid input") | ||
return False | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -669,28 +669,26 @@ def firmware_program(self, fw_type, fw_path, fw_extra=None): | |
"Failed: Invalid extra information string %s" % data[1]) | ||
break | ||
|
||
# Uploading image to BMC | ||
print("Uploading image to BMC...") | ||
upload_file = self.upload_file_bmc(fw_path) | ||
if not upload_file: | ||
print("%s failed: Unable to upload image to BMC" % | ||
data[1]) | ||
continue | ||
|
||
filename_w_ext = os.path.basename(fw_path) | ||
json_data = dict() | ||
json_data["image_path"] = "[email protected]:/home/root/%s" % filename_w_ext | ||
json_data["password"] = bmc_pwd | ||
json_data["device"] = "cpld" | ||
json_data["reboot"] = "no" | ||
json_data["type"] = fw_extra_str | ||
|
||
# Call BMC api to install cpld image | ||
# Install cpld image via ispvm tool | ||
print("Installing...") | ||
r = requests.post(self.fw_upgrade_url, json=json_data) | ||
if r.status_code != 200: | ||
print("%s failed: BMC API report error code %d" % | ||
(data[1], r.status_code)) | ||
command = 'ispvm %s' % fw_path | ||
if fw_extra_str in ["top_lc", "bottom_lc"]: | ||
option = 1 if fw_extra_str == "top_lc" else 2 | ||
command = "ispvm -c %d %s" % (option, | ||
os.path.abspath(fw_path)) | ||
print("Running command : %s" % command) | ||
process = subprocess.Popen( | ||
command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
|
||
while True: | ||
output = process.stdout.readline() | ||
if output == '' and process.poll() is not None: | ||
break | ||
|
||
rc = process.returncode | ||
if rc != 0: | ||
print("Failed: Unable to install CPLD") | ||
continue | ||
|
||
print("%s upgrade completed\n" % fw_extra_str) | ||
|
@@ -720,11 +718,13 @@ def firmware_refresh(self, fpga_list, cpld_list, fw_extra=None): | |
No operation if the power cycle is not needed. | ||
Example: | ||
self.firmware_refresh(["FPGA"], ["BASE_CPLD", "LC_CPLD"],"/tmp/fw/refresh.vme") | ||
self.firmware_refresh( | ||
["FPGA"], ["BASE_CPLD", "LC_CPLD"],"/tmp/fw/refresh.vme") | ||
or | ||
self.firmware_refresh(["FPGA"], None, None) | ||
or | ||
self.firmware_refresh(None, ["FAN_CPLD", "LC1_CPLD", "BASE_CPLD"], "/tmp/fw/fan_refresh.vme:none:/tmp/fw/base_refresh.vme") | ||
self.firmware_refresh(None, ["FAN_CPLD", "LC1_CPLD", "BASE_CPLD"], | ||
"/tmp/fw/fan_refresh.vme:none:/tmp/fw/base_refresh.vme") | ||
""" | ||
upgrade_list = [] | ||
if not fpga_list and not cpld_list: | ||
|
@@ -772,6 +772,13 @@ def firmware_refresh(self, fpga_list, cpld_list, fw_extra=None): | |
if r.status_code != 200: | ||
print("Failed: %d Unable to load new FPGA" % r.status_code) | ||
return False | ||
elif cpld_list: | ||
json_data = dict() | ||
json_data["data"] = "echo cpu_cpld > /tmp/cpld_refresh" | ||
r = requests.post(self.bmc_raw_command_url, json=json_data) | ||
if r.status_code != 200: | ||
print("Failed: %d Unable to load new CPLD" % r.status_code) | ||
return False | ||
else: | ||
print("Failed: Invalid input") | ||
return False | ||
|