From aa7197371d2ae87526bc154f120a0d9eb71dcafd Mon Sep 17 00:00:00 2001 From: Wirut Getbamrung Date: Mon, 18 Mar 2019 11:35:38 +0800 Subject: [PATCH 1/3] [device/ali] - Fix an error on fan cpld version monitoring --- .../alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py | 2 +- .../x86_64-alibaba_as13-48f8h-cl-r0/plugins/fwmgrutil.py | 2 +- .../alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fwmgrutil.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 08fe7364c702..a25a05b616e5 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) 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 1a88551da7dc..36945295679b 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) 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 98ca7d3550f7..39c3c08b0f97 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) From 026151e2579c5c9973eca2ec911583db4c5b1d35 Mon Sep 17 00:00:00 2001 From: Wirut Getbamrung Date: Mon, 18 Mar 2019 15:38:11 +0800 Subject: [PATCH 2/3] [device/alibaba] - Update bios method to avoid the reboot issue --- .../plugins/fwmgrutil.py | 27 ++++++++++++++----- .../plugins/fwmgrutil.py | 27 ++++++++++++++----- .../plugins/fwmgrutil.py | 27 ++++++++++++++----- 3 files changed, 60 insertions(+), 21 deletions(-) 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 a25a05b616e5..8fe771ac8275 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 @@ -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: @@ -395,6 +398,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 +407,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 36945295679b..d600f2fb912c 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 @@ -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: @@ -395,6 +398,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 +407,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 39c3c08b0f97..cb7af8f95154 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 @@ -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: @@ -395,6 +398,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 +407,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() From eb5cb570a1c4cffa80f6d4649c92f1ac8a4aa329 Mon Sep 17 00:00:00 2001 From: Wirut Getbamrung Date: Mon, 18 Mar 2019 15:42:35 +0800 Subject: [PATCH 3/3] [device/alibaba] - Add more switch cpld upgrade type --- .../alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py | 3 ++- .../x86_64-alibaba_as13-48f8h-cl-r0/plugins/fwmgrutil.py | 3 ++- .../x86_64-alibaba_as23-128h-cl-r0/plugins/fwmgrutil.py | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) 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 8fe771ac8275..8dab27f9cfe8 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 @@ -332,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) 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 d600f2fb912c..a41babcac039 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 @@ -332,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) 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 cb7af8f95154..89238886b61a 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 @@ -332,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)