Commit ef78c7d
common: restapi : fix bug at endpoint /api/fw_versions
Summary:
# Description
- import and use Tuple insteads tuple in rest_fw_versions.py
- get `bash` real path insteads fixing in source code
# Motivation
Fix bug the restapi failed on start
```
root@bmc-oob:~# rest.py
Traceback (most recent call last):
File "/usr/local/bin/rest.py", line 38, in <module>
from setup_plat_routes import setup_plat_routes
File "/usr/local/fbpackages/rest-api/setup_plat_routes.py", line 23, in <module>
from board_setup_routes import setup_board_routes
File "/usr/local/fbpackages/rest-api/board_setup_routes.py", line 22, in <module>
from board_endpoint import boardApp_Handler
File "/usr/local/fbpackages/rest-api/board_endpoint.py", line 26, in <module>
import rest_fw_versions
File "/usr/local/fbpackages/rest-api/rest_fw_versions.py", line 50, in <module>
def _run_command(cmd: str) -> tuple[str, str]:
TypeError: 'type' object is not subscriptable
```
fix bug `/usr/local/bash` path not found
```
root@bmc-oob:~# curl http://localhost:8080/api/fw_versions | python -m json.tool
{
"Information": {
"firmware_versions": {
"bic": "",
"bios": "",
"fcm": "",
"fpga": "",
"pwr": "",
"scm": "",
"smb": ""
},
"firmware_string": "bic:,bios:,fcm:,fpga:,pwr:,scm:,smb:",
"firmware_hash": "369bbdb4c097",
"errors": {
"bic": "Command exception: /usr/bin/fw-util scm --version |grep Bri|grep -v Boot| cut -d ' ' -f 3 - FileNotFoundError(2, 'No such file or directory')",
"bios": "Command exception: /usr/bin/fw-util scm --version |grep BIOS| cut -d ' ' -f 3 - FileNotFoundError(2, 'No such file or directory')",
"fcm": "Command exception: /usr/local/bin/cpld_ver.sh |grep FCM|cut -d ' ' -f 2 - FileNotFoundError(2, 'No such file or directory')",
"fpga": "Command exception: /usr/local/bin/fpga_ver.sh |grep FPGA|head -1|cut -d ' ' -f 2 - FileNotFoundError(2, 'No such file or directory')",
"pwr": "Command exception: /usr/local/bin/cpld_ver.sh |grep PWR|cut -d ' ' -f 2 - FileNotFoundError(2, 'No such file or directory')",
"scm": "Command exception: /usr/local/bin/cpld_ver.sh |grep SCM|cut -d ' ' -f 2 - FileNotFoundError(2, 'No such file or directory')",
"smb": "Command exception: /usr/local/bin/cpld_ver.sh |grep SYSCPLD|cut -d ' ' -f 2 - FileNotFoundError(2, 'No such file or directory')"
}
},
"Actions": [],
"Resources": []
}
```
X-link: https://github.com/facebookexternal/openbmc.celestica/pull/1903
Test Plan:
Test on wedge400
```
root@bmc-oob:~# curl http://localhost:8080/api/sys
{"Information": {"Description": "Wedge System"}, "Actions": [], "Resources": ["bmc", "board_revision", "fc_present", "feutil", "firmware_info", "fscd_sensor_data", "gb_freq", "gpios", "mb", "modbus", "modbus_registers", "ntp", "optics_thermal", "presence", "psu_update", "sensors", "server", "seutil", "switch_reset", "vddcore"]}
```
```
root@bmc-oob:~# curl http://localhost:8080/api/fw_versions | python -m json.tool
{
"Information": {
"firmware_versions": {
"bic": "1.15",
"bios": "XG1_3A12",
"fcm": "4.2",
"fpga": "0.56",
"pwr": "2.4",
"scm": "4.0",
"smb": "2.5"
},
"firmware_string": "bic:1.15,bios:XG1_3A12,fcm:4.2,fpga:0.56,pwr:2.4,scm:4.0,smb:2.5",
"firmware_hash": "a45435f67303",
"errors": {}
},
"Actions": [],
"Resources": []
}
root@bmc-oob:~#
```
Reviewed By: binhuang00
Differential Revision: D90559411
Pulled By: ezeob002
fbshipit-source-id: faa33f2216446e5ed2708d65e23f78e62fc0df581 parent 5ba1f45 commit ef78c7d
1 file changed
+8
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | | - | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
| |||
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
50 | | - | |
| 52 | + | |
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| 57 | + | |
| 58 | + | |
55 | 59 | | |
56 | | - | |
| 60 | + | |
57 | 61 | | |
58 | 62 | | |
59 | 63 | | |
| |||
87 | 91 | | |
88 | 92 | | |
89 | 93 | | |
90 | | - | |
| 94 | + | |
91 | 95 | | |
92 | 96 | | |
93 | 97 | | |
| |||
0 commit comments