diff --git a/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py b/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py index 08fe7364c70..8dab27f9cfe 100644 --- a/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py +++ b/device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py @@ -127,7 +127,7 @@ def get_cpld_version(self): fan_cpld_key = "FanCPLD Version" fan_cpld = None bmc_info_req = requests.get(self.bmc_info_url) - if bmc_info_req == 200: + if bmc_info_req.status_code == 200: bmc_info_json = bmc_info_req.json() bmc_info = bmc_info_json.get('Information') fan_cpld = bmc_info.get(fan_cpld_key) @@ -240,6 +240,7 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None): bmc_pwd = self.get_bmc_pass() if fw_type == 'bmc': # Copy BMC image file to BMC + print("BMC Upgrade") print("Uploading image to BMC...") upload_file = self.upload_file_bmc(fw_path) if not upload_file: @@ -279,6 +280,7 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None): return False elif fw_type == 'fpga': + print("FPGA Upgrade") command = 'fpga_prog ' + fw_path print("Running command : ", command) process = subprocess.Popen( @@ -302,6 +304,7 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None): return False elif 'cpld' in fw_type: + print("CPLD Upgrade") # Check input fw_extra_str = str(fw_extra).upper() if ":" in fw_path and ":" in fw_extra_str: @@ -329,7 +332,8 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None): "CPU_CPLD": "cpu", "BASE_CPLD": "base", "COMBO_CPLD": "combo", - "SW_CPLD": "switch", + "SW_CPLD1": "switch", + "SW_CPLD2": "switch", "REFRESH_CPLD": "refresh" }.get(fw_extra_str, None) @@ -395,6 +399,7 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None): return True elif 'bios' in fw_type: + print("BIOS Upgrade") fw_extra_str = str(fw_extra).lower() flash = fw_extra_str if fw_extra_str in [ "master", "slave"] else "master" @@ -403,13 +408,22 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None): fw_path) child = pexpect.spawn(scp_command) i = child.expect(["root@240.1.1.1's password:"], timeout=30) - if i == 0: - print("Uploading image to BMC...") - print("Running command : ", scp_command) - child.sendline(bmc_pwd) - data = child.read() - print(data) - child.close + if i != 0: + print("Failed: Unable to connect to BMC") + return False + + print("Uploading image to BMC...") + child.sendline(bmc_pwd) + data = child.read() + print(data) + child.close + + json_data = dict() + json_data["data"] = "/usr/bin/ipmitool -b 1 -t 0x2c raw 0x2e 0xdf 0x57 0x01 0x00 0x01" + r = requests.post(self.bmc_raw_command_url, json=json_data) + if r.status_code != 200: + print("Failed") + return False filename_w_ext = os.path.basename(fw_path) json_data = dict() diff --git a/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fwmgrutil.py b/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fwmgrutil.py index 1a88551da7d..a41babcac03 100644 --- a/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fwmgrutil.py +++ b/device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fwmgrutil.py @@ -127,7 +127,7 @@ def get_cpld_version(self): fan_cpld_key = "FanCPLD Version" fan_cpld = None bmc_info_req = requests.get(self.bmc_info_url) - if bmc_info_req == 200: + if bmc_info_req.status_code == 200: bmc_info_json = bmc_info_req.json() bmc_info = bmc_info_json.get('Information') fan_cpld = bmc_info.get(fan_cpld_key) @@ -240,6 +240,7 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None): bmc_pwd = self.get_bmc_pass() if fw_type == 'bmc': # Copy BMC image file to BMC + print("BMC Upgrade") print("Uploading image to BMC...") upload_file = self.upload_file_bmc(fw_path) if not upload_file: @@ -279,6 +280,7 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None): return False elif fw_type == 'fpga': + print("FPGA Upgrade") command = 'fpga_prog ' + fw_path print("Running command : ", command) process = subprocess.Popen( @@ -302,6 +304,7 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None): return False elif 'cpld' in fw_type: + print("CPLD Upgrade") # Check input fw_extra_str = str(fw_extra).upper() if ":" in fw_path and ":" in fw_extra_str: @@ -329,7 +332,8 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None): "CPU_CPLD": "cpu", "BASE_CPLD": "base", "COMBO_CPLD": "combo", - "SW_CPLD": "switch", + "SW_CPLD1": "switch", + "SW_CPLD2": "switch", "REFRESH_CPLD": "refresh" }.get(fw_extra_str, None) @@ -395,6 +399,7 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None): return True elif 'bios' in fw_type: + print("BIOS Upgrade") fw_extra_str = str(fw_extra).lower() flash = fw_extra_str if fw_extra_str in [ "master", "slave"] else "master" @@ -403,13 +408,22 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None): fw_path) child = pexpect.spawn(scp_command) i = child.expect(["root@240.1.1.1's password:"], timeout=30) - if i == 0: - print("Uploading image to BMC...") - print("Running command : ", scp_command) - child.sendline(bmc_pwd) - data = child.read() - print(data) - child.close + if i != 0: + print("Failed: Unable to connect to BMC") + return False + + print("Uploading image to BMC...") + child.sendline(bmc_pwd) + data = child.read() + print(data) + child.close + + json_data = dict() + json_data["data"] = "/usr/bin/ipmitool -b 1 -t 0x2c raw 0x2e 0xdf 0x57 0x01 0x00 0x01" + r = requests.post(self.bmc_raw_command_url, json=json_data) + if r.status_code != 200: + print("Failed") + return False filename_w_ext = os.path.basename(fw_path) json_data = dict() diff --git a/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fwmgrutil.py b/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fwmgrutil.py index 98ca7d3550f..89238886b61 100644 --- a/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fwmgrutil.py +++ b/device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fwmgrutil.py @@ -127,7 +127,7 @@ def get_cpld_version(self): fan_cpld_key = "FanCPLD Version" fan_cpld = None bmc_info_req = requests.get(self.bmc_info_url) - if bmc_info_req == 200: + if bmc_info_req.status_code == 200: bmc_info_json = bmc_info_req.json() bmc_info = bmc_info_json.get('Information') fan_cpld = bmc_info.get(fan_cpld_key) @@ -240,6 +240,7 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None): bmc_pwd = self.get_bmc_pass() if fw_type == 'bmc': # Copy BMC image file to BMC + print("BMC Upgrade") print("Uploading image to BMC...") upload_file = self.upload_file_bmc(fw_path) if not upload_file: @@ -279,6 +280,7 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None): return False elif fw_type == 'fpga': + print("FPGA Upgrade") command = 'fpga_prog ' + fw_path print("Running command : ", command) process = subprocess.Popen( @@ -302,6 +304,7 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None): return False elif 'cpld' in fw_type: + print("CPLD Upgrade") # Check input fw_extra_str = str(fw_extra).upper() if ":" in fw_path and ":" in fw_extra_str: @@ -329,7 +332,8 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None): "CPU_CPLD": "cpu", "BASE_CPLD": "base", "COMBO_CPLD": "combo", - "SW_CPLD": "switch", + "SW_CPLD1": "switch", + "SW_CPLD2": "switch", "REFRESH_CPLD": "refresh" }.get(fw_extra_str, None) @@ -395,6 +399,7 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None): return True elif 'bios' in fw_type: + print("BIOS Upgrade") fw_extra_str = str(fw_extra).lower() flash = fw_extra_str if fw_extra_str in [ "master", "slave"] else "master" @@ -403,13 +408,22 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None): fw_path) child = pexpect.spawn(scp_command) i = child.expect(["root@240.1.1.1's password:"], timeout=30) - if i == 0: - print("Uploading image to BMC...") - print("Running command : ", scp_command) - child.sendline(bmc_pwd) - data = child.read() - print(data) - child.close + if i != 0: + print("Failed: Unable to connect to BMC") + return False + + print("Uploading image to BMC...") + child.sendline(bmc_pwd) + data = child.read() + print(data) + child.close + + json_data = dict() + json_data["data"] = "/usr/bin/ipmitool -b 1 -t 0x2c raw 0x2e 0xdf 0x57 0x01 0x00 0x01" + r = requests.post(self.bmc_raw_command_url, json=json_data) + if r.status_code != 200: + print("Failed") + return False filename_w_ext = os.path.basename(fw_path) json_data = dict()