日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

add a redfish schema

發(fā)布時(shí)間:2023/12/31 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 add a redfish schema 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

add a redfish schema

在redfish中添加自己的schema xml文件,需要以下幾步:

  • 在py腳本中添加
  • 在index中添加
  • 添加xml文件
  • 修改hpp中的data.type
  • 使用工具驗(yàn)證schema
  • 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 文件。

    需要注意:

  • TargetIP 是bmc的ip,每次執(zhí)行前需要確認(rèn)該ip
  • MetadataFilePath 是schema的存放路徑
  • LocalOnlyMode置位false,ServiceMode 為true
  • LogPath 輸出結(jié)果的存放路徑
  • [SystemInformation] TargetIP = 10.112.108.153 SystemInfo = Test Config, place your own description of target system here UserName = root Password = 0penBmc AuthType = Session ForceAuth = False Token = UseSSL = True CertificateCheck = False CertificateBundle = [Options] MetadataFilePath = ./SchemaFiles/metadata Schema_Pack = OemCheck = True CacheMode = Off CacheFilePath = SchemaSuffix = _v1.xml Timeout = 150 HttpProxy = HttpsProxy = LocalOnlyMode = False ServiceMode = True PreferOnline = False LinkLimit = LogEntry:1 Sample = 0 VersionCheck = [Validator] PayloadMode = Default PayloadFilePath = LogPath = ./logs

    實(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)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。