bmc code update with automation/redfish

George Keishing gkeishin at in.ibm.com
Sat Jun 6 04:41:47 AEST 2020




From:	"David Wang (王振宇)" <DavidWang at quantatw.com>
To:	George Keishing <gkeishin at in.ibm.com>
Cc:	"openbmc at lists.ozlabs.org" <openbmc at lists.ozlabs.org>
Date:	04-06-2020 13:50
Subject:	[EXTERNAL] bmc code update with automation/redfish
Sent by:	"openbmc" <openbmc-bounces
            +gkeishin=in.ibm.com at lists.ozlabs.org>



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:45
c78e674a

3. -X PUT -d '{"data":
"xyz.openbmc_project.Software.Activation.RequestedActivations.Active"}' \

https://urldefense.proofpoint.com/v2/url?u=https-3A__-24-257Bbmc-257D_xyz_openbmc-5Fproject_software_c78e674a_attr_RequestedActivation&d=DwIGog&c=jf_iaSHvJObTbx-siA1ZOg&r=hHlxml_LX5HIffRsSFs-k3DrxQDKe6i0A3XGNW7rlIw&m=oA2ROoQqSxi2gl9jCiolEevjfNhPr_GsL2avNuL520U&s=5-X3Qdm9lMNmL46y23MtztPV92FYO9CtV0e3olmJr7U&e=


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]:                                        Updating


If 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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20200606/4cd38f30/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20200606/4cd38f30/attachment-0001.gif>


More information about the openbmc mailing list