Skip to content

Commit 37274e1

Browse files
Wirut Getbamrungtiantianlv
authored andcommitted
[device/alibaba]: Update firmware_program api to install cpld on cpu
1 parent a5600a1 commit 37274e1

File tree

3 files changed

+87
-66
lines changed

3 files changed

+87
-66
lines changed

device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -669,28 +669,26 @@ def firmware_program(self, fw_type, fw_path, fw_extra=None):
669669
"Failed: Invalid extra information string %s" % data[1])
670670
break
671671

672-
# Uploading image to BMC
673-
print("Uploading image to BMC...")
674-
upload_file = self.upload_file_bmc(fw_path)
675-
if not upload_file:
676-
print("%s failed: Unable to upload image to BMC" %
677-
data[1])
678-
continue
679-
680672
filename_w_ext = os.path.basename(fw_path)
681-
json_data = dict()
682-
json_data["image_path"] = "[email protected]:/home/root/%s" % filename_w_ext
683-
json_data["password"] = bmc_pwd
684-
json_data["device"] = "cpld"
685-
json_data["reboot"] = "no"
686-
json_data["type"] = fw_extra_str
687-
688-
# Call BMC api to install cpld image
673+
# Install cpld image via ispvm tool
689674
print("Installing...")
690-
r = requests.post(self.fw_upgrade_url, json=json_data)
691-
if r.status_code != 200:
692-
print("%s failed: BMC API report error code %d" %
693-
(data[1], r.status_code))
675+
command = 'ispvm %s' % fw_path
676+
if fw_extra_str in ["top_lc", "bottom_lc"]:
677+
option = 1 if fw_extra_str == "top_lc" else 2
678+
command = "ispvm -c %d %s" % (option,
679+
os.path.abspath(fw_path))
680+
print("Running command : %s" % command)
681+
process = subprocess.Popen(
682+
command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
683+
684+
while True:
685+
output = process.stdout.readline()
686+
if output == '' and process.poll() is not None:
687+
break
688+
689+
rc = process.returncode
690+
if rc != 0:
691+
print("Failed: Unable to install CPLD")
694692
continue
695693

696694
print("%s upgrade completed\n" % fw_extra_str)
@@ -720,11 +718,13 @@ def firmware_refresh(self, fpga_list, cpld_list, fw_extra=None):
720718
No operation if the power cycle is not needed.
721719
722720
Example:
723-
self.firmware_refresh(["FPGA"], ["BASE_CPLD", "LC_CPLD"],"/tmp/fw/refresh.vme")
721+
self.firmware_refresh(
722+
["FPGA"], ["BASE_CPLD", "LC_CPLD"],"/tmp/fw/refresh.vme")
724723
or
725724
self.firmware_refresh(["FPGA"], None, None)
726725
or
727-
self.firmware_refresh(None, ["FAN_CPLD", "LC1_CPLD", "BASE_CPLD"], "/tmp/fw/fan_refresh.vme:none:/tmp/fw/base_refresh.vme")
726+
self.firmware_refresh(None, ["FAN_CPLD", "LC1_CPLD", "BASE_CPLD"],
727+
"/tmp/fw/fan_refresh.vme:none:/tmp/fw/base_refresh.vme")
728728
"""
729729
upgrade_list = []
730730
if not fpga_list and not cpld_list:
@@ -772,6 +772,13 @@ def firmware_refresh(self, fpga_list, cpld_list, fw_extra=None):
772772
if r.status_code != 200:
773773
print("Failed: %d Unable to load new FPGA" % r.status_code)
774774
return False
775+
elif cpld_list:
776+
json_data = dict()
777+
json_data["data"] = "echo cpu_cpld > /tmp/cpld_refresh"
778+
r = requests.post(self.bmc_raw_command_url, json=json_data)
779+
if r.status_code != 200:
780+
print("Failed: %d Unable to load new CPLD" % r.status_code)
781+
return False
775782
else:
776783
print("Failed: Invalid input")
777784
return False

device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fwmgrutil.py

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -669,28 +669,26 @@ def firmware_program(self, fw_type, fw_path, fw_extra=None):
669669
"Failed: Invalid extra information string %s" % data[1])
670670
break
671671

672-
# Uploading image to BMC
673-
print("Uploading image to BMC...")
674-
upload_file = self.upload_file_bmc(fw_path)
675-
if not upload_file:
676-
print("%s failed: Unable to upload image to BMC" %
677-
data[1])
678-
continue
679-
680672
filename_w_ext = os.path.basename(fw_path)
681-
json_data = dict()
682-
json_data["image_path"] = "[email protected]:/home/root/%s" % filename_w_ext
683-
json_data["password"] = bmc_pwd
684-
json_data["device"] = "cpld"
685-
json_data["reboot"] = "no"
686-
json_data["type"] = fw_extra_str
687-
688-
# Call BMC api to install cpld image
673+
# Install cpld image via ispvm tool
689674
print("Installing...")
690-
r = requests.post(self.fw_upgrade_url, json=json_data)
691-
if r.status_code != 200:
692-
print("%s failed: BMC API report error code %d" %
693-
(data[1], r.status_code))
675+
command = 'ispvm %s' % fw_path
676+
if fw_extra_str in ["top_lc", "bottom_lc"]:
677+
option = 1 if fw_extra_str == "top_lc" else 2
678+
command = "ispvm -c %d %s" % (option,
679+
os.path.abspath(fw_path))
680+
print("Running command : %s" % command)
681+
process = subprocess.Popen(
682+
command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
683+
684+
while True:
685+
output = process.stdout.readline()
686+
if output == '' and process.poll() is not None:
687+
break
688+
689+
rc = process.returncode
690+
if rc != 0:
691+
print("Failed: Unable to install CPLD")
694692
continue
695693

696694
print("%s upgrade completed\n" % fw_extra_str)
@@ -720,11 +718,13 @@ def firmware_refresh(self, fpga_list, cpld_list, fw_extra=None):
720718
No operation if the power cycle is not needed.
721719
722720
Example:
723-
self.firmware_refresh(["FPGA"], ["BASE_CPLD", "LC_CPLD"],"/tmp/fw/refresh.vme")
721+
self.firmware_refresh(
722+
["FPGA"], ["BASE_CPLD", "LC_CPLD"],"/tmp/fw/refresh.vme")
724723
or
725724
self.firmware_refresh(["FPGA"], None, None)
726725
or
727-
self.firmware_refresh(None, ["FAN_CPLD", "LC1_CPLD", "BASE_CPLD"], "/tmp/fw/fan_refresh.vme:none:/tmp/fw/base_refresh.vme")
726+
self.firmware_refresh(None, ["FAN_CPLD", "LC1_CPLD", "BASE_CPLD"],
727+
"/tmp/fw/fan_refresh.vme:none:/tmp/fw/base_refresh.vme")
728728
"""
729729
upgrade_list = []
730730
if not fpga_list and not cpld_list:
@@ -772,6 +772,13 @@ def firmware_refresh(self, fpga_list, cpld_list, fw_extra=None):
772772
if r.status_code != 200:
773773
print("Failed: %d Unable to load new FPGA" % r.status_code)
774774
return False
775+
elif cpld_list:
776+
json_data = dict()
777+
json_data["data"] = "echo cpu_cpld > /tmp/cpld_refresh"
778+
r = requests.post(self.bmc_raw_command_url, json=json_data)
779+
if r.status_code != 200:
780+
print("Failed: %d Unable to load new CPLD" % r.status_code)
781+
return False
775782
else:
776783
print("Failed: Invalid input")
777784
return False

device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fwmgrutil.py

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -669,28 +669,26 @@ def firmware_program(self, fw_type, fw_path, fw_extra=None):
669669
"Failed: Invalid extra information string %s" % data[1])
670670
break
671671

672-
# Uploading image to BMC
673-
print("Uploading image to BMC...")
674-
upload_file = self.upload_file_bmc(fw_path)
675-
if not upload_file:
676-
print("%s failed: Unable to upload image to BMC" %
677-
data[1])
678-
continue
679-
680672
filename_w_ext = os.path.basename(fw_path)
681-
json_data = dict()
682-
json_data["image_path"] = "[email protected]:/home/root/%s" % filename_w_ext
683-
json_data["password"] = bmc_pwd
684-
json_data["device"] = "cpld"
685-
json_data["reboot"] = "no"
686-
json_data["type"] = fw_extra_str
687-
688-
# Call BMC api to install cpld image
673+
# Install cpld image via ispvm tool
689674
print("Installing...")
690-
r = requests.post(self.fw_upgrade_url, json=json_data)
691-
if r.status_code != 200:
692-
print("%s failed: BMC API report error code %d" %
693-
(data[1], r.status_code))
675+
command = 'ispvm %s' % fw_path
676+
if fw_extra_str in ["top_lc", "bottom_lc"]:
677+
option = 1 if fw_extra_str == "top_lc" else 2
678+
command = "ispvm -c %d %s" % (option,
679+
os.path.abspath(fw_path))
680+
print("Running command : %s" % command)
681+
process = subprocess.Popen(
682+
command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
683+
684+
while True:
685+
output = process.stdout.readline()
686+
if output == '' and process.poll() is not None:
687+
break
688+
689+
rc = process.returncode
690+
if rc != 0:
691+
print("Failed: Unable to install CPLD")
694692
continue
695693

696694
print("%s upgrade completed\n" % fw_extra_str)
@@ -720,11 +718,13 @@ def firmware_refresh(self, fpga_list, cpld_list, fw_extra=None):
720718
No operation if the power cycle is not needed.
721719
722720
Example:
723-
self.firmware_refresh(["FPGA"], ["BASE_CPLD", "LC_CPLD"],"/tmp/fw/refresh.vme")
721+
self.firmware_refresh(
722+
["FPGA"], ["BASE_CPLD", "LC_CPLD"],"/tmp/fw/refresh.vme")
724723
or
725724
self.firmware_refresh(["FPGA"], None, None)
726725
or
727-
self.firmware_refresh(None, ["FAN_CPLD", "LC1_CPLD", "BASE_CPLD"], "/tmp/fw/fan_refresh.vme:none:/tmp/fw/base_refresh.vme")
726+
self.firmware_refresh(None, ["FAN_CPLD", "LC1_CPLD", "BASE_CPLD"],
727+
"/tmp/fw/fan_refresh.vme:none:/tmp/fw/base_refresh.vme")
728728
"""
729729
upgrade_list = []
730730
if not fpga_list and not cpld_list:
@@ -772,6 +772,13 @@ def firmware_refresh(self, fpga_list, cpld_list, fw_extra=None):
772772
if r.status_code != 200:
773773
print("Failed: %d Unable to load new FPGA" % r.status_code)
774774
return False
775+
elif cpld_list:
776+
json_data = dict()
777+
json_data["data"] = "echo cpu_cpld > /tmp/cpld_refresh"
778+
r = requests.post(self.bmc_raw_command_url, json=json_data)
779+
if r.status_code != 200:
780+
print("Failed: %d Unable to load new CPLD" % r.status_code)
781+
return False
775782
else:
776783
print("Failed: Invalid input")
777784
return False

0 commit comments

Comments
 (0)