BMC REDFISH
发布日期:2022-02-26 14:49:42 浏览次数:35 分类:技术文章

本文共 5864 字,大约阅读时间需要 19 分钟。

Redfish

REDFISH UPDATE FIRMWARE

Author Date Version Comment
zhangjian38 2020-3-23 v0.1 Init version
zhangjian38 2020-3-26 v0.2

文章目录

1. Update SOP

More details please refer to MegaRAC Redfish - API Doc (v1.7)

1.1 Upload image file

    1. URI : https://$ip/redfish/v1/UpdateService/Actions/Oem/UpdateService.UploadFirmwareImage

    2. Method : POST

    3. Body : type form-data, value "Key":"image_file ", "Value":"<image_file_path>"

      Note : This method use local file, not include transfer by ftp or http server

1.2 Start Update

    1. URI : https://$ip/redfish/v1/UpdateService/Actions/Oem/UpdateService.BMCFwUpdate

    2. Method : POST

    3. Body : type JSON(application/json), value {"FlashType":"FULLFwUpdate","UploadSelector":"Default"}

      Note : The details about FlashType and UploadSelector Please refet to MegaRAC Redfish - API Doc (v1.7) 3.65.3.3

2. Key Code Flow

​ packages:

update_service_redfish_extension-src

libredfishflash-src

gami_bmc_update_module-src

2.1 Upload image file

  • URI Define File : update_service_redfish_extension-6.56.0.0.0-src/data/app/RTP_1_5/extensions/redfish-resource/updateservice/redfish-resource-URI_pattern.lua

    local URI_pattern = {	{ key = "updateservice_upload_action", pattern = "^" .. CONFIG.SERVICE_PREFIX .. "/UpdateService/(Actions)/(Oem)/(UpdateService.UploadFirmwareImage)$"},	...}
  • Handler Define File : update_service_redfish_extension-6.56.0.0.0-src/data/app/RTP_1_5/extensions/redfish-resource/updateservice/redfish-resource-handler.lua

    local UploadFileHandler = require("redfish.upload-file")...local handler_table = {	updateservice_upload_action = UploadFileHandler,...}
  • Handle Invoke :

    1. When Upload image file, UploadFileHandler:post will be invoked, in file upload-file.lua
    function UploadFileHandler:post(target, info, action)     ...end
    1. Judge that the URL parameter is valid ([There’s](javascript:😉 [nothing](javascript:😉 [to](javascript:😉 [say](javascript:😉 )

    2. Wirte image to /tmp/redfishfwupdate/rom.ima

      function UploadFileHandler:post(target, info, action)    ...	local redis = self:get_db()	local IsSignedImage = "Redfish:UpdateService:Oem:AMI:BMC:UploadedImageFormat"	if string.match(fname, '(.-%.ima_enc)$') then		coroutine.yield(redis:set(IsSignedImage, "signed"))	else		coroutine.yield(redis:set(IsSignedImage, "unsigned"))	end	local tmp_name = "/tmp/redfishfwupdate/"	local f = io.open(tmp_name .. "rom.ima", "w")	f:write(parsed_body)	f:close()	local fwupdate_in_progress = "Redfish:UpdateService:Oem:AMI:BMC:FWUpdateInProgress"	local image_path = tmp_name .. "rom.ima"	coroutine.yield(redis:set(fwupdate_in_progress, image_path))	...end

2.2 Start Update

  • **URI and Handler Define ** was same as 2.1 Upload image file

  • Handle Invoke :

    1. When start update, UpdateServiceHandler:post will be invoked, in file update-service.lua

      Note : This Handler Cotains simple update and ami oem update, Now ,I only focus on oem update

    function UpdateServiceHandler:post(target, info, action)...end
    1. Judge that the URL parameter is valid ([There’s](javascript:😉 [nothing](javascript:😉 [to](javascript:😉 [say](javascript:😉 )

    2. Invoke function flashBMC()

      a. Find Image File

      local imagefile=io.popen("ls /tmp/redfishfwupdate/")local uploadedimage=imagefile:read("*a")imagefile:close()if string.find(uploadedimage,"rom.ima") == nil then    self:error_action_requires_file()end

      b. Set update parameter .

      local FlashType = request_data.FlashTypelocal UploadSelector = request_data.UploadSelector

      c. Checking ActiveImage and InactivedImage

      d. Start update, create a file and set redis for update.

      os.execute("touch "..FLASHER_START_FILE)local redis_action_key = "POST:Redfish:UpdateService:OemAction:StartFwUpdate:BMC"						yield(redis:set(redis_action_key, turbo.escape.json_encode(request_data)))
    3. package : gami_bmc_update_module-src , FwUpdate.lua ,function FwUpdate.StartFwUpdate = function(group_name) will be invoked.

      TODO : I don’t know why and how this function will be invoked

      Note : Why this this function will be invoked, please refer to doc “REDIS 2 FUNCTION HANDLER

      FwUpdate.StartFwUpdate = function(group_name)    ... wRet = FwUpdate.UpdateFw_BMC(reqdata)    ...end

      In function UpdateFw_BMC

      a. Set to FlashMode

      libipmi_update.updateservice:set_flashmode()
      CALL LIB REDFISH FLASH(libredfishflash-src)

      **This lib will sending a command to `/var/pipe/flasher_cmd`**   ```lua  function updateservice:set_flashmode()  	os.execute("echo '0' > "..FLASHER_FLASHPercent_FILE)  	local dual_image_support = updateservice:checkDualImageSupport()  	local wRet = flashlibrary.PrepareFlashArea(FLSH_CMD_PREP_TFTP_FLASH_AREA, dual_image_support)  end  ```

      b. Download Image from Remote Path

      ```lua  wRet = libipmi_update.updateservice:download_image()  ```  Copy File to /mnt/fwupdate  	    ```lua  function updateservice:download_image()  os.execute("touch "..FLASHER_DOWNLOAD_FILE)  print("Uploading Image from /tmp/redfishfwupdate/ to /mnt/fwupdate/")  local cmd = "cp /tmp/redfishfwupdate/rom.ima /mnt/fwupdate/rom.ima"  local wRet = os.execute("echo '"..cmd.."'> /tmp/downloadimage_redfish.pid | "..cmd)  end  ```

      c. Verify Image, CALL LIB REDFISH FLASH

      ```lua  function updateservice:verifyimage_bmc(flashtype)  	  wRet = flashlibrary.VerifyFirmwareImage(VeriInfo[0], section_info[0], section_count)  end  ```

      d. Flash Image

      lua wRet = libipmi_update.updateservice:startflash_bmc(flashtype, parameter)

      CALL LIB REDFISH FLASH  LIB REDFISH FLASH Function `StartImageFlash`, send cmd to `"/var/pipe/flasher_cmd"`  ```c  int StartImageFlash (unsigned char PreserveCfg, unsigned char ResetBMC,unsigned char FlashType,void *SectionName,INT8U MaxSectionCount)  {  	FlasherCmd Cmd;  	Cmd.Command = REDFISH_FLASH_CMD_START_FLASH;  	SendCmdExpectNoReply(Cmd);  }  ```  Get Progress    ```lua  ProgressState = flashlibrary.GetFlashProgress(flprog)          local Progress = ffi.string(flprog.Progress, ffi.sizeof(flprog.Progress))       Progress = string.match(Progress, "(%d+)")  ```

转载地址:https://blog.csdn.net/qq_32030453/article/details/105221204 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Mysql安装——解压包直接安装
下一篇:Dubbo原理<一> Dubbo SPI详解

发表评论

最新留言

留言是一种美德,欢迎回访!
[***.207.175.100]2024年03月04日 02时01分50秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章

jquery查找div下第一个input_jquery查找div元素第一个元素id 2019-04-21
如何修改手机屏幕显示的长宽比例_屏幕分辨率 尺寸 比例 长宽 如何计算 2019-04-21
mysql 的版本 命名规则_MySQL版本和命名规则 2019-04-21
no java stack_Java Stack contains()用法及代码示例 2019-04-21
java动态代码_Java Agent入门学习之动态修改代码 2019-04-21
python集合如何去除重复数据_Python 迭代删除重复项,集合删除重复项 2019-04-21
iview 自定义时间选择器组件_Vue.js中使用iView日期选择器并设置开始时间结束时间校验功能... 2019-04-21
java 验证码校验_JavaWeb验证码校验功能代码实例 2019-04-21
java多线程初学者指南_Java多线程初学者指南(4):线程的生命周期 2019-04-21
java进程user是jenkins_java 学习:在java中启动其他应用,由jenkins想到的 2019-04-21
java添加资源文件_如何在eclipse中将资源文件夹添加到我的Java项目中 2019-04-21
java的三种修饰符_3分钟弄明白JAVA三大修饰符 2019-04-21
mysql source skip_redis mysql 中的跳表(skip list) 查找树(btree) 2019-04-21
java sun.org.mozilla_maven编译找不到符号 sun.org.mozilla.javascript.internal 2019-04-21
php curl 输出到文件,PHP 利用CURL(HTTP)实现服务器上传文件至另一服务器 2019-04-21
PHP字符串运算结果,PHP运算符(二)"字符串运算符"实例详解 2019-04-21
PHP实现 bcrypt,如何使php中的bcrypt和Java中的jbcrypt兼容 2019-04-21
php8安全,PHP八大安全函数解析 2019-04-21
php基础语法了解和熟悉的表现,PHP第二课 了解PHP的基本语法以及目录结构 2019-04-21
matlab中lag函数用法,MATLAB movavg函数用法 2019-04-21