Redfish接口测试

Posted 阿等儿

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Redfish接口测试相关的知识,希望对你有一定的参考价值。

1、Postman使用

关闭SSL certificate verification
File -->Settings–>General

2、登录BMC,获取session

操作类型:
POST
https://deviceip/redfish/v1/SessionService/Sessions

请求头:
Content-Type:application/json

请求消息体:

“UserName”:“用户名”,
“Password”:“密码”


Tests:

var Token = postman.getResponseHeader("X-Auth-Token");
pm.globals.set("X-Auth-Token", Token);

3、获取服务器资产信息

操作类型:
GET
https://deviceip/redfish/v1/Systems/1

请求头:
X-Auth-Token:X-Auth-Token

请求消息体:

Tests:

4、服务器上下电

操作类型:
POST
https://deviceip/redfish/v1/Systems/1/Actions/ComputerSystem.Reset

请求头:
X-Auth-Token:X-Auth-Token
Content-Type:application/json

请求消息体:
下电:

 
"ResetType": "GracefulShutdown"


开机:

 
"ResetType": "On"


重启:

 
"ResetType": "ForceRestart"


Tests:

5、创建BMC用户

操作类型:
POST
https://deviceip/redfish/v1/AccountService/Accounts

请求头:
X-Auth-Token:X-Auth-Token
Content-Type:application/json

请求消息体:

 
    "Id":"3", 
    "UserName":"Tech.ON", 
    "Password":"TianGong8000@", 
    "RoleId":"Administrator" 

Id:为新增的用户ID
UserName:新增的用户名
Password:新增用户名的密码
RoleId:当前登录的用户名

Tests:

6、删除BMC用户

操作类型:
DELETE
https://deviceip/redfish/v1/AccountService/Accounts/4

请求头:
X-Auth-Token:X-Auth-Token

请求消息体:

Tests:

7、获取指定BMC用户的信息

操作类型:
GET
https://deviceip/redfish/v1/AccountService/Accounts/4

请求头:
X-Auth-Token:X-Auth-Token
Content-Type:application/json
Accept:* / *

请求消息体:

Tests:

var ETag = postman.getResponseHeader("ETag");
pm.globals.set("ETag", ETag);

8、修改指定BMC用户信息

注意:要先获取该指定用户的信息(先执行上一条获取bmc信息,再执行修改)
操作类型:
PATCH
https://deviceip/redfish/v1/AccountService/Accounts/4

请求头:
X-Auth-Token:X-Auth-Token
Content-Type:application/json
If-Match:ETag

请求消息体:

 
    "UserName":"test2", 
    "Password":"MCY@6363", 
    "RoleId":"Administrator" 


Tests:

9、获取指定BMC网口资源信息

操作类型:
GET
https://deviceip/redfish/v1/Managers/1/EthernetInterfaces/

请求头:
X-Auth-Token:X-Auth-Token

请求消息体:

Tests:

var ETag = postman.getResponseHeader("ETag");
pm.globals.set("ETag", ETag);


返回结果

加上指定网口mac地址后:

10、修改指定BMC管理地址

操作类型:
PATCH
https://deviceip/redfish/v1/Managers/1/EthernetInterfaces/10c3ab155768

请求头:
X-Auth-Token:X-Auth-Token
Content-Type:application/json
If-Match:ETag

请求消息体:


	"IPv4Addresses":[
"Address":"192.168.2.56"
]


Tests:

11、获取Bios设置资源信息

操作类型:
GET
https://deviceip/redfish/v1/Systems/1/Bios/Settings

请求头:
X-Auth-Token:X-Auth-Token

请求消息体:

Tests:

var ETag = postman.getResponseHeader("ETag");
pm.globals.set("ETag", ETag);

12、修改BIOS参数(改变启动顺序)

操作类型:
PATCH
https://deviceip/redfish/v1/Systems/1/Bios/Settings

请求头:
X-Auth-Token:X-Auth-Token
Content-Type:application/json
If-Match:ETag

请求消息体:


  "Attributes":  
  
    "BootTypeOrder0": "HardDiskDrive",
    "BootTypeOrder1": "DVDROMDrive",
    "BootTypeOrder2": "PXE",
    "BootTypeOrder3": "Others"
  

Tests:

以上是关于Redfish接口测试的主要内容,如果未能解决你的问题,请参考以下文章

BMCRedfish简述

python redfish操作

red fish

JMeter接口测试-模块控制器

UEFI实战Redfish的BIOS实现1

UEFI实战Redfish的BIOS实现1