add a redfish schema
add a redfish schema
在redfish中添加自己的schema xml文件,需要以下幾步:
1. 在py腳本中添加code
在python腳本中添加以下代碼。在工具去驗(yàn)證schema的時(shí)候可以把文件從bmc下載到pc。
# build\workspace\sources\bmcweb\scripts\update_schemas.py metadata_index.write(" <edmx:Reference Uri=\"/redfish/v1/schema/OemService_v1.xml\">\n")metadata_index.write(" <edmx:Include Namespace=\"OemService\"/>\n")metadata_index.write(" <edmx:Include Namespace=\"OemService.v1_0_0\"/>\n")metadata_index.write(" </edmx:Reference>\n")2. 在index中添加code
這里相當(dāng)于添加頭文件,指定文件,指定namespace。
build\workspace\sources\bmcweb\static\redfish\v1\$metadata\index.xml<edmx:Reference Uri="/redfish/v1/schema/OemService_v1.xml"><edmx:Include Namespace="OemService"/><edmx:Include Namespace="OemService.v1_0_0"/></edmx:Reference>3. 添加xml文件
把自己的文件添加進(jìn)來,注意其中的namespace等
build\workspace\sources\bmcweb\static\redfish\v1\schema\OemService_v1.xml<?xml version="1.0" encoding="UTF-8"?> <edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0"><edmx:Reference Uri="Org.OData.Core.V1.xml"><edmx:Include Namespace="Org.OData.Core.V1" Alias="OData"/></edmx:Reference><edmx:Reference Uri="Org.OData.Measures.V1.xml"><edmx:Include Namespace="Org.OData.Measures.V1" Alias="Measures"/></edmx:Reference><edmx:Reference Uri="RedfishExtensions_v1.xml"><edmx:Include Namespace="RedfishExtensions.v1_0_0" Alias="Redfish"/><edmx:Include Namespace="Validation.v1_0_0" Alias="Validation"/></edmx:Reference><edmx:Reference Uri="Resource_v1.xml"><edmx:Include Namespace="Resource"/><edmx:Include Namespace="Resource.v1_0_0"/></edmx:Reference><!--# Include schemas for referred resources--><edmx:Reference Uri="http://redfish.dmtf.org/schemas/v1/SoftwareInventory_v1.xml"><edmx:Include Namespace="SoftwareInventory"/><edmx:Include Namespace="SoftwareInventory.v1_0_0"/><edmx:Include Namespace="SoftwareInventory.v1_1_0"/></edmx:Reference><edmx:DataServices><Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="OemService"><ComplexType Name="SoftwareInventory" Type="OemService.SoftwareInventory"><Property Name="LastUpdateTime" Type="Edm.String"/><Property Name="UpdateState" Type="Edm.String"><Annotation Term="OData.Description" String="This indicates the software update state"/><Annotation Term="OData.LongDescription" String="This indicates the software update state of the software inventory resource."/></Property><Property Name="Status" Type="Edm.String"><Annotation Term="OData.Description" String="This indicates whether the under the software list is valid."/><Annotation Term="OData.LongDescription" String="This indicates whether the under the software list is valid."/></Property></ComplexType></Schema></edmx:DataServices> </edmx:Edmx>4. 修改hpp中的data.type
在文件中修改odata.type。注意json文件的組織需要與schme中的code對應(yīng)。
// build\workspace\sources\bmcweb\redfish-core\lib\software_service.hpp asyncResp->res.jsonValue["Oem"]["SoftwareInventory"]["@odata.type"] ="#OemService.SoftwareInventory";以下是redfish get到的json數(shù)據(jù),注意一個(gè)json里面可以有兩種odata.type。數(shù)據(jù)的驗(yàn)證是通過type指定的命名空間查找xml中的數(shù)據(jù)。
{"@odata.context": "/redfish/v1/$metadata#SoftwareInventory.SoftwareInventory","@odata.id": "/redfish/v1/UpdateService/SoftwareInventory/AdvancedSystemManagementKey","@odata.type": "#SoftwareInventory.v1_1_0.SoftwareInventory","Actions": {"Oem": {}},"Description": "Upload your key to activate advanced system management features","Id": "AdvancedSystemManagementKey","Name": "Software Inventory","Oem": {"SoftwareInventory": {"@odata.type": "#OemService.SoftwareInventory","LastUpdateTime": "Thu Jan 1 00:04:30 1970","Status": "ACTIVED","UpdateState": "Idle"}} }5. 使用工具驗(yàn)證schema
5.1 安裝、配置工具
Redfish-Service-Validator-master 該工具到github上下載zip包即可,之后解壓。https://github.com/DMTF/Redfish-Service-Validator
安裝python等。注意python腳本,目前3.8.1可以快速安裝whl包。
用cmd在代碼目錄下執(zhí)行以下命令。
pip3 install -r requirements.txt
pip3 install beautifulsoup4 --upgrade
配置文件
在工具目錄下新建文件夾config,在文件夾中添加config.ini 文件。
需要注意:
實(shí)際使用中只需要注意修改IP即可。
5.2 工具使用
工具配置完成后,用cmd在工具代碼目錄下執(zhí)行以下命令,等待完成(十幾分鐘)。
RedfishServiceValidator.py -c config/config.ini執(zhí)行完成后會(huì)有結(jié)果提示。
5.3 查看結(jié)果
在代碼目錄下的logs文件夾中找到最新的時(shí)間命名的html文件,在瀏覽器中打開即可查看結(jié)果,
最上面可以查看到存在問題的url。
[外鏈圖片轉(zhuǎn)存失敗,源站可能有防盜鏈機(jī)制,建議將圖片保存下來直接上傳(img-X6arJgrD-1623291534619)(C:\Users\penghu4x\AppData\Roaming\Typora\typora-user-images\image-20210610095347716.png)]
之后修改xml或者h(yuǎn)pp代碼,知道測試通過。
總結(jié)
以上是生活随笔為你收集整理的add a redfish schema的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用Python对Dicom文件进行读取
- 下一篇: 华为大数据平台使用pyhive连接hiv