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 fishbone32 bmc upgrade api #186

Closed
wants to merge 1 commit into from
Closed
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
42 changes: 31 additions & 11 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 @@ -99,17 +99,26 @@ def get_bmc_version(self):
return str(bmc_version)

def upload_file_bmc(self, fw_path):
scp_command = 'sudo scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -r %s root@240.1.1.1:/home/root/' % os.path.abspath(
fw_path)
child = pexpect.spawn(scp_command)
i = child.expect(["root@240.1.1.1's password:"], timeout=30)
bmc_pwd = self.get_bmc_pass()
if i == 0 and bmc_pwd:
child.sendline(bmc_pwd)
data = child.read()
print(data)
child.close
return os.path.isfile(fw_path)
scp_command = 'sudo scp -o StrictHostKeyChecking=no -o ' \
'UserKnownHostsFile=/dev/null -r %s root@240.1.1.1:/home/root/' \
% os.path.abspath(fw_path)
for n in range(0,3):
child = pexpect.spawn(scp_command, timeout=120)
expect_list = [pexpect.EOF, pexpect.TIMEOUT, "'s password:"]
i = child.expect(expect_list, timeout=120)
bmc_pwd = self.get_bmc_pass()
if i == 2 and bmc_pwd != None:
child.sendline(bmc_pwd)
data = child.read()
child.close()
return os.path.isfile(fw_path)
elif i == 0:
print('upload done')
return True
else:
print "Failed to scp %s to BMC, index %d, retry %d" % (fw_path, i, n)
continue
print "Failed to scp %s to BMC, index %d" % (fw_path, i)
return False

def get_cpld_version(self):
Expand Down Expand Up @@ -272,6 +281,17 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None):
flash = "slave"
json_data["flash"] = flash

# umount /data/mnt
umount_json_data = dict()
umount_json_data["data"] = "pkill rsyslogd; umount -f /mnt/data/"
r = requests.post(self.bmc_raw_command_url, json=umount_json_data)
if r.status_code != 200:
self.__update_fw_upgrade_logger(
"bmc_upgrade", "fail, message=unable to umount /data/mnt")
self.__update_fw_upgrade_logger(
"last_upgrade_result", str(last_fw_upgrade))
return False

# Install BMC
if flash == "both":
self.__update_fw_upgrade_logger(
Expand Down