前言:
redfish是新一代的带外管理协议。通过restful api,抽象统一各服务器厂商的带外管理操作。
虽然如此,但各厂商对redfish的支持程度不一。所以,不同厂商对redfish的操作方式与报文格式依然存在小部分差异。甚至有一些型号的服务器不支持redfish。
所以,上新型号服务器前,必须确认服务器型号是否支持redfish,协议是否需要重新适配。
步骤:
1.获取token api
curl -i -k --request POST -H "Content-Type: application/json" -d '{"UserName" : "xxxxxxx","Password" : "xxxxx"}' ${http协议}://${带外ip地址}/redfish/v1/SessionService/Sessions && echo
从返回报文头中,获取X-Auth-Token和Location。
X-Auth-Token:用于后续请求
Location:记录本次session id。用于操作完成后,清除session
2.获取服务器硬件信息
名称 | uri | method | 响应报文子对象 | 说明 |
获取token | /redfish/v1/SessionService/Sessions | post | ||
获取内存列表 | /redfish/v1/Systems/1/Memory | get | Members |
Members记录了内存列表各自的URI。
"Members": [
{
"@odata.id": "/redfish/v1/Systems/1/Memory/proc1dimm1"
},
{
"@odata.id": "/redfish/v1/Systems/1/Memory/proc1dimm2"
}
]
|
获取内存详情 | /redfish/v1/Systems/1/Memory/${menId} | get | /redfish/v1/Systems/1/Memory/proc1dimm1 | |
获取cpu列表 | /redfish/v1/Systems/1/Processors | get | Members |
"Members": [
{
"@odata.id": "/redfish/v1/Systems/1/Processors/1"
},
{
"@odata.id": "/redfish/v1/Systems/1/Processors/2"
}
]
|
获取电源列表 | /redfish/v1/Chassis/1/Power | get | PowerSupplies | |
获取风扇列表 | /redfish/v1/Chassis/1/Thermal | get | Fans | |
获取操作系统存储(磁盘)列表 | /redfish/v1/Systems/1/Storages | get | Members |
{
"@odata.context": "/redfish/v1/$metadata#Systems/Members/1/Storages/$entity",
"@odata.id": "/redfish/v1/Systems/1/Storages",
"@odata.type": "#StorageCollection.StorageCollection",
"Name": "Storage Collection",
"Members@odata.count": 2,
"Members": [
{
"@odata.id": "/redfish/v1/Systems/1/Storages/RAIDStorage0"
},
{
"@odata.id": "/redfish/v1/Systems/1/Storages/RAIDStorage1"
}
]
}
需先对磁盘做挂载才能识别
|
获取机箱存储列表
H3C有效(华为V5、浪潮无效)
|
/redfish/v1/Chassis/1/Drives | get | Members |
{
"@odata.context": "/redfish/v1/$metadata#DriveCollection.DriveCollection",
"@odata.id": "/redfish/v1/Chassis/1/Drives",
"@odata.type": "#DriveCollection.DriveCollection",
"Name": "Drive Collection",
"Members@odata.count": 14,
"Members": [
{
"@odata.id": "/redfish/v1/Chassis/1/Drives/HDDPlaneDisk0"
},
{
"@odata.id": "/redfish/v1/Chassis/1/Drives/HDDPlaneDisk1"
},
{
"@odata.id": "/redfish/v1/Chassis/1/Drives/HDDPlaneDisk2"
},
{
"@odata.id": "/redfish/v1/Chassis/1/Drives/HDDPlaneDisk3"
},
{
"@odata.id": "/redfish/v1/Chassis/1/Drives/HDDPlaneDisk4"
},
{
"@odata.id": "/redfish/v1/Chassis/1/Drives/HDDPlaneDisk5"
},
{
"@odata.id": "/redfish/v1/Chassis/1/Drives/HDDPlaneDisk6"
},
{
"@odata.id": "/redfish/v1/Chassis/1/Drives/HDDPlaneDisk7"
},
{
"@odata.id": "/redfish/v1/Chassis/1/Drives/HDDPlaneDisk8"
},
{
"@odata.id": "/redfish/v1/Chassis/1/Drives/HDDPlaneDisk9"
},
{
"@odata.id": "/redfish/v1/Chassis/1/Drives/HDDPlaneDisk44"
},
{
"@odata.id": "/redfish/v1/Chassis/1/Drives/HDDPlaneDisk45"
},
{
"@odata.id": "/redfish/v1/Chassis/1/Drives/mainboardPCIeCard1(SSD)"
},
{
"@odata.id": "/redfish/v1/Chassis/1/Drives/mainboardPCIeCard5(SSD)"
}
]
}
无需预先挂载
|
获取磁盘详情 | /redfish/v1/Chassis/1/Drives/HDDPlaneDisk0 | get | ||
删除token | /redfish/v1/SessionService/Sessions/${sessionId} | delete |
/redfish/v1/SessionService/Sessions/${sessionId}
URI地址来源:“获取token”步骤中,响应报文的Location头信息。
华为服务器Location头信息是URI;HPE服务器Location头信息是完整的URL
|