67 lines
2.0 KiB
Go
67 lines
2.0 KiB
Go
package collector
|
|
|
|
import (
|
|
"gitlink.org.cn/cloudream/common/pkgs/mq"
|
|
uopsdk "gitlink.org.cn/cloudream/common/sdks/unifyops"
|
|
)
|
|
|
|
type ResourceService interface {
|
|
GetOneResourceData(msg *GetOneResourceData) (*GetOneResourceDataResp, *mq.CodeMessage)
|
|
|
|
GetAllResourceData(msg *GetAllResourceData) (*GetAllResourceDataResp, *mq.CodeMessage)
|
|
}
|
|
|
|
// 根据nodeID和类型名称获取节点中某一类型的信息
|
|
var _ = Register(Service.GetOneResourceData)
|
|
|
|
type GetOneResourceData struct {
|
|
mq.MessageBodyBase
|
|
UOPSlwNodeID uopsdk.SlwNodeID `json:"uopSlwNodeID"`
|
|
Type uopsdk.ResourceType `json:"type"`
|
|
}
|
|
type GetOneResourceDataResp struct {
|
|
mq.MessageBodyBase
|
|
Data uopsdk.ResourceData `json:"data"`
|
|
}
|
|
|
|
func NewGetOneResourceData(uopSlwNodeID uopsdk.SlwNodeID, typ uopsdk.ResourceType) *GetOneResourceData {
|
|
return &GetOneResourceData{
|
|
UOPSlwNodeID: uopSlwNodeID,
|
|
Type: typ,
|
|
}
|
|
}
|
|
func NewGetOneResourceDataResp(data uopsdk.ResourceData) *GetOneResourceDataResp {
|
|
return &GetOneResourceDataResp{
|
|
Data: data,
|
|
}
|
|
}
|
|
func (c *Client) GetOneResourceData(msg *GetOneResourceData, opts ...mq.RequestOption) (*GetOneResourceDataResp, error) {
|
|
return mq.Request(Service.GetOneResourceData, c.rabbitCli, msg, opts...)
|
|
}
|
|
|
|
// 根据nodeID获取节点全部资源信息
|
|
var _ = Register(Service.GetAllResourceData)
|
|
|
|
type GetAllResourceData struct {
|
|
mq.MessageBodyBase
|
|
UOPSlwNodeID uopsdk.SlwNodeID `json:"uopSlwNodeID"`
|
|
}
|
|
type GetAllResourceDataResp struct {
|
|
mq.MessageBodyBase
|
|
Datas []uopsdk.ResourceData `json:"datas"`
|
|
}
|
|
|
|
func NewGetAllResourceData(uopSlwNodeID uopsdk.SlwNodeID) *GetAllResourceData {
|
|
return &GetAllResourceData{
|
|
UOPSlwNodeID: uopSlwNodeID,
|
|
}
|
|
}
|
|
func NewGetAllResourceDataResp(datas []uopsdk.ResourceData) *GetAllResourceDataResp {
|
|
return &GetAllResourceDataResp{
|
|
Datas: datas,
|
|
}
|
|
}
|
|
func (c *Client) GetAllResourceData(msg *GetAllResourceData, opts ...mq.RequestOption) (*GetAllResourceDataResp, error) {
|
|
return mq.Request(Service.GetAllResourceData, c.rabbitCli, msg, opts...)
|
|
}
|