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 multiple cpld firmware upgrade and bug fix #58

Merged
merged 3 commits into from Mar 9, 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
1 change: 1 addition & 0 deletions device/alibaba/x86_64-alibaba_as13-32h-cl-r0/default_sku
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AS13-32H t1
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
CONSOLE_SPEED=9600
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="processor.max_cstate=1 intel_idle.max_cstate=0"
145 changes: 92 additions & 53 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 @@ -95,9 +95,22 @@ def get_bmc_version(self):
bmc_info_json = bmc_info_req.json()
bmc_info = bmc_info_json.get('Information')
bmc_version = bmc_info.get(bmc_version_key)

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)
if i == 0:
bmc_pwd = self.get_bmc_pass()
child.sendline(bmc_pwd)
data = child.read()
print(data)
child.close
return True
return False

def get_cpld_version(self):
"""Get CPLD version from SONiC
:returns: dict like {'CPLD_1': version_string, 'CPLD_2': version_string}
Expand Down Expand Up @@ -223,22 +236,14 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None):
or 'cpld_fan_come_board', etc. If None, upgrade all CPLD/FPGA firmware. for fw_type 'bios' and 'bmc',
value should be one of 'master' or 'slave' or 'both'
"""

bmc_pwd = self.get_bmc_pass()
if fw_type == 'bmc':
# Copy BMC image file to BMC
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)
if i == 0:
print("Uploading image to BMC...")
print("Running command : ", scp_command)

bmc_pwd = self.get_bmc_pass()
child.sendline(bmc_pwd)
data = child.read()
print(data)
child.close
print("Uploading image to BMC...")
upload_file = self.upload_file_bmc(fw_path)
if not upload_file:
print("Failed")
return False

filename_w_ext = os.path.basename(fw_path)
json_data = dict()
Expand Down Expand Up @@ -296,53 +301,88 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None):
return False

elif 'cpld' in fw_type:
# Check input
fw_extra_str = str(fw_extra).upper()
fw_extra_str = {
"TOP_LC_CPLD": "top_lc",
"BOT_LC_CPLD": "bot_lc",
"FAN_CPLD": "fan",
"CPU_CPLD": "cpu",
"BASE_CPLD": "base",
"COMBO_CPLD": "combo",
"SW_CPLD": "switch"
}.get(fw_extra_str, None)

if fw_extra_str is None:
print("Failed: Invalid extra information string")
if ":" in fw_path and ":" in fw_extra_str:
fw_path_list = fw_path.split(":")
fw_extra_str_list = fw_extra_str.split(":")
else:
fw_path_list = [fw_path]
fw_extra_str_list = [fw_extra_str]

if len(fw_path_list) != len(fw_extra_str_list):
print("Failed: Invalid input")
return False

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)
if i == 0:
data_list = list(zip(fw_path_list, fw_extra_str_list))
for data in data_list:
fw_path = data[0]
fw_extra_str = data[1]

# Set fw_extra
fw_extra_str = {
"TOP_LC_CPLD": "top_lc",
"BOT_LC_CPLD": "bot_lc",
"FAN_CPLD": "fan",
"CPU_CPLD": "cpu",
"BASE_CPLD": "base",
"COMBO_CPLD": "combo",
"SW_CPLD": "switch"
}.get(fw_extra_str, None)

if fw_extra_str is None:
print("Failed: Invalid extra information string")
return False

# Uploading image to BMC
print("Uploading image to BMC...")
print("Running command : ", scp_command)
bmc_pwd = self.get_bmc_pass()
child.sendline(bmc_pwd)
data = child.read()
print(data)
child.close
upload_file = self.upload_file_bmc(fw_path)
if not upload_file:
print("Failed: Unable to upload image to BMC")
return False

filename_w_ext = os.path.basename(fw_path)
json_data = dict()
json_data["image_path"] = "root@127.0.0.1:/home/root/%s" % filename_w_ext
json_data["password"] = bmc_pwd
json_data["device"] = "cpld"
json_data["reboot"] = "no"
json_data["type"] = fw_extra_str
filename_w_ext = os.path.basename(fw_path)
json_data = dict()
json_data["image_path"] = "root@127.0.0.1:/home/root/%s" % filename_w_ext
json_data["password"] = bmc_pwd
json_data["device"] = "cpld"
json_data["reboot"] = "no"
json_data["type"] = fw_extra_str

print("Installing CPLD type :", fw_extra_str)
r = requests.post(self.fw_upgrade_url, json=json_data)
if r.status_code != 200 or 'success' not in r.json().get('result'):
print("Failed")
return False
# Call BMC api to install cpld image
print("Installing CPLD type :", fw_extra_str)
r = requests.post(self.fw_upgrade_url, json=json_data)
if r.status_code != 200 or 'success' not in r.json().get('result'):
print("Failed: Invalid cpld image")
return False

print(fw_extra_str, "Done")

if fw_extra_str == "combo":
# Refresh CPLD
if "COMBO_CPLD" in fw_extra_str_list or "BASE_CPLD" in fw_extra_str_list or "CPU_CPLD" in fw_extra_str_list:
print(fw_extra_str, "Refreshing CPLD...")
dir_name = os.path.dirname(fw_path)
file_list = [i for i in os.listdir(
dir_name) if i.lower().endswith("_onlyrefresh.vme")]

if len(file_list) < 1:
print("Failed: Refresh image not found")
return False

fw_path = os.path.join(dir_name, file_list[0])
upload_file = self.upload_file_bmc(fw_path)
if not upload_file:
print("Failed: Unable to upload refresh image to BMC")
return False

json_data = dict()
json_data["image_path"] = "root@127.0.0.1:/home/root/%s" % file_list[0]
json_data["password"] = bmc_pwd
json_data["device"] = "cpld"
json_data["type"] = "enable"
r = requests.post(self.fw_upgrade_url, json=json_data)
if r.status_code != 200 or 'success' not in r.json().get('result'):
print("Failed")
print("Failed: Invalid refresh image")
return False

print("Done")
Expand All @@ -360,7 +400,6 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None):
if i == 0:
print("Uploading image to BMC...")
print("Running command : ", scp_command)
bmc_pwd = self.get_bmc_pass()
child.sendline(bmc_pwd)
data = child.read()
print(data)
Expand Down
1 change: 1 addition & 0 deletions device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/default_sku
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AS13-48F8H t1
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
CONSOLE_SPEED=9600
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="processor.max_cstate=1 intel_idle.max_cstate=0"
145 changes: 92 additions & 53 deletions device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/fwmgrutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,22 @@ def get_bmc_version(self):
bmc_info_json = bmc_info_req.json()
bmc_info = bmc_info_json.get('Information')
bmc_version = bmc_info.get(bmc_version_key)

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)
if i == 0:
bmc_pwd = self.get_bmc_pass()
child.sendline(bmc_pwd)
data = child.read()
print(data)
child.close
return True
return False

def get_cpld_version(self):
"""Get CPLD version from SONiC
:returns: dict like {'CPLD_1': version_string, 'CPLD_2': version_string}
Expand Down Expand Up @@ -223,22 +236,14 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None):
or 'cpld_fan_come_board', etc. If None, upgrade all CPLD/FPGA firmware. for fw_type 'bios' and 'bmc',
value should be one of 'master' or 'slave' or 'both'
"""

bmc_pwd = self.get_bmc_pass()
if fw_type == 'bmc':
# Copy BMC image file to BMC
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)
if i == 0:
print("Uploading image to BMC...")
print("Running command : ", scp_command)

bmc_pwd = self.get_bmc_pass()
child.sendline(bmc_pwd)
data = child.read()
print(data)
child.close
print("Uploading image to BMC...")
upload_file = self.upload_file_bmc(fw_path)
if not upload_file:
print("Failed")
return False

filename_w_ext = os.path.basename(fw_path)
json_data = dict()
Expand Down Expand Up @@ -296,53 +301,88 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None):
return False

elif 'cpld' in fw_type:
# Check input
fw_extra_str = str(fw_extra).upper()
fw_extra_str = {
"TOP_LC_CPLD": "top_lc",
"BOT_LC_CPLD": "bot_lc",
"FAN_CPLD": "fan",
"CPU_CPLD": "cpu",
"BASE_CPLD": "base",
"COMBO_CPLD": "combo",
"SW_CPLD": "switch"
}.get(fw_extra_str, None)

if fw_extra_str is None:
print("Failed: Invalid extra information string")
if ":" in fw_path and ":" in fw_extra_str:
fw_path_list = fw_path.split(":")
fw_extra_str_list = fw_extra_str.split(":")
else:
fw_path_list = [fw_path]
fw_extra_str_list = [fw_extra_str]

if len(fw_path_list) != len(fw_extra_str_list):
print("Failed: Invalid input")
return False

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)
if i == 0:
data_list = list(zip(fw_path_list, fw_extra_str_list))
for data in data_list:
fw_path = data[0]
fw_extra_str = data[1]

# Set fw_extra
fw_extra_str = {
"TOP_LC_CPLD": "top_lc",
"BOT_LC_CPLD": "bot_lc",
"FAN_CPLD": "fan",
"CPU_CPLD": "cpu",
"BASE_CPLD": "base",
"COMBO_CPLD": "combo",
"SW_CPLD": "switch"
}.get(fw_extra_str, None)

if fw_extra_str is None:
print("Failed: Invalid extra information string")
return False

# Uploading image to BMC
print("Uploading image to BMC...")
print("Running command : ", scp_command)
bmc_pwd = self.get_bmc_pass()
child.sendline(bmc_pwd)
data = child.read()
print(data)
child.close
upload_file = self.upload_file_bmc(fw_path)
if not upload_file:
print("Failed: Unable to upload image to BMC")
return False

filename_w_ext = os.path.basename(fw_path)
json_data = dict()
json_data["image_path"] = "root@127.0.0.1:/home/root/%s" % filename_w_ext
json_data["password"] = bmc_pwd
json_data["device"] = "cpld"
json_data["reboot"] = "no"
json_data["type"] = fw_extra_str
filename_w_ext = os.path.basename(fw_path)
json_data = dict()
json_data["image_path"] = "root@127.0.0.1:/home/root/%s" % filename_w_ext
json_data["password"] = bmc_pwd
json_data["device"] = "cpld"
json_data["reboot"] = "no"
json_data["type"] = fw_extra_str

print("Installing CPLD type :", fw_extra_str)
r = requests.post(self.fw_upgrade_url, json=json_data)
if r.status_code != 200 or 'success' not in r.json().get('result'):
print("Failed")
return False
# Call BMC api to install cpld image
print("Installing CPLD type :", fw_extra_str)
r = requests.post(self.fw_upgrade_url, json=json_data)
if r.status_code != 200 or 'success' not in r.json().get('result'):
print("Failed: Invalid cpld image")
return False

print(fw_extra_str, "Done")

if fw_extra_str == "combo":
# Refresh CPLD
if "COMBO_CPLD" in fw_extra_str_list or "BASE_CPLD" in fw_extra_str_list or "CPU_CPLD" in fw_extra_str_list:
print(fw_extra_str, "Refreshing CPLD...")
dir_name = os.path.dirname(fw_path)
file_list = [i for i in os.listdir(
dir_name) if i.lower().endswith("_onlyrefresh.vme")]

if len(file_list) < 1:
print("Failed: Refresh image not found")
return False

fw_path = os.path.join(dir_name, file_list[0])
upload_file = self.upload_file_bmc(fw_path)
if not upload_file:
print("Failed: Unable to upload refresh image to BMC")
return False

json_data = dict()
json_data["image_path"] = "root@127.0.0.1:/home/root/%s" % file_list[0]
json_data["password"] = bmc_pwd
json_data["device"] = "cpld"
json_data["type"] = "enable"
r = requests.post(self.fw_upgrade_url, json=json_data)
if r.status_code != 200 or 'success' not in r.json().get('result'):
print("Failed")
print("Failed: Invalid refresh image")
return False

print("Done")
Expand All @@ -360,7 +400,6 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None):
if i == 0:
print("Uploading image to BMC...")
print("Running command : ", scp_command)
bmc_pwd = self.get_bmc_pass()
child.sendline(bmc_pwd)
data = child.read()
print(data)
Expand Down
1 change: 1 addition & 0 deletions device/alibaba/x86_64-alibaba_as23-128h-cl-r0/default_sku
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AS23-128H t1
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
CONSOLE_SPEED=9600
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="processor.max_cstate=1 intel_idle.max_cstate=0"
Loading