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 fwmgrutil to fixes bug #61

Merged
merged 3 commits into from Mar 18, 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
32 changes: 23 additions & 9 deletions device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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(
Expand All @@ -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:
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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"
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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(
Expand All @@ -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:
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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"
Expand All @@ -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()
Expand Down
32 changes: 23 additions & 9 deletions device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fwmgrutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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(
Expand All @@ -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:
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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"
Expand All @@ -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()
Expand Down