曙光 cpu,内存, 存储接口调整

This commit is contained in:
tzwang 2023-05-05 11:36:00 +08:00
parent cfbf4a2810
commit cb8a955c33
8 changed files with 378 additions and 36 deletions

View File

@ -5622,6 +5622,69 @@ func (x *CpResp) GetPOpsAtFp16() float32 {
return 0 return 0
} }
type GiResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
CpuCoreNum int32 `protobuf:"varint,1,opt,name=cpuCoreNum,proto3" json:"cpuCoreNum,omitempty"`
MemoryInGib int32 `protobuf:"varint,2,opt,name=memoryInGib,proto3" json:"memoryInGib,omitempty"`
StorageInGib int32 `protobuf:"varint,3,opt,name=storageInGib,proto3" json:"storageInGib,omitempty"`
}
func (x *GiResp) Reset() {
*x = GiResp{}
if protoimpl.UnsafeEnabled {
mi := &file_pb_hpcAC_proto_msgTypes[59]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GiResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GiResp) ProtoMessage() {}
func (x *GiResp) ProtoReflect() protoreflect.Message {
mi := &file_pb_hpcAC_proto_msgTypes[59]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GiResp.ProtoReflect.Descriptor instead.
func (*GiResp) Descriptor() ([]byte, []int) {
return file_pb_hpcAC_proto_rawDescGZIP(), []int{59}
}
func (x *GiResp) GetCpuCoreNum() int32 {
if x != nil {
return x.CpuCoreNum
}
return 0
}
func (x *GiResp) GetMemoryInGib() int32 {
if x != nil {
return x.MemoryInGib
}
return 0
}
func (x *GiResp) GetStorageInGib() int32 {
if x != nil {
return x.StorageInGib
}
return 0
}
var File_pb_hpcAC_proto protoreflect.FileDescriptor var File_pb_hpcAC_proto protoreflect.FileDescriptor
var file_pb_hpcAC_proto_rawDesc = []byte{ var file_pb_hpcAC_proto_rawDesc = []byte{
@ -6488,7 +6551,14 @@ var file_pb_hpcAC_proto_rawDesc = []byte{
0x0b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x22, 0x28, 0x0a, 0x06, 0x0b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x22, 0x28, 0x0a, 0x06,
0x63, 0x70, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x4f, 0x70, 0x73, 0x41, 0x74, 0x63, 0x70, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x4f, 0x70, 0x73, 0x41, 0x74,
0x46, 0x70, 0x31, 0x36, 0x18, 0x01, 0x20, 0x01, 0x28, 0x02, 0x52, 0x0a, 0x70, 0x4f, 0x70, 0x73, 0x46, 0x70, 0x31, 0x36, 0x18, 0x01, 0x20, 0x01, 0x28, 0x02, 0x52, 0x0a, 0x70, 0x4f, 0x70, 0x73,
0x41, 0x74, 0x46, 0x70, 0x31, 0x36, 0x32, 0xe7, 0x08, 0x0a, 0x05, 0x68, 0x70, 0x63, 0x41, 0x43, 0x41, 0x74, 0x46, 0x70, 0x31, 0x36, 0x22, 0x6e, 0x0a, 0x06, 0x67, 0x69, 0x52, 0x65, 0x73, 0x70,
0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x70, 0x75, 0x43, 0x6f, 0x72, 0x65, 0x4e, 0x75, 0x6d, 0x18, 0x01,
0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x63, 0x70, 0x75, 0x43, 0x6f, 0x72, 0x65, 0x4e, 0x75, 0x6d,
0x12, 0x20, 0x0a, 0x0b, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x49, 0x6e, 0x47, 0x69, 0x62, 0x18,
0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x49, 0x6e, 0x47,
0x69, 0x62, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x49, 0x6e, 0x47,
0x69, 0x62, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67,
0x65, 0x49, 0x6e, 0x47, 0x69, 0x62, 0x32, 0x9c, 0x09, 0x0a, 0x05, 0x68, 0x70, 0x63, 0x41, 0x43,
0x12, 0x30, 0x0a, 0x07, 0x4c, 0x69, 0x73, 0x74, 0x4a, 0x6f, 0x62, 0x12, 0x11, 0x2e, 0x68, 0x70, 0x12, 0x30, 0x0a, 0x07, 0x4c, 0x69, 0x73, 0x74, 0x4a, 0x6f, 0x62, 0x12, 0x11, 0x2e, 0x68, 0x70,
0x63, 0x41, 0x43, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x71, 0x1a, 0x12, 0x63, 0x41, 0x43, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x71, 0x1a, 0x12,
0x2e, 0x68, 0x70, 0x63, 0x41, 0x43, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4a, 0x6f, 0x62, 0x52, 0x65, 0x2e, 0x68, 0x70, 0x63, 0x41, 0x43, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4a, 0x6f, 0x62, 0x52, 0x65,
@ -6559,8 +6629,11 @@ var file_pb_hpcAC_proto_rawDesc = []byte{
0x6f, 0x6d, 0x70, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x50, 0x6f, 0x77, 0x65, 0x72, 0x12, 0x12, 0x2e, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x50, 0x6f, 0x77, 0x65, 0x72, 0x12, 0x12, 0x2e,
0x68, 0x70, 0x63, 0x41, 0x43, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x68, 0x70, 0x63, 0x41, 0x43, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65,
0x71, 0x1a, 0x0d, 0x2e, 0x68, 0x70, 0x63, 0x41, 0x43, 0x2e, 0x63, 0x70, 0x52, 0x65, 0x73, 0x70, 0x71, 0x1a, 0x0d, 0x2e, 0x68, 0x70, 0x63, 0x41, 0x43, 0x2e, 0x63, 0x70, 0x52, 0x65, 0x73, 0x70,
0x42, 0x08, 0x5a, 0x06, 0x2f, 0x68, 0x70, 0x63, 0x41, 0x43, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x12, 0x33, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c, 0x49, 0x6e,
0x6f, 0x33, 0x66, 0x6f, 0x12, 0x12, 0x2e, 0x68, 0x70, 0x63, 0x41, 0x43, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75,
0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x0d, 0x2e, 0x68, 0x70, 0x63, 0x41, 0x43, 0x2e, 0x67,
0x69, 0x52, 0x65, 0x73, 0x70, 0x42, 0x08, 0x5a, 0x06, 0x2f, 0x68, 0x70, 0x63, 0x41, 0x43, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@ -6575,7 +6648,7 @@ func file_pb_hpcAC_proto_rawDescGZIP() []byte {
return file_pb_hpcAC_proto_rawDescData return file_pb_hpcAC_proto_rawDescData
} }
var file_pb_hpcAC_proto_msgTypes = make([]protoimpl.MessageInfo, 60) var file_pb_hpcAC_proto_msgTypes = make([]protoimpl.MessageInfo, 61)
var file_pb_hpcAC_proto_goTypes = []interface{}{ var file_pb_hpcAC_proto_goTypes = []interface{}{
(*JobManager)(nil), // 0: hpcAC.JobManager (*JobManager)(nil), // 0: hpcAC.JobManager
(*JobManagerReq)(nil), // 1: hpcAC.JobManagerReq (*JobManagerReq)(nil), // 1: hpcAC.JobManagerReq
@ -6636,14 +6709,15 @@ var file_pb_hpcAC_proto_goTypes = []interface{}{
(*ACClusterData)(nil), // 56: hpcAC.ACClusterData (*ACClusterData)(nil), // 56: hpcAC.ACClusterData
(*ResourceReq)(nil), // 57: hpcAC.resourceReq (*ResourceReq)(nil), // 57: hpcAC.resourceReq
(*CpResp)(nil), // 58: hpcAC.cpResp (*CpResp)(nil), // 58: hpcAC.cpResp
nil, // 59: hpcAC.DeleteJobResp.DataEntry (*GiResp)(nil), // 59: hpcAC.giResp
nil, // 60: hpcAC.DeleteJobResp.DataEntry
} }
var file_pb_hpcAC_proto_depIdxs = []int32{ var file_pb_hpcAC_proto_depIdxs = []int32{
0, // 0: hpcAC.ListJobManagerResp.data:type_name -> hpcAC.JobManager 0, // 0: hpcAC.ListJobManagerResp.data:type_name -> hpcAC.JobManager
3, // 1: hpcAC.JobDetail.job_init_attr:type_name -> hpcAC.JobInitAttr 3, // 1: hpcAC.JobDetail.job_init_attr:type_name -> hpcAC.JobInitAttr
4, // 2: hpcAC.JobDetail.job_session_info:type_name -> hpcAC.JobVncSessionInfo 4, // 2: hpcAC.JobDetail.job_session_info:type_name -> hpcAC.JobVncSessionInfo
5, // 3: hpcAC.GetJobDetailResp.data:type_name -> hpcAC.JobDetail 5, // 3: hpcAC.GetJobDetailResp.data:type_name -> hpcAC.JobDetail
59, // 4: hpcAC.DeleteJobResp.data:type_name -> hpcAC.DeleteJobResp.DataEntry 60, // 4: hpcAC.DeleteJobResp.data:type_name -> hpcAC.DeleteJobResp.DataEntry
10, // 5: hpcAC.ListJobResp.jobs:type_name -> hpcAC.job 10, // 5: hpcAC.ListJobResp.jobs:type_name -> hpcAC.job
15, // 6: hpcAC.ListHistoryJobResp.data:type_name -> hpcAC.HistoryJobData 15, // 6: hpcAC.ListHistoryJobResp.data:type_name -> hpcAC.HistoryJobData
16, // 7: hpcAC.HistoryJobData.list:type_name -> hpcAC.HistoryJobList 16, // 7: hpcAC.HistoryJobData.list:type_name -> hpcAC.HistoryJobList
@ -6681,27 +6755,29 @@ var file_pb_hpcAC_proto_depIdxs = []int32{
48, // 39: hpcAC.hpcAC.GetACToken:input_type -> hpcAC.ACTokenReq 48, // 39: hpcAC.hpcAC.GetACToken:input_type -> hpcAC.ACTokenReq
53, // 40: hpcAC.hpcAC.GetACClusterId:input_type -> hpcAC.ACClusterReq 53, // 40: hpcAC.hpcAC.GetACClusterId:input_type -> hpcAC.ACClusterReq
57, // 41: hpcAC.hpcAC.GetComputingPower:input_type -> hpcAC.resourceReq 57, // 41: hpcAC.hpcAC.GetComputingPower:input_type -> hpcAC.resourceReq
12, // 42: hpcAC.hpcAC.ListJob:output_type -> hpcAC.ListJobResp 57, // 42: hpcAC.hpcAC.GetGeneralInfo:input_type -> hpcAC.resourceReq
14, // 43: hpcAC.hpcAC.ListHistoryJob:output_type -> hpcAC.ListHistoryJobResp 12, // 43: hpcAC.hpcAC.ListJob:output_type -> hpcAC.ListJobResp
18, // 44: hpcAC.hpcAC.SubmitJob:output_type -> hpcAC.SubmitJobResp 14, // 44: hpcAC.hpcAC.ListHistoryJob:output_type -> hpcAC.ListHistoryJobResp
2, // 45: hpcAC.hpcAC.ListJobManager:output_type -> hpcAC.ListJobManagerResp 18, // 45: hpcAC.hpcAC.SubmitJob:output_type -> hpcAC.SubmitJobResp
7, // 46: hpcAC.hpcAC.GetJobDetail:output_type -> hpcAC.GetJobDetailResp 2, // 46: hpcAC.hpcAC.ListJobManager:output_type -> hpcAC.ListJobManagerResp
9, // 47: hpcAC.hpcAC.DeleteJob:output_type -> hpcAC.DeleteJobResp 7, // 47: hpcAC.hpcAC.GetJobDetail:output_type -> hpcAC.GetJobDetailResp
38, // 48: hpcAC.hpcAC.FileContent:output_type -> hpcAC.FileContentResp 9, // 48: hpcAC.hpcAC.DeleteJob:output_type -> hpcAC.DeleteJobResp
42, // 49: hpcAC.hpcAC.SelectQueueByUser:output_type -> hpcAC.QueueResp 38, // 49: hpcAC.hpcAC.FileContent:output_type -> hpcAC.FileContentResp
44, // 50: hpcAC.hpcAC.QueryQueueDetails:output_type -> hpcAC.QueueDetailsResp 42, // 50: hpcAC.hpcAC.SelectQueueByUser:output_type -> hpcAC.QueueResp
46, // 51: hpcAC.hpcAC.QueryUserQuotasLimit:output_type -> hpcAC.UserQuotasLimitResp 44, // 51: hpcAC.hpcAC.QueryQueueDetails:output_type -> hpcAC.QueueDetailsResp
21, // 52: hpcAC.hpcAC.ParaStorQuota:output_type -> hpcAC.ParaStorQuotaResp 46, // 52: hpcAC.hpcAC.QueryUserQuotasLimit:output_type -> hpcAC.UserQuotasLimitResp
24, // 53: hpcAC.hpcAC.WallTime:output_type -> hpcAC.WallTimeResp 21, // 53: hpcAC.hpcAC.ParaStorQuota:output_type -> hpcAC.ParaStorQuotaResp
26, // 54: hpcAC.hpcAC.QueueJobs:output_type -> hpcAC.QueueJobsResp 24, // 54: hpcAC.hpcAC.WallTime:output_type -> hpcAC.WallTimeResp
30, // 55: hpcAC.hpcAC.CpuCore:output_type -> hpcAC.CpuCoreResp 26, // 55: hpcAC.hpcAC.QueueJobs:output_type -> hpcAC.QueueJobsResp
33, // 56: hpcAC.hpcAC.jobs:output_type -> hpcAC.JobsResp 30, // 56: hpcAC.hpcAC.CpuCore:output_type -> hpcAC.CpuCoreResp
37, // 57: hpcAC.hpcAC.HistoryJobDetail:output_type -> hpcAC.HistoryJobDetailResp 33, // 57: hpcAC.hpcAC.jobs:output_type -> hpcAC.JobsResp
52, // 58: hpcAC.hpcAC.GetACToken:output_type -> hpcAC.TokenResp 37, // 58: hpcAC.hpcAC.HistoryJobDetail:output_type -> hpcAC.HistoryJobDetailResp
55, // 59: hpcAC.hpcAC.GetACClusterId:output_type -> hpcAC.ClusterResp 52, // 59: hpcAC.hpcAC.GetACToken:output_type -> hpcAC.TokenResp
58, // 60: hpcAC.hpcAC.GetComputingPower:output_type -> hpcAC.cpResp 55, // 60: hpcAC.hpcAC.GetACClusterId:output_type -> hpcAC.ClusterResp
42, // [42:61] is the sub-list for method output_type 58, // 61: hpcAC.hpcAC.GetComputingPower:output_type -> hpcAC.cpResp
23, // [23:42] is the sub-list for method input_type 59, // 62: hpcAC.hpcAC.GetGeneralInfo:output_type -> hpcAC.giResp
43, // [43:63] is the sub-list for method output_type
23, // [23:43] is the sub-list for method input_type
23, // [23:23] is the sub-list for extension type_name 23, // [23:23] is the sub-list for extension type_name
23, // [23:23] is the sub-list for extension extendee 23, // [23:23] is the sub-list for extension extendee
0, // [0:23] is the sub-list for field type_name 0, // [0:23] is the sub-list for field type_name
@ -7421,6 +7497,18 @@ func file_pb_hpcAC_proto_init() {
return nil return nil
} }
} }
file_pb_hpcAC_proto_msgTypes[59].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GiResp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
} }
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
@ -7428,7 +7516,7 @@ func file_pb_hpcAC_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_pb_hpcAC_proto_rawDesc, RawDescriptor: file_pb_hpcAC_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 60, NumMessages: 61,
NumExtensions: 0, NumExtensions: 0,
NumServices: 1, NumServices: 1,
}, },

View File

@ -57,6 +57,8 @@ type HpcACClient interface {
GetACClusterId(ctx context.Context, in *ACClusterReq, opts ...grpc.CallOption) (*ClusterResp, error) GetACClusterId(ctx context.Context, in *ACClusterReq, opts ...grpc.CallOption) (*ClusterResp, error)
// 获取曙光账号算力 // 获取曙光账号算力
GetComputingPower(ctx context.Context, in *ResourceReq, opts ...grpc.CallOption) (*CpResp, error) GetComputingPower(ctx context.Context, in *ResourceReq, opts ...grpc.CallOption) (*CpResp, error)
// 获取曙光账号cpu,内存,存储信息
GetGeneralInfo(ctx context.Context, in *ResourceReq, opts ...grpc.CallOption) (*GiResp, error)
} }
type hpcACClient struct { type hpcACClient struct {
@ -238,6 +240,15 @@ func (c *hpcACClient) GetComputingPower(ctx context.Context, in *ResourceReq, op
return out, nil return out, nil
} }
func (c *hpcACClient) GetGeneralInfo(ctx context.Context, in *ResourceReq, opts ...grpc.CallOption) (*GiResp, error) {
out := new(GiResp)
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/GetGeneralInfo", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// HpcACServer is the server API for HpcAC service. // HpcACServer is the server API for HpcAC service.
// All implementations must embed UnimplementedHpcACServer // All implementations must embed UnimplementedHpcACServer
// for forward compatibility // for forward compatibility
@ -277,6 +288,8 @@ type HpcACServer interface {
GetACClusterId(context.Context, *ACClusterReq) (*ClusterResp, error) GetACClusterId(context.Context, *ACClusterReq) (*ClusterResp, error)
// 获取曙光账号算力 // 获取曙光账号算力
GetComputingPower(context.Context, *ResourceReq) (*CpResp, error) GetComputingPower(context.Context, *ResourceReq) (*CpResp, error)
// 获取曙光账号cpu,内存,存储信息
GetGeneralInfo(context.Context, *ResourceReq) (*GiResp, error)
mustEmbedUnimplementedHpcACServer() mustEmbedUnimplementedHpcACServer()
} }
@ -341,6 +354,9 @@ func (UnimplementedHpcACServer) GetACClusterId(context.Context, *ACClusterReq) (
func (UnimplementedHpcACServer) GetComputingPower(context.Context, *ResourceReq) (*CpResp, error) { func (UnimplementedHpcACServer) GetComputingPower(context.Context, *ResourceReq) (*CpResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetComputingPower not implemented") return nil, status.Errorf(codes.Unimplemented, "method GetComputingPower not implemented")
} }
func (UnimplementedHpcACServer) GetGeneralInfo(context.Context, *ResourceReq) (*GiResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetGeneralInfo not implemented")
}
func (UnimplementedHpcACServer) mustEmbedUnimplementedHpcACServer() {} func (UnimplementedHpcACServer) mustEmbedUnimplementedHpcACServer() {}
// UnsafeHpcACServer may be embedded to opt out of forward compatibility for this service. // UnsafeHpcACServer may be embedded to opt out of forward compatibility for this service.
@ -696,6 +712,24 @@ func _HpcAC_GetComputingPower_Handler(srv interface{}, ctx context.Context, dec
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _HpcAC_GetGeneralInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ResourceReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HpcACServer).GetGeneralInfo(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/hpcAC.hpcAC/GetGeneralInfo",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HpcACServer).GetGeneralInfo(ctx, req.(*ResourceReq))
}
return interceptor(ctx, in, info, handler)
}
// HpcAC_ServiceDesc is the grpc.ServiceDesc for HpcAC service. // HpcAC_ServiceDesc is the grpc.ServiceDesc for HpcAC service.
// It's only intended for direct use with grpc.RegisterService, // It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy) // and not to be introspected or modified (even as a copy)
@ -779,6 +813,10 @@ var HpcAC_ServiceDesc = grpc.ServiceDesc{
MethodName: "GetComputingPower", MethodName: "GetComputingPower",
Handler: _HpcAC_GetComputingPower_Handler, Handler: _HpcAC_GetComputingPower_Handler,
}, },
{
MethodName: "GetGeneralInfo",
Handler: _HpcAC_GetGeneralInfo_Handler,
},
}, },
Streams: []grpc.StreamDesc{}, Streams: []grpc.StreamDesc{},
Metadata: "pb/hpcAC.proto", Metadata: "pb/hpcAC.proto",

View File

@ -31,6 +31,7 @@ type (
FileDataReq = hpcAC.FileDataReq FileDataReq = hpcAC.FileDataReq
FileDataResp = hpcAC.FileDataResp FileDataResp = hpcAC.FileDataResp
GetJobDetailResp = hpcAC.GetJobDetailResp GetJobDetailResp = hpcAC.GetJobDetailResp
GiResp = hpcAC.GiResp
HistoryJobData = hpcAC.HistoryJobData HistoryJobData = hpcAC.HistoryJobData
HistoryJobDetail = hpcAC.HistoryJobDetail HistoryJobDetail = hpcAC.HistoryJobDetail
HistoryJobDetailReq = hpcAC.HistoryJobDetailReq HistoryJobDetailReq = hpcAC.HistoryJobDetailReq
@ -109,6 +110,8 @@ type (
GetACClusterId(ctx context.Context, in *ACClusterReq, opts ...grpc.CallOption) (*ClusterResp, error) GetACClusterId(ctx context.Context, in *ACClusterReq, opts ...grpc.CallOption) (*ClusterResp, error)
// 获取曙光账号算力 // 获取曙光账号算力
GetComputingPower(ctx context.Context, in *ResourceReq, opts ...grpc.CallOption) (*CpResp, error) GetComputingPower(ctx context.Context, in *ResourceReq, opts ...grpc.CallOption) (*CpResp, error)
// 获取曙光账号cpu,内存,存储信息
GetGeneralInfo(ctx context.Context, in *ResourceReq, opts ...grpc.CallOption) (*GiResp, error)
} }
defaultHpcAC struct { defaultHpcAC struct {
@ -232,3 +235,9 @@ func (m *defaultHpcAC) GetComputingPower(ctx context.Context, in *ResourceReq, o
client := hpcAC.NewHpcACClient(m.cli.Conn()) client := hpcAC.NewHpcACClient(m.cli.Conn())
return client.GetComputingPower(ctx, in, opts...) return client.GetComputingPower(ctx, in, opts...)
} }
// 获取曙光账号cpu,内存,存储信息
func (m *defaultHpcAC) GetGeneralInfo(ctx context.Context, in *ResourceReq, opts ...grpc.CallOption) (*GiResp, error) {
client := hpcAC.NewHpcACClient(m.cli.Conn())
return client.GetGeneralInfo(ctx, in, opts...)
}

View File

@ -112,3 +112,40 @@ type ClusterResp struct {
JobManagerPort string `json:"JobManagerPort"` JobManagerPort string `json:"JobManagerPort"`
} `json:"data"` } `json:"data"`
} }
type ResourceGroupResp struct {
Code string `json:"code"`
Msg string `json:"msg"`
Data struct {
Dcu []string `json:"dcu"`
Cpu []string `json:"cpu"`
} `json:"data"`
}
type ParastorQuota struct {
Code string `json:"code"`
Msg string `json:"msg"`
Data []struct {
Username interface{} `json:"username"`
Path string `json:"path"`
Threshold int `json:"threshold"`
Usage float64 `json:"usage"`
} `json:"data"`
}
type ResourceResp struct {
Code string `json:"code"`
Msg string `json:"msg"`
Data struct {
Id interface{} `json:"id"`
CpuNumber int `json:"cpuNumber"`
MluLimits int `json:"mluLimits"`
DcuLimits int `json:"dcuLimits"`
NvLimits int `json:"nvLimits"`
GpuNumber int `json:"gpuNumber"`
MemorySize int `json:"memorySize"`
ResourceGroup string `json:"resourceGroup"`
UserName interface{} `json:"userName"`
NodeNumber int `json:"nodeNumber"`
MaxTime string `json:"maxTime"`
} `json:"data"`
}

View File

@ -14,13 +14,16 @@ type ShuguangConf struct {
ClusterID string `json:"ClusterID"` ClusterID string `json:"ClusterID"`
} }
// 算力相关配置 // 算力,cpu,内存 相关配置
type CPConf struct { type CPConf struct {
AcBaseUrl string AcBaseUrl string
AuthUrl string AuthUrl string
ClusUrl string ClusUrl string
CenterUrl string CenterUrl string
UserLimitUrl string UserLimitUrl string
Dcu float32 Dcu float32
CpuCore float32 CpuCore float32
AiResourceUrl string
AiResourceGroupUrl string
ParastorQuotaUrl string
} }

View File

@ -0,0 +1,152 @@
package logic
import (
"PCM/adaptor/PCM-HPC/PCM-AC/rpc/internal/common"
"PCM/common/tool"
"context"
"strconv"
"strings"
"PCM/adaptor/PCM-HPC/PCM-AC/rpc/hpcAC"
"PCM/adaptor/PCM-HPC/PCM-AC/rpc/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type GetGeneralInfoLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetGeneralInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetGeneralInfoLogic {
return &GetGeneralInfoLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 获取曙光账号cpu,内存,存储信息
func (l *GetGeneralInfoLogic) GetGeneralInfo(in *hpcAC.ResourceReq) (*hpcAC.GiResp, error) {
resp := &hpcAC.GiResp{}
resp.MemoryInGib = 0
resp.CpuCoreNum = 0
resp.StorageInGib = 0
cpConf := l.svcCtx.Config.CPConf
sgConf := l.svcCtx.Config.ShuguangConf
tokenUrl := cpConf.AcBaseUrl + cpConf.AuthUrl
//获取token
var tokenResp common.TokenResp
var token string
tokenReq := tool.GetACHttpRequest()
_, err := tokenReq.SetHeader(tool.ContentType, tool.ApplicationJson).
SetHeader("user", l.svcCtx.Config.User).
SetHeader("password", l.svcCtx.Config.Password).
SetHeader("orgId", l.svcCtx.Config.OrgId).
SetResult(&tokenResp).
Post(tokenUrl)
if err != nil || tokenResp.Code != "0" {
return resp, nil
}
for _, datum := range tokenResp.Data {
if datum.ClusterId != "0" {
token = datum.Token
}
}
//获取 ai, hpc prefix url
var centerResp common.CenterResp
centerUrl := cpConf.AcBaseUrl + cpConf.CenterUrl
var hpc_prefix_url string
var ai_prefix_url string
centerReq := tool.GetACHttpRequest()
_, err = centerReq.SetHeader(tool.ContentType, tool.ApplicationJson).
SetHeader("token", token).
SetResult(&centerResp).
Get(centerUrl)
if err != nil || centerResp.Code != "0" {
return resp, nil
}
hpc_prefix_url = centerResp.Data.HpcUrls[0].Url
ai_prefix_url = centerResp.Data.AiUrls[0].Url
//获取调度器id
var clusterResp common.ClusterResp
var jobManagerId int
clusterUrl := hpc_prefix_url + cpConf.ClusUrl
clusterReq := tool.GetACHttpRequest()
_, err = clusterReq.SetHeader(tool.ContentType, tool.ApplicationJson).
SetHeader("token", token).
SetResult(&clusterResp).
Get(clusterUrl)
if err != nil || clusterResp.Code != "0" {
return resp, nil
}
jobManagerId = clusterResp.Data[0].Id
//获取用户资源限制信息
var quotaResp common.QuotaResp
quotaUrl := hpc_prefix_url + cpConf.UserLimitUrl
quotaReq := tool.GetACHttpRequest()
_, err = quotaReq.SetHeader(tool.ContentType, tool.ApplicationJson).
SetHeader("token", token).
SetQueryString("strJobManagerID=" + strconv.Itoa(jobManagerId)).
SetResult(&quotaResp).
Get(quotaUrl)
if err != nil || quotaResp.Code != "0" {
return resp, nil
}
//查询普通共享存储配额及使用量
var parastorQuotaResp common.ParastorQuota
parastorQuotaUrl := hpc_prefix_url + cpConf.ParastorQuotaUrl
parastorQuotaUrl = strings.Replace(parastorQuotaUrl, "{username}", sgConf.User, -1)
parastorQuotaReq := tool.GetACHttpRequest()
_, err = parastorQuotaReq.SetHeader(tool.ContentType, tool.ApplicationJson).
SetHeader("token", token).
SetResult(&parastorQuotaResp).
Get(parastorQuotaUrl)
if err != nil || parastorQuotaResp.Code != "0" {
return resp, nil
}
//获取资源分组
var resourceGroupResp common.ResourceGroupResp
resourceGroupUrl := ai_prefix_url + cpConf.AiResourceGroupUrl
resourceGroupReq := tool.GetACHttpRequest()
_, err = resourceGroupReq.SetHeader(tool.ContentType, tool.ApplicationJson).
SetHeader("token", token).
SetResult(&resourceGroupResp).
Get(resourceGroupUrl)
if err != nil || resourceGroupResp.Code != "0" {
return resp, nil
}
//获取节点资源限额
//var resourceResp common.ResourceResp
//resourceUrl := ai_prefix_url + cpConf.AiResourceUrl
//
//resourceGroupReq := tool.GetACHttpRequest()
//_, err = resourceGroupReq.SetHeader(tool.ContentType, tool.ApplicationJson).
// SetHeader("token", token).
// SetResult(&resourceGroupResp).
// Get(resourceGroupUrl)
//if err != nil || resourceGroupResp.Code != "0" {
// return resp, nil
//}
return &hpcAC.GiResp{}, nil
}

View File

@ -132,3 +132,9 @@ func (s *HpcACServer) GetComputingPower(ctx context.Context, in *hpcAC.ResourceR
l := logic.NewGetComputingPowerLogic(ctx, s.svcCtx) l := logic.NewGetComputingPowerLogic(ctx, s.svcCtx)
return l.GetComputingPower(in) return l.GetComputingPower(in)
} }
// 获取曙光账号cpu,内存,存储信息
func (s *HpcACServer) GetGeneralInfo(ctx context.Context, in *hpcAC.ResourceReq) (*hpcAC.GiResp, error) {
l := logic.NewGetGeneralInfoLogic(ctx, s.svcCtx)
return l.GetGeneralInfo(in)
}

View File

@ -614,6 +614,12 @@ message cpResp{
float pOpsAtFp16 = 1; float pOpsAtFp16 = 1;
} }
message giResp{
int32 cpuCoreNum = 1;
int32 memoryInGib = 2;
int32 storageInGib = 3;
}
// HPC Services for AC // HPC Services for AC
service hpcAC { service hpcAC {
@ -671,4 +677,7 @@ service hpcAC {
// //
rpc GetComputingPower(resourceReq) returns (cpResp); rpc GetComputingPower(resourceReq) returns (cpResp);
//cpu,
rpc GetGeneralInfo(resourceReq) returns (giResp);
} }