fix:增加大屏数据代码到2.0分支
This commit is contained in:
parent
fdf44058e4
commit
9486c5c8f4
|
|
@ -20,7 +20,7 @@ const (
|
|||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// *****************auth Start************************
|
||||
// *****************screen storage Start************************
|
||||
type StorageScreenReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
|
|
@ -279,11 +279,15 @@ type StorageScreenResp struct {
|
|||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
TotalSize int32 `protobuf:"varint,1,opt,name=totalSize,proto3" json:"totalSize,omitempty"` // @gotags: copier:"totalSize"
|
||||
AiCenterInfos []*AiCenterInfos `protobuf:"bytes,2,rep,name=aiCenterInfos,proto3" json:"aiCenterInfos,omitempty"` // @gotags: copier:"aiCenterInfos"
|
||||
Code int32 `protobuf:"varint,3,opt,name=code,proto3" json:"code,omitempty"` // @gotags: copier:"Code"
|
||||
Msg string `protobuf:"bytes,4,opt,name=msg,proto3" json:"msg,omitempty"` // @gotags: copier:"Msg"
|
||||
ErrorMsg string `protobuf:"bytes,5,opt,name=error_msg,json=errorMsg,proto3" json:"error_msg,omitempty"` // @gotags: copier:"ErrorMsg"
|
||||
TotalSize int32 `protobuf:"varint,1,opt,name=totalSize,proto3" json:"totalSize,omitempty"` // @gotags: copier:"totalSize"
|
||||
AiCenterInfos []*AiCenterInfos `protobuf:"bytes,2,rep,name=aiCenterInfos,proto3" json:"aiCenterInfos,omitempty"` // @gotags: copier:"aiCenterInfos"
|
||||
StorageUsed float32 `protobuf:"fixed32,3,opt,name=StorageUsed,proto3" json:"StorageUsed,omitempty"`
|
||||
StorageUsing float32 `protobuf:"fixed32,4,opt,name=StorageUsing,proto3" json:"StorageUsing,omitempty"`
|
||||
UsageRate float32 `protobuf:"fixed32,5,opt,name=UsageRate,proto3" json:"UsageRate,omitempty"`
|
||||
UsingRate float32 `protobuf:"fixed32,6,opt,name=UsingRate,proto3" json:"UsingRate,omitempty"`
|
||||
Code int32 `protobuf:"varint,7,opt,name=code,proto3" json:"code,omitempty"` // @gotags: copier:"Code"
|
||||
Msg string `protobuf:"bytes,8,opt,name=msg,proto3" json:"msg,omitempty"` // @gotags: copier:"Msg"
|
||||
ErrorMsg string `protobuf:"bytes,9,opt,name=error_msg,json=errorMsg,proto3" json:"error_msg,omitempty"` // @gotags: copier:"ErrorMsg"
|
||||
}
|
||||
|
||||
func (x *StorageScreenResp) Reset() {
|
||||
|
|
@ -332,6 +336,34 @@ func (x *StorageScreenResp) GetAiCenterInfos() []*AiCenterInfos {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (x *StorageScreenResp) GetStorageUsed() float32 {
|
||||
if x != nil {
|
||||
return x.StorageUsed
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *StorageScreenResp) GetStorageUsing() float32 {
|
||||
if x != nil {
|
||||
return x.StorageUsing
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *StorageScreenResp) GetUsageRate() float32 {
|
||||
if x != nil {
|
||||
return x.UsageRate
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *StorageScreenResp) GetUsingRate() float32 {
|
||||
if x != nil {
|
||||
return x.UsingRate
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *StorageScreenResp) GetCode() int32 {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
|
|
@ -399,25 +431,33 @@ var file_pcm_ceph_proto_rawDesc = []byte{
|
|||
0x72, 0x64, 0x52, 0x75, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x15, 0x20, 0x01, 0x28, 0x05, 0x52,
|
||||
0x0b, 0x63, 0x61, 0x72, 0x64, 0x52, 0x75, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08,
|
||||
0x6a, 0x6f, 0x62, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x16, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08,
|
||||
0x6a, 0x6f, 0x62, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xb3, 0x01, 0x0a, 0x11, 0x53, 0x74, 0x6f,
|
||||
0x6a, 0x6f, 0x62, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xb5, 0x02, 0x0a, 0x11, 0x53, 0x74, 0x6f,
|
||||
0x72, 0x61, 0x67, 0x65, 0x53, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1c,
|
||||
0x0a, 0x09, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x05, 0x52, 0x09, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x3d, 0x0a, 0x0d,
|
||||
0x61, 0x69, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x18, 0x02, 0x20,
|
||||
0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x2e, 0x41,
|
||||
0x69, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x52, 0x0d, 0x61, 0x69,
|
||||
0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x63,
|
||||
0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12,
|
||||
0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73,
|
||||
0x67, 0x12, 0x1b, 0x0a, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x05,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x32, 0x50,
|
||||
0x0a, 0x04, 0x43, 0x65, 0x70, 0x68, 0x12, 0x48, 0x0a, 0x0d, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67,
|
||||
0x65, 0x53, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x12, 0x1a, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61,
|
||||
0x74, 0x65, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, 0x63, 0x72, 0x65, 0x65, 0x6e,
|
||||
0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x2e, 0x53,
|
||||
0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70,
|
||||
0x42, 0x07, 0x5a, 0x05, 0x2f, 0x63, 0x65, 0x70, 0x68, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x33,
|
||||
0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x53,
|
||||
0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x55, 0x73, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02,
|
||||
0x52, 0x0b, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x55, 0x73, 0x65, 0x64, 0x12, 0x22, 0x0a,
|
||||
0x0c, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x55, 0x73, 0x69, 0x6e, 0x67, 0x18, 0x04, 0x20,
|
||||
0x01, 0x28, 0x02, 0x52, 0x0c, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x55, 0x73, 0x69, 0x6e,
|
||||
0x67, 0x12, 0x1c, 0x0a, 0x09, 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x61, 0x74, 0x65, 0x18, 0x05,
|
||||
0x20, 0x01, 0x28, 0x02, 0x52, 0x09, 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x61, 0x74, 0x65, 0x12,
|
||||
0x1c, 0x0a, 0x09, 0x55, 0x73, 0x69, 0x6e, 0x67, 0x52, 0x61, 0x74, 0x65, 0x18, 0x06, 0x20, 0x01,
|
||||
0x28, 0x02, 0x52, 0x09, 0x55, 0x73, 0x69, 0x6e, 0x67, 0x52, 0x61, 0x74, 0x65, 0x12, 0x12, 0x0a,
|
||||
0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, 0x64,
|
||||
0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03,
|
||||
0x6d, 0x73, 0x67, 0x12, 0x1b, 0x0a, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x73, 0x67,
|
||||
0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67,
|
||||
0x32, 0x50, 0x0a, 0x04, 0x43, 0x65, 0x70, 0x68, 0x12, 0x48, 0x0a, 0x0d, 0x73, 0x74, 0x6f, 0x72,
|
||||
0x61, 0x67, 0x65, 0x53, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x12, 0x1a, 0x2e, 0x74, 0x65, 0x6d, 0x70,
|
||||
0x6c, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, 0x63, 0x72, 0x65,
|
||||
0x65, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65,
|
||||
0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x52, 0x65,
|
||||
0x73, 0x70, 0x42, 0x07, 0x5a, 0x05, 0x2f, 0x63, 0x65, 0x70, 0x68, 0x62, 0x06, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import (
|
|||
"PCM/adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/config"
|
||||
"PCM/common/tool"
|
||||
"context"
|
||||
"fmt"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
|
|
@ -68,7 +69,40 @@ func (l *StorageScreenLogic) StorageScreen(in *ceph.StorageScreenReq) (*ceph.Sto
|
|||
return nil, err
|
||||
}
|
||||
if statusCode == 200 {
|
||||
json.Unmarshal(body, &resp)
|
||||
err := json.Unmarshal(body, &resp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
var usedStorageScale int32 //已使用
|
||||
var usingStorageScale int32 //未使用
|
||||
for _, item := range resp.AiCenterInfos {
|
||||
if item.ConnectionState == 3 {
|
||||
usedStorageScale += item.StorageScale
|
||||
} else {
|
||||
usingStorageScale += item.StorageScale
|
||||
}
|
||||
}
|
||||
fmt.Println(usedStorageScale)
|
||||
fmt.Println(usingStorageScale)
|
||||
var floatUsedStorageScale float32 = float32(usedStorageScale)
|
||||
var floatUsingStorageScale float32 = float32(usingStorageScale)
|
||||
|
||||
var UsageRate float32 //已使用率
|
||||
var UsingRate float32 //未使用率
|
||||
var StorageUsed float32 //已使用量
|
||||
var StorageUsing float32 //未使用量
|
||||
UsageRate = (floatUsedStorageScale*1024 + 54.6) / (floatUsedStorageScale*1024 + floatUsingStorageScale*1024 + 54.6)
|
||||
UsingRate = (floatUsingStorageScale*1024 + 54.6) / (floatUsedStorageScale*1024 + floatUsingStorageScale*1024 + 54.6)
|
||||
StorageUsed = floatUsedStorageScale*1024 + 54.6
|
||||
StorageUsing = floatUsingStorageScale*1024 + 54.6
|
||||
fmt.Println(StorageUsed)
|
||||
fmt.Println(StorageUsing)
|
||||
fmt.Println(UsageRate)
|
||||
fmt.Println(UsingRate)
|
||||
resp.UsageRate = UsageRate
|
||||
resp.UsageRate = UsingRate
|
||||
resp.StorageUsing = StorageUsing
|
||||
resp.StorageUsing = StorageUsed
|
||||
resp.Code = 200
|
||||
resp.Msg = "Success"
|
||||
} else if statusCode != 200 {
|
||||
|
|
|
|||
|
|
@ -3,13 +3,11 @@ syntax = "proto3";
|
|||
package template;
|
||||
option go_package = "/ceph";
|
||||
|
||||
/******************auth Start*************************/
|
||||
/******************screen storage Start*************************/
|
||||
message StorageScreenReq{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
message AiCenterInfos{
|
||||
string id = 1; // @gotags: copier:"id"
|
||||
string name = 2; // @gotags: copier:"name"
|
||||
|
|
@ -38,10 +36,19 @@ message AiCenterInfos{
|
|||
message StorageScreenResp{
|
||||
int32 totalSize = 1; // @gotags: copier:"totalSize"
|
||||
repeated AiCenterInfos aiCenterInfos = 2; // @gotags: copier:"aiCenterInfos"
|
||||
int32 code = 3; // @gotags: copier:"Code"
|
||||
string msg = 4; // @gotags: copier:"Msg"
|
||||
string error_msg =5;// @gotags: copier:"ErrorMsg"
|
||||
float StorageUsed = 3;
|
||||
float StorageUsing = 4;
|
||||
float UsageRate =5;
|
||||
float UsingRate =6;
|
||||
int32 code = 7; // @gotags: copier:"Code"
|
||||
string msg = 8; // @gotags: copier:"Msg"
|
||||
string error_msg =9;// @gotags: copier:"ErrorMsg"
|
||||
}
|
||||
/******************screen storage end*************************/
|
||||
|
||||
/******************screen computing power Start*************************/
|
||||
|
||||
/******************screen computing power End*************************/
|
||||
|
||||
service Ceph {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue