当前位置: 首页 > news >正文

openbmc web/redfish到底层设计(持续更新...)

1.说明

本节是厘清openbmc的界面层web或者redfish到底层数据获取与展示。

不可或缺的是先阅读官方关于redfish的设计文档:

  • 1.https://github.com/openbmc/docs/blob/master/designs/redfish-authorization.md
  • 2.https://github.com/openbmc/docs/blob/master/designs/redfish-postcodes.md
  • 3.https://github.com/openbmc/docs/blob/master/development/web-ui.md

需要注意的是,官方的文档一定要细读与分析背后的设计。

2.代码简单流程分析

2.1 大致总体流程

代码包包含webredfish,均在bmcweb中,可以使用如下命令抽取代码:

# devtool modify bmcweb

调用关系如下:

(bmcweb/src/webserver_main.cpp)
int main(int /*argc*/, char** /*argv*/) noexcept(false)
---> run()  (bmcweb/src/webserver_run.cpp)---> server.add_interface("/xyz/openbmc_project/bmcweb","xyz.openbmc_project.bmcweb");---> if constexpr (BMCWEB_REDFISH)---> redfish::RedfishService redfish(app);---> redfish::EventServiceManager::getInstance(&*io);---> crow::login_routes::requestRoutes(app);---> app.run();---> systemBus->request_name("xyz.openbmc_project.bmcweb");---> io->run();

redfish()定义在文件bmcweb/redfish-core/src/redfish.cpp中,关系如下:

RedfishService::RedfishService(App& app)
---> requestRoutesMetadata(app);
---> requestRoutesOdata(app);
---> requestAccountServiceRoutes(app);
---> requestRoutesRoles(app);
---> ...
---> requestRoutesManager(app);
---> ...
---> requestRoutesSystemsLogServicesPostCode(app);
---> ...
---> requestRoutesRedfish(app);

因此,如果需要添加自己的redfish功能,可以在这里添加顶层函数功能。

拿一个函数调用:requestRoutesManager(app)举例:

(bmcweb/redfish-core/lib/managers.hpp)
inline void requestRoutesManager(App& app)
---> BMCWEB_ROUTE(app, "/redfish/v1/Managers/<str>/")...

调用返回数据。

2.2 webredfish结合

openbmcwebredfish怎么结合去服务用户呢?

web理解就是前端展现给用户的网页,redfish其实是与web进行沟通,所以openbmc设计理念是redfish(bmcweb)作为后台与web(web-vue)作为前端搭配起来使用的。

顺便提一下,openbmc是使用nghttp2作为web server的。

举一个简单例子,在前端js中获取数据:

async getChassisCollection() {
--->  ...
---> .get('/redfish/v1/Chassis')
2.3 针对官方文档,简单分析一个例子

这一部分针对官方文档的内容,看一下例子。

官方文档如下:

  • https://github.com/openbmc/docs/blob/master/designs/redfish-postcodes.md

该文档说的bios postcode的事情,可以找到代码位置:

bmcweb/redfish-core/lib/systems_logservices_postcodes.hpp
bmcweb/redfish-core/src/redfish.cpp

在文件bmcweb/redfish-core/src/redfish.cpp中调用函数requestRoutesSystemsLogServicesPostCode(),在文件bmcweb/redfish-core/lib/systems_logservices_postcodes.hpp中定义了函数:requestRoutesSystemsLogServicesPostCode():

inline void requestRoutesSystemsLogServicesPostCode(App& app)
---> BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/LogServices/PostCodes/")...
---> BMCWEB_ROUTE(app,"/redfish/v1/Systems/<str>/LogServices/PostCodes/Actions/LogService.ClearLog/")
---> BMCWEB_ROUTE(app,"/redfish/v1/Systems/<str>/LogServices/PostCodes/Entries/")
---> BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/LogServices/PostCodes/Entries/<str>/")
---> BMCWEB_ROUTE(app,"/redfish/v1/Systems/<str>/LogServices/PostCodes/Entries/<str>/attachment/")

比较关心的是对于设置操作如何处理。可以看到,调用的是函数handleSystemsLogServicesPostCodesPost():

inline void handleSystemsLogServicesPostCodesPost()
---> crow::connections::systemBus->async_method_call(..,"xyz.openbmc_project.State.Boot.PostCode0",
"/xyz/openbmc_project/State/Boot/PostCode0",
"xyz.openbmc_project.Collection.DeleteAll", 
"DeleteAll");

因此,采取的就是一种函数调用的办法去处理的。

2.4 web获取后台数据的例子

这一节借一个web例子,可以看到web和后台是怎么交互的。

例如,在web下可以看到如下内容:

在这里插入图片描述
因此,明显看到后台以(redfish)json数据呈现给webweb解析即可。

http://www.lryc.cn/news/534269.html

相关文章:

  • Linux init
  • Maven 版本管理与 SNAPSHOT 详解
  • TCP三次握手全方面详解
  • 【C#】一维、二维、三维数组的使用
  • MIT开源7B推理模型Satori:用行动思维链进行强化学习,增强自回归搜索
  • 【JVM详解二】常量池
  • w200基于spring boot的个人博客系统的设计与实现
  • 【算法】快速排序算法的实现:C 和 C++ 版本
  • 前沿科技一览未来发展趋势
  • js滚动到页面最底部
  • 视觉硬件选型和算法选择(CNN)
  • Mybatis篇
  • 【Python】元组
  • 【AI实践】deepseek支持升级git
  • 【AI实践】Cursor上手-跑通Hello World和时间管理功能
  • Redis数据库(二):Redis 常用的五种数据结构
  • 【计组】实验五 J型指令设计实验
  • ubuntu 本地部署deepseek r1 蒸馏模型
  • RestTemplate Https 证书访问错误
  • MySQL内存使用率高且不释放问题排查与总结
  • mysql8 从C++源码角度看sql生成抽象语法树
  • 【DeepSeek】DeepSeek概述 | 本地部署deepseek
  • 【C++】多态原理剖析
  • 【Rust自学】20.4. 结语:Rust学习一阶段完成+附录
  • pytorch引用halcon写数据集
  • 让文物“活”起来,以3D数字化技术传承文物历史文化!
  • aarch64 Ubuntu20.04 安装docker
  • JAVA:CloseableHttpClient 进行 HTTP 请求的技术指南
  • Mac上搭建k8s环境——Minikube
  • 经典排序算法复习----C语言