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

server/2025/2/12 14:20:41/

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.ppmy.cn/server/167081.html

相关文章

后盾人JS -- 模块化开发

开发模块管理引擎 <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><meta name"viewport" content"widthdevice-width, initial-scale1.0"><title>Document</title> </he…

对接苹果ios退款接口-保姆级

前言&#xff1a; 1.吐槽&#xff1a;苹果退款很恶心&#xff0c;是它认为符合退款就直接给退了&#xff0c;没有国内店家审核阶段。会导致商户额外损失&#xff0c;所以有必要对用户发起的退款订单做及时响应。 2.尴尬&#xff1a;初次对接苹果相关业务&#xff0c;因为苹果不…

Deepseek本地部署:1.5B到671B,参数规模的秘密与设计逻辑

在人工智能领域&#xff0c;模型的参数规模是决定其能力的重要因素之一。Deepseek提供了从1.5B到671B不等的多种参数规模模型&#xff0c;供用户根据需求进行本地部署。那么&#xff0c;这些参数规模的区别是什么&#xff1f;为什么Deepseek选择这些特定的参数规模&#xff0c;…

后台管理系统网页开发

CSS样式代码 /* 后台管理系统样式文件 */ #container{ width:100%; height:100%; /* background-color:antiquewhite;*/ display:flex;} /* 左侧导航区域:宽度300px*/ .left{ width:300px; height: 100%; background-color:#203453; display:flex; flex-direction:column; jus…

性能优化中的系统架构优化

系统架构优化是性能优化的一个重要方面&#xff0c;它涉及到对整个IT系统或交易链上各个环节的分析与改进。通过系统架构优化&#xff0c;可以提高系统的响应速度、吞吐量&#xff0c;并降低各层之间的耦合度&#xff0c;从而更好地应对市场的变化和需求。业务增长导致的性能问…

0基础租个硬件玩deepseek,蓝耘元生代智算云|本地部署DeepSeek R1模型

前言&#xff1a;哈喽&#xff0c;大家好&#xff0c;今天给大家分享一篇文章&#xff01;并提供具体代码帮助大家深入理解&#xff0c;彻底掌握&#xff01;创作不易&#xff0c;如果能帮助到大家或者给大家一些灵感和启发&#xff0c;欢迎收藏关注哦 &#x1f495; 目录 0基础…

Spring Boot 和Tomcat的关系

Spring Boot 和 Tomcat 之间的关系可以从多个角度来详细阐述&#xff0c;包括它们的作用、工作原理以及如何协同工作。以下是详细的解析&#xff1a; 1. Spring Boot 的简介 Spring Boot 是一个基于 Spring 框架的开发工具&#xff0c;它的目标是简化 Spring 应用的开发。Spr…

Linux:ELF加载_动态库

hello&#xff0c;各位小伙伴&#xff0c;本篇文章跟大家一起学习《Linux&#xff1a;ELF加载_动态库_进程通信》&#xff0c;感谢大家对我上一篇的支持&#xff0c;如有什么问题&#xff0c;还请多多指教 &#xff01; 如果本篇文章对你有帮助&#xff0c;还请各位点点赞&…