bmc code update with automation/redfish
Hi George,
I’m testing BMC by automation with test_redfish_bmc_code_update.robot.
It failed. However I can successfully update bmc manually so I try to find the reason of failure.
When I upload image by REST:
1. -X POST -T <tar_file> https://${bmc}/upload/image
2. ls -l /tmp/images
drwx------ 2 root root 280 Jun 4 06:45 c78e674a
3. -X PUT -d '{"data": "xyz.openbmc_project.Software.Activation.RequestedActivations.Active"}' \
https://${bmc}/xyz/openbmc_project/software/c78e674a/attr/RequestedActivation
4. Then bmc untar the tar file to /run/initramfs/ and remove the tar file
ls -l /run/initramfs -rw-r--r-- 1 root root 4229844 Jun 4 06:46 image-kernel -rw-r--r-- 1 root root 23703552 Jun 4 06:46 image-rofs -rw-r--r-- 1 root root 850304 Jun 4 06:46 image-rwfs -rw-r--r-- 1 root root 433712 Jun 4 06:46 image-u-boot
When I upload image by Redfish (or automation):
1. -X POST -T <tar_file> https://${bmc}/redfish/v1/UpdateService
2. BMC immediately completes steps 2 to 4 above. So there’s no folder named “c78e674a” in /tmp/images. ls -l /run/initramfs
-rw-r--r-- 1 root root 4229844 Jun 4 06:53 image-kernel -rw-r--r-- 1 root root 23703552 Jun 4 06:53 image-rofs -rw-r--r-- 1 root root 850304 Jun 4 06:53 image-rwfs -rw-r--r-- 1 root root 433712 Jun 4 06:53 image-u-boot
3. Then robot try to “Get Latest Image ID” by command
cd /tmp/images/; stat -c '%Y %n' * | sort -k1,1nr | head -n 1 But the folder has been removed, so the robot finds nothing, and then fails.
Here’s the question:
It seems that the robot expects the folder "c78e674a" to exist.
However, when uploading an image through Redfish command, once the tar file is uploaded, bmc untar and remove it. How can I fix it? Do you have any suggestion?
Please leave any comments, thank you.
Regards,
David
From: "David Wang (王振宇)" <[email protected]>
To: George Keishing <[email protected]>
Cc: "[email protected]" <[email protected]>
Date: 04-06-2020 13:50
Subject: [EXTERNAL] bmc code update with automation/redfish
Sent by: "openbmc" <openbmc-bounces
[email protected]>
Hi George,
I’m testing BMC by automation with test_redfish_bmc_code_update.robot. It failed. However I can successfully update bmc manually so I try to find the reason of failure.
When I upload image by REST:
1. -X POST -T <tar_file>
https://urldefense.proofpoint.com/v2/url?u=https-3A__-24-257Bbmc-257D_upload_image&d=DwIGog&c=jf_iaSHvJObTbx-siA1ZOg&r=hHlxml_LX5HIffRsSFs-k3DrxQDKe6i0A3XGNW7rlIw&m=oA2ROoQqSxi2gl9jCiolEevjfNhPr_GsL2avNuL520U&s=m5vwcw9Q1ikZHMfIVxrZnwFWeeB9i8aIosAhpyEa_aw&e=
2. ls -l /tmp/images
drwx------ 2 root root 280 Jun 4 06:45c78e674a
3. -X PUT -d '{"data":
"xyz.openbmc_project.Software.Activation.RequestedActivations.Active"}' \
4. Then bmc untar the tar file to /run/initramfs/ and remove the tar file
ls -l /run/initramfs -rw-r--r-- 1 root root 4229844 Jun 4 06:46 image-kernel -rw-r--r-- 1 root root 23703552 Jun 4 06:46 image-rofs -rw-r--r-- 1 root root 850304 Jun 4 06:46 image-rwfs -rw-r--r-- 1 root root 433712 Jun 4 06:46
image-u-boot
When I upload image by Redfish (or automation):
1. -X POST -T <tar_file>
https://urldefense.proofpoint.com/v2/url?u=https-3A__-24-257Bbmc-257D_redfish_v1_UpdateService&d=DwIGog&c=jf_iaSHvJObTbx-siA1ZOg&r=hHlxml_LX5HIffRsSFs-k3DrxQDKe6i0A3XGNW7rlIw&m=oA2ROoQqSxi2gl9jCiolEevjfNhPr_GsL2avNuL520U&s=6bJfPi8T1M4BiUdFYJ280VZja0b_O4OxtUvUIFvfRaA&e=
2. BMC immediately completes steps 2 to 4 above. So there’s no folder named “c78e674a” in /tmp/images.
ls -l /run/initramfs
-rw-r--r-- 1 root root 4229844 Jun 4 06:53 image-kernel -rw-r--r-- 1 root root 23703552 Jun 4 06:53 image-rofs -rw-r--r-- 1 root root 850304 Jun 4 06:53 image-rwfs -rw-r--r-- 1 root root 433712 Jun 4 06:53 image-u-boot
3. Then robot try to “Get Latest Image ID” by command
cd /tmp/images/; stat -c '%Y %n' * | sort -k1,1nr | head -n 1 But the folder has been removed, so the robot finds nothing, and then fails.
Here’s the question:
It seems that the robot expects the folder "c78e674a" to exist. However, when uploading an image through Redfish command, once the tar file is uploaded, bmc untar and remove it.
How can I fix it? Do you have any suggestion?
Please leave any comments, thank you.
Regards,
David
-----------------------------------------------------------------------------------------------
Hi David,
You can refer this one openbmc-test-automation/redfish/extended/redfish_bmc_code_update.robot
Example:
robot -v OPENBMC_HOST:xx.xx.xx.xx -v
IMAGE_FILE_PATH=./obmc-phosphor-image-witherspoon-ubi.mtd.tar --include Redfish_BMC_Code_Update openbmc-test-automation/redfish/extended/redfish_bmc_code_update.robot
#(UTC) 2020/05/14 07:25:52.259475 - 0.835874 - Executing: patch
('/redfish/v1/UpdateService', body="{'HttpPushUriOptions' :
{'HttpPushUriApplyTime' : {'ApplyT...
#(UTC) 2020/05/14 07:25:52.315118 - 0.055644 - Executing: get
('/redfish/v1/UpdateService')
apply_time: None
#(UTC) 2020/05/14 07:26:13.643450 - 21.328331 - Issuing:
cd /tmp/images/; stat -c '%Y %n' * | sort -k1,1nr | head -n 1
#(UTC) 2020/05/14 07:26:18.806209 - 0.173404 - Issuing: ls
-l /tmp/images/d2dea46d/MANIFEST
image_id: d2dea46d
#(UTC) 2020/05/14 07:26:19.447311 - 0.112001 - Issuing:
cat /tmp/images/d2dea46d/MANIFEST
manifest:
purpose=xyz.openbmc_project.Software.Version.VersionPurpose.BMC version=2.8.0-dev-1823-gca64d2910
KeyType=OpenBMC
HashType=RSA-SHA256
MachineName=witherspoon
#(UTC) 2020/05/14 07:26:19.778033 - 0.017176 - Executing: get
('/redfish/v1/UpdateService/FirmwareInventory/d2dea46d') status:
[Health]: OK
[HealthRollup]: OK
[State]: UpdatingIf you wanted to do it manually, here are the steps for the above as well:
1. Get authorization token
$ curl -k -H "Content-Type: application/json" -X POST https://$ {bmc_ip}/login -d '{"username" : "root", "password" : "0penBmc"}' { "token": "3bpggDPS58SiUmWOUUC5" } $ export bmc_token=3bpggDPS58SiUmWOUUC5
2. Set the ApplyTime policy ( either one of them , by default OnReset )
OnReset - updates the image when BMC takes reset curl -k -H "X-Auth-Token: $bmc_token" -H "Content-Type:
application/octet-stream" -X PATCH -d '{ "HttpPushUriOptions":
{ "HttpPushUriApplyTime":{ "ApplyTime":"OnReset"}}}' https://$
{bmc_ip}/redfish/v1/UpdateService
Immediate - Trigger reboots BMC automatically when Activation is completed
curl -k -H "X-Auth-Token: $bmc_token" -H "Content-Type:
application/octet-stream" -X PATCH -d '{ "HttpPushUriOptions":
{ "HttpPushUriApplyTime":{ "ApplyTime":"Immediate"}}}' https://$
{bmc_ip}/redfish/v1/UpdateService
3. Upload and Activate:
curl -k -H "X-Auth-Token: $bmc_token" -H "Content-Type:
application/octet-stream" -X POST
-T ./Imagepath/obmc_withspoon.ubi.mtd.tar https://$
{bmc_ip}/redfish/v1/UpdateService
Thanks and Regards,
George Keishing
Hi George,
Thank you for the reply,
Quoted 9 lines
#(UTC) 2020/05/14 07:25:52.259475 - 0.835874 - Executing: patch('/redfish/v1/UpdateService', body="{'HttpPushUriOptions' : {'HttpPushUriApplyTime' : {'ApplyT... #(UTC) 2020/05/14 07:25:52.315118 - 0.055644 - Executing: get('/redfish/v1/UpdateService') apply_time: None #(UTC) 2020/05/14 07:26:13.643450 - 21.328331 - Issuing: cd
/tmp/images/; stat -c '%Y %n' * | sort -k1,1nr | head -n 1
I stuck in here, robot can't find anything in /tmp/images.
I've tracked the difference between the steps of Rest and Redfish. Rest upload the image and wait for another signal to active it,
while Redfish upload the image and active it at the same time. However robot is using redfish cmd.
See:
https://github.com/openbmc/docs/blob/master/code-update/code-update.md (step 2&4)
https://github.com/openbmc/docs/blob/master/designs/firmware-update-over-redfish.md#update-an-image
Step "active image" will copy 4 image files to /run/initramfs and delete the image folder /tmp/images/c78e674a before returning http response. And robot will check image's ID right after getting http response. But there's nothing in /tmp/images anymore, so it fail. The time sequence is as follows:
1.robot upload tar file by redfish command and BMC untar it in /tmp/images/c78e674a.
2.bmcweb active the image: BMC copy 4 image files to /run/initramfs and delete /tmp/images/c78e674a.
3.robot try to check image's id in /tmp/images/c78e674a but it no longer exists.
4.robot fail.
Based on the above, the robot seems to fail without a doubt. However the robot works for you.
What makes this different? Do I miss something? Does anyone have any ideas?
Any advice is welcome.
Thanks.
Quoted 12 lines
#(UTC) 2020/05/14 07:26:18.806209 - 0.173404 - Issuing: ls -l /tmp/images/d2dea46d/MANIFEST image_id: d2dea46d #(UTC) 2020/05/14 07:26:19.447311 - 0.112001 - Issuing: cat /tmp/images/d2dea46d/MANIFEST manifest: purpose=xyz.openbmc_project.Software.Version.VersionPurpose.BMC version=2.8.0-dev-1823-gca64d2910 KeyType=OpenBMC HashType=RSA-SHA256 MachineName=witherspoon #(UTC) 2020/05/14 07:26:19.778033 - 0.017176 - Executing:
Quoted 6 lines
get('/redfish/v1/UpdateService/FirmwareInventory/d2dea46d')
status:
[Health]: OK
[HealthRollup]: OK
[State]: Updating
Best regards,
David