From bd23c6d01e8c620d5e0b3b63a85108f8b053661d Mon Sep 17 00:00:00 2001 From: zhouqunjie <450705171@qq.com> Date: Tue, 8 Nov 2022 02:02:40 -0800 Subject: [PATCH] list qos --- adaptor/pcm_slurm/gen/idl/slurm.pb.go | 91 +++++----- adaptor/pcm_slurm/gen/idl/slurm.pb.gw.go | 87 ++++++++++ adaptor/pcm_slurm/gen/idl/slurm_grpc.pb.go | 38 +++++ adaptor/pcm_slurm/gen/idl/slurmdb_qos.pb.go | 151 +++++++++++++++-- .../gen/openapiv2/idl/slurm.swagger.json | 11 ++ adaptor/pcm_slurm/idl/slurm.proto | 4 + adaptor/pcm_slurm/idl/slurm.yaml | 2 + adaptor/pcm_slurm/idl/slurmdb_qos.proto | 8 + adaptor/pcm_slurm/server/slurm.go | 10 ++ adaptor/pcm_slurm/server/slurmImpl.go | 9 + adaptor/pcm_slurm/service/slurmdb_qos.go | 158 ++++++++++++++++++ adaptor/pcm_slurm/service/slurmer.go | 1 + 12 files changed, 519 insertions(+), 51 deletions(-) create mode 100644 adaptor/pcm_slurm/service/slurmdb_qos.go diff --git a/adaptor/pcm_slurm/gen/idl/slurm.pb.go b/adaptor/pcm_slurm/gen/idl/slurm.pb.go index 834124da..19d7d20e 100644 --- a/adaptor/pcm_slurm/gen/idl/slurm.pb.go +++ b/adaptor/pcm_slurm/gen/idl/slurm.pb.go @@ -29,33 +29,37 @@ var file_idl_slurm_proto_rawDesc = []byte{ 0x1a, 0x17, 0x69, 0x64, 0x6c, 0x2f, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x64, 0x62, 0x5f, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x69, 0x64, 0x6c, 0x2f, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x64, 0x62, 0x5f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x88, 0x03, 0x0a, 0x0c, 0x53, 0x6c, 0x75, 0x72, 0x6d, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x36, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, - 0x72, 0x73, 0x12, 0x13, 0x2e, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, - 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x14, 0x2e, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x2e, - 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x12, 0x30, 0x0a, - 0x07, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x11, 0x2e, 0x73, 0x6c, 0x75, 0x72, 0x6d, - 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x12, 0x2e, 0x73, 0x6c, - 0x75, 0x72, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, - 0x4b, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x12, 0x1a, 0x2e, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, - 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x1a, - 0x1b, 0x2e, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x73, 0x73, 0x6f, - 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x12, 0x45, 0x0a, 0x0e, - 0x47, 0x65, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, - 0x2e, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x19, 0x2e, 0x73, 0x6c, 0x75, 0x72, 0x6d, - 0x2e, 0x47, 0x65, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, - 0x65, 0x73, 0x70, 0x12, 0x3f, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x73, 0x12, 0x16, 0x2e, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, - 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x73, 0x6c, - 0x75, 0x72, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x12, 0x39, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x12, 0x14, 0x2e, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x73, 0x6c, 0x75, 0x72, 0x6d, - 0x2e, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x42, - 0x0a, 0x5a, 0x08, 0x2f, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x15, 0x69, 0x64, 0x6c, 0x2f, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x64, + 0x62, 0x5f, 0x71, 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xbd, 0x03, 0x0a, 0x0c, + 0x53, 0x6c, 0x75, 0x72, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x36, 0x0a, 0x09, + 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x12, 0x13, 0x2e, 0x73, 0x6c, 0x75, 0x72, + 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x14, + 0x2e, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x12, 0x30, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, + 0x11, 0x2e, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, + 0x65, 0x71, 0x1a, 0x12, 0x2e, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, + 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, 0x4b, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x73, + 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1a, 0x2e, 0x73, 0x6c, 0x75, + 0x72, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x2e, 0x4c, + 0x69, 0x73, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x12, 0x45, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x2e, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x2e, 0x47, 0x65, + 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x1a, + 0x19, 0x2e, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, + 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x3f, 0x0a, 0x0c, 0x4c, 0x69, + 0x73, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x12, 0x16, 0x2e, 0x73, 0x6c, 0x75, + 0x72, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x52, + 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x41, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x12, 0x39, 0x0a, 0x0a, 0x47, + 0x65, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x14, 0x2e, 0x73, 0x6c, 0x75, 0x72, + 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x1a, + 0x15, 0x2e, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x33, 0x0a, 0x08, 0x4c, 0x69, 0x73, 0x74, 0x51, 0x6f, + 0x73, 0x73, 0x12, 0x12, 0x2e, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x51, + 0x6f, 0x73, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x13, 0x2e, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x2e, 0x4c, + 0x69, 0x73, 0x74, 0x51, 0x6f, 0x73, 0x73, 0x52, 0x65, 0x73, 0x70, 0x42, 0x0a, 0x5a, 0x08, 0x2f, + 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var file_idl_slurm_proto_goTypes = []interface{}{ @@ -65,12 +69,14 @@ var file_idl_slurm_proto_goTypes = []interface{}{ (*GetAssociationReq)(nil), // 3: slurm.GetAssociationReq (*ListAccountsReq)(nil), // 4: slurm.ListAccountsReq (*GetAccountReq)(nil), // 5: slurm.GetAccountReq - (*ListUsersResp)(nil), // 6: slurm.ListUsersResp - (*GetUserResp)(nil), // 7: slurm.GetUserResp - (*ListAssociationsResp)(nil), // 8: slurm.ListAssociationsResp - (*GetAssociationResp)(nil), // 9: slurm.GetAssociationResp - (*ListAccountsResp)(nil), // 10: slurm.ListAccountsResp - (*GetAccountResp)(nil), // 11: slurm.GetAccountResp + (*ListQossReq)(nil), // 6: slurm.ListQossReq + (*ListUsersResp)(nil), // 7: slurm.ListUsersResp + (*GetUserResp)(nil), // 8: slurm.GetUserResp + (*ListAssociationsResp)(nil), // 9: slurm.ListAssociationsResp + (*GetAssociationResp)(nil), // 10: slurm.GetAssociationResp + (*ListAccountsResp)(nil), // 11: slurm.ListAccountsResp + (*GetAccountResp)(nil), // 12: slurm.GetAccountResp + (*ListQossResp)(nil), // 13: slurm.ListQossResp } var file_idl_slurm_proto_depIdxs = []int32{ 0, // 0: slurm.SlurmService.ListUsers:input_type -> slurm.ListUsersReq @@ -79,14 +85,16 @@ var file_idl_slurm_proto_depIdxs = []int32{ 3, // 3: slurm.SlurmService.GetAssociation:input_type -> slurm.GetAssociationReq 4, // 4: slurm.SlurmService.ListAccounts:input_type -> slurm.ListAccountsReq 5, // 5: slurm.SlurmService.GetAccount:input_type -> slurm.GetAccountReq - 6, // 6: slurm.SlurmService.ListUsers:output_type -> slurm.ListUsersResp - 7, // 7: slurm.SlurmService.GetUser:output_type -> slurm.GetUserResp - 8, // 8: slurm.SlurmService.ListAssociations:output_type -> slurm.ListAssociationsResp - 9, // 9: slurm.SlurmService.GetAssociation:output_type -> slurm.GetAssociationResp - 10, // 10: slurm.SlurmService.ListAccounts:output_type -> slurm.ListAccountsResp - 11, // 11: slurm.SlurmService.GetAccount:output_type -> slurm.GetAccountResp - 6, // [6:12] is the sub-list for method output_type - 0, // [0:6] is the sub-list for method input_type + 6, // 6: slurm.SlurmService.ListQoss:input_type -> slurm.ListQossReq + 7, // 7: slurm.SlurmService.ListUsers:output_type -> slurm.ListUsersResp + 8, // 8: slurm.SlurmService.GetUser:output_type -> slurm.GetUserResp + 9, // 9: slurm.SlurmService.ListAssociations:output_type -> slurm.ListAssociationsResp + 10, // 10: slurm.SlurmService.GetAssociation:output_type -> slurm.GetAssociationResp + 11, // 11: slurm.SlurmService.ListAccounts:output_type -> slurm.ListAccountsResp + 12, // 12: slurm.SlurmService.GetAccount:output_type -> slurm.GetAccountResp + 13, // 13: slurm.SlurmService.ListQoss:output_type -> slurm.ListQossResp + 7, // [7:14] is the sub-list for method output_type + 0, // [0:7] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name @@ -101,6 +109,7 @@ func file_idl_slurm_proto_init() { file_idl_slurmdb_user_proto_init() file_idl_slurmdb_assoc_proto_init() file_idl_slurmdb_account_proto_init() + file_idl_slurmdb_qos_proto_init() type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/adaptor/pcm_slurm/gen/idl/slurm.pb.gw.go b/adaptor/pcm_slurm/gen/idl/slurm.pb.gw.go index dc31f233..47c93bc2 100644 --- a/adaptor/pcm_slurm/gen/idl/slurm.pb.gw.go +++ b/adaptor/pcm_slurm/gen/idl/slurm.pb.gw.go @@ -247,6 +247,42 @@ func local_request_SlurmService_GetAccount_0(ctx context.Context, marshaler runt } +var ( + filter_SlurmService_ListQoss_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_SlurmService_ListQoss_0(ctx context.Context, marshaler runtime.Marshaler, client SlurmServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListQossReq + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SlurmService_ListQoss_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ListQoss(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SlurmService_ListQoss_0(ctx context.Context, marshaler runtime.Marshaler, server SlurmServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListQossReq + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SlurmService_ListQoss_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ListQoss(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterSlurmServiceHandlerServer registers the http handlers for service SlurmService to "mux". // UnaryRPC :call SlurmServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -403,6 +439,31 @@ func RegisterSlurmServiceHandlerServer(ctx context.Context, mux *runtime.ServeMu }) + mux.Handle("GET", pattern_SlurmService_ListQoss_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/slurm.SlurmService/ListQoss", runtime.WithHTTPPathPattern("/apis/slurm/listQoss")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SlurmService_ListQoss_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SlurmService_ListQoss_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -576,6 +637,28 @@ func RegisterSlurmServiceHandlerClient(ctx context.Context, mux *runtime.ServeMu }) + mux.Handle("GET", pattern_SlurmService_ListQoss_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/slurm.SlurmService/ListQoss", runtime.WithHTTPPathPattern("/apis/slurm/listQoss")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SlurmService_ListQoss_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SlurmService_ListQoss_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -591,6 +674,8 @@ var ( pattern_SlurmService_ListAccounts_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"apis", "slurm", "listAccounts"}, "")) pattern_SlurmService_GetAccount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"apis", "slurm", "getAccount"}, "")) + + pattern_SlurmService_ListQoss_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"apis", "slurm", "listQoss"}, "")) ) var ( @@ -605,4 +690,6 @@ var ( forward_SlurmService_ListAccounts_0 = runtime.ForwardResponseMessage forward_SlurmService_GetAccount_0 = runtime.ForwardResponseMessage + + forward_SlurmService_ListQoss_0 = runtime.ForwardResponseMessage ) diff --git a/adaptor/pcm_slurm/gen/idl/slurm_grpc.pb.go b/adaptor/pcm_slurm/gen/idl/slurm_grpc.pb.go index 7e4cdec6..b5dcd0bb 100644 --- a/adaptor/pcm_slurm/gen/idl/slurm_grpc.pb.go +++ b/adaptor/pcm_slurm/gen/idl/slurm_grpc.pb.go @@ -34,6 +34,8 @@ type SlurmServiceClient interface { ListAccounts(ctx context.Context, in *ListAccountsReq, opts ...grpc.CallOption) (*ListAccountsResp, error) // get specific account info from slurmdb GetAccount(ctx context.Context, in *GetAccountReq, opts ...grpc.CallOption) (*GetAccountResp, error) + // list all qos info from slurmdb + ListQoss(ctx context.Context, in *ListQossReq, opts ...grpc.CallOption) (*ListQossResp, error) } type slurmServiceClient struct { @@ -98,6 +100,15 @@ func (c *slurmServiceClient) GetAccount(ctx context.Context, in *GetAccountReq, return out, nil } +func (c *slurmServiceClient) ListQoss(ctx context.Context, in *ListQossReq, opts ...grpc.CallOption) (*ListQossResp, error) { + out := new(ListQossResp) + err := c.cc.Invoke(ctx, "/slurm.SlurmService/ListQoss", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // SlurmServiceServer is the server API for SlurmService service. // All implementations must embed UnimplementedSlurmServiceServer // for forward compatibility @@ -114,6 +125,8 @@ type SlurmServiceServer interface { ListAccounts(context.Context, *ListAccountsReq) (*ListAccountsResp, error) // get specific account info from slurmdb GetAccount(context.Context, *GetAccountReq) (*GetAccountResp, error) + // list all qos info from slurmdb + ListQoss(context.Context, *ListQossReq) (*ListQossResp, error) mustEmbedUnimplementedSlurmServiceServer() } @@ -139,6 +152,9 @@ func (UnimplementedSlurmServiceServer) ListAccounts(context.Context, *ListAccoun func (UnimplementedSlurmServiceServer) GetAccount(context.Context, *GetAccountReq) (*GetAccountResp, error) { return nil, status.Errorf(codes.Unimplemented, "method GetAccount not implemented") } +func (UnimplementedSlurmServiceServer) ListQoss(context.Context, *ListQossReq) (*ListQossResp, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListQoss not implemented") +} func (UnimplementedSlurmServiceServer) mustEmbedUnimplementedSlurmServiceServer() {} // UnsafeSlurmServiceServer may be embedded to opt out of forward compatibility for this service. @@ -260,6 +276,24 @@ func _SlurmService_GetAccount_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _SlurmService_ListQoss_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListQossReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SlurmServiceServer).ListQoss(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/slurm.SlurmService/ListQoss", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SlurmServiceServer).ListQoss(ctx, req.(*ListQossReq)) + } + return interceptor(ctx, in, info, handler) +} + // SlurmService_ServiceDesc is the grpc.ServiceDesc for SlurmService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -291,6 +325,10 @@ var SlurmService_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetAccount", Handler: _SlurmService_GetAccount_Handler, }, + { + MethodName: "ListQoss", + Handler: _SlurmService_ListQoss_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "idl/slurm.proto", diff --git a/adaptor/pcm_slurm/gen/idl/slurmdb_qos.pb.go b/adaptor/pcm_slurm/gen/idl/slurmdb_qos.pb.go index 9379a99e..528e5f24 100644 --- a/adaptor/pcm_slurm/gen/idl/slurmdb_qos.pb.go +++ b/adaptor/pcm_slurm/gen/idl/slurmdb_qos.pb.go @@ -322,6 +322,100 @@ func (x *QosInfo) GetUsageThres() float64 { return 0 } +type ListQossReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SlurmVersion SlurmVersion `protobuf:"varint,1,opt,name=slurm_version,json=slurmVersion,proto3,enum=slurm.SlurmVersion" json:"slurm_version,omitempty"` +} + +func (x *ListQossReq) Reset() { + *x = ListQossReq{} + if protoimpl.UnsafeEnabled { + mi := &file_idl_slurmdb_qos_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListQossReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListQossReq) ProtoMessage() {} + +func (x *ListQossReq) ProtoReflect() protoreflect.Message { + mi := &file_idl_slurmdb_qos_proto_msgTypes[2] + 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 ListQossReq.ProtoReflect.Descriptor instead. +func (*ListQossReq) Descriptor() ([]byte, []int) { + return file_idl_slurmdb_qos_proto_rawDescGZIP(), []int{2} +} + +func (x *ListQossReq) GetSlurmVersion() SlurmVersion { + if x != nil { + return x.SlurmVersion + } + return SlurmVersion_tianhe +} + +type ListQossResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + QosInfos []*QosInfo `protobuf:"bytes,1,rep,name=qos_infos,json=qosInfos,proto3" json:"qos_infos,omitempty"` +} + +func (x *ListQossResp) Reset() { + *x = ListQossResp{} + if protoimpl.UnsafeEnabled { + mi := &file_idl_slurmdb_qos_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListQossResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListQossResp) ProtoMessage() {} + +func (x *ListQossResp) ProtoReflect() protoreflect.Message { + mi := &file_idl_slurmdb_qos_proto_msgTypes[3] + 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 ListQossResp.ProtoReflect.Descriptor instead. +func (*ListQossResp) Descriptor() ([]byte, []int) { + return file_idl_slurmdb_qos_proto_rawDescGZIP(), []int{3} +} + +func (x *ListQossResp) GetQosInfos() []*QosInfo { + if x != nil { + return x.QosInfos + } + return nil +} + var File_idl_slurmdb_qos_proto protoreflect.FileDescriptor var file_idl_slurmdb_qos_proto_rawDesc = []byte{ @@ -386,9 +480,17 @@ var file_idl_slurmdb_qos_proto_rawDesc = []byte{ 0x73, 0x61, 0x67, 0x65, 0x46, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x1b, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0b, 0x75, 0x73, 0x61, 0x67, 0x65, 0x46, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x75, 0x73, 0x61, 0x67, 0x65, 0x54, 0x68, 0x72, 0x65, 0x73, 0x18, 0x1c, 0x20, 0x01, 0x28, - 0x01, 0x52, 0x0a, 0x75, 0x73, 0x61, 0x67, 0x65, 0x54, 0x68, 0x72, 0x65, 0x73, 0x42, 0x0a, 0x5a, - 0x08, 0x2f, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x01, 0x52, 0x0a, 0x75, 0x73, 0x61, 0x67, 0x65, 0x54, 0x68, 0x72, 0x65, 0x73, 0x22, 0x47, 0x0a, + 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x51, 0x6f, 0x73, 0x73, 0x52, 0x65, 0x71, 0x12, 0x38, 0x0a, 0x0d, + 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x13, 0x2e, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x2e, 0x53, 0x6c, 0x75, 0x72, + 0x6d, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x56, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x3b, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x51, 0x6f, + 0x73, 0x73, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2b, 0x0a, 0x09, 0x71, 0x6f, 0x73, 0x5f, 0x69, 0x6e, + 0x66, 0x6f, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x73, 0x6c, 0x75, 0x72, + 0x6d, 0x2e, 0x51, 0x6f, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x71, 0x6f, 0x73, 0x49, 0x6e, + 0x66, 0x6f, 0x73, 0x42, 0x0a, 0x5a, 0x08, 0x2f, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x70, 0x62, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -403,18 +505,23 @@ func file_idl_slurmdb_qos_proto_rawDescGZIP() []byte { return file_idl_slurmdb_qos_proto_rawDescData } -var file_idl_slurmdb_qos_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_idl_slurmdb_qos_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_idl_slurmdb_qos_proto_goTypes = []interface{}{ (*QosUsageInfo)(nil), // 0: slurm.QosUsageInfo (*QosInfo)(nil), // 1: slurm.QosInfo + (*ListQossReq)(nil), // 2: slurm.ListQossReq + (*ListQossResp)(nil), // 3: slurm.ListQossResp + (SlurmVersion)(0), // 4: slurm.SlurmVersion } var file_idl_slurmdb_qos_proto_depIdxs = []int32{ 0, // 0: slurm.QosInfo.usage:type_name -> slurm.QosUsageInfo - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 4, // 1: slurm.ListQossReq.slurm_version:type_name -> slurm.SlurmVersion + 1, // 2: slurm.ListQossResp.qos_infos:type_name -> slurm.QosInfo + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name } func init() { file_idl_slurmdb_qos_proto_init() } @@ -448,6 +555,30 @@ func file_idl_slurmdb_qos_proto_init() { return nil } } + file_idl_slurmdb_qos_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListQossReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_idl_slurmdb_qos_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListQossResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -455,7 +586,7 @@ func file_idl_slurmdb_qos_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_idl_slurmdb_qos_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 4, NumExtensions: 0, NumServices: 0, }, diff --git a/adaptor/pcm_slurm/gen/openapiv2/idl/slurm.swagger.json b/adaptor/pcm_slurm/gen/openapiv2/idl/slurm.swagger.json index e85c1680..03416bbf 100644 --- a/adaptor/pcm_slurm/gen/openapiv2/idl/slurm.swagger.json +++ b/adaptor/pcm_slurm/gen/openapiv2/idl/slurm.swagger.json @@ -284,6 +284,17 @@ } } }, + "slurmListQossResp": { + "type": "object", + "properties": { + "qosInfos": { + "type": "array", + "items": { + "$ref": "#/definitions/slurmQosInfo" + } + } + } + }, "slurmListUsersResp": { "type": "object", "properties": { diff --git a/adaptor/pcm_slurm/idl/slurm.proto b/adaptor/pcm_slurm/idl/slurm.proto index 2c7e5eeb..2400e30c 100644 --- a/adaptor/pcm_slurm/idl/slurm.proto +++ b/adaptor/pcm_slurm/idl/slurm.proto @@ -6,6 +6,7 @@ import "idl/node.proto"; import "idl/slurmdb_user.proto"; import "idl/slurmdb_assoc.proto"; import "idl/slurmdb_account.proto"; +import "idl/slurmdb_qos.proto"; // Slurm Services @@ -29,4 +30,7 @@ service SlurmService { // get specific account info from slurmdb rpc GetAccount(GetAccountReq) returns (GetAccountResp); + // list all qos info from slurmdb + rpc ListQoss(ListQossReq) returns (ListQossResp); + } diff --git a/adaptor/pcm_slurm/idl/slurm.yaml b/adaptor/pcm_slurm/idl/slurm.yaml index d00d0305..56e9f552 100644 --- a/adaptor/pcm_slurm/idl/slurm.yaml +++ b/adaptor/pcm_slurm/idl/slurm.yaml @@ -15,4 +15,6 @@ http: get: "/apis/slurm/listAccounts" - selector: slurm.SlurmService.GetAccount get: "/apis/slurm/getAccount" + - selector: slurm.SlurmService.ListQoss + get: "/apis/slurm/listQoss" diff --git a/adaptor/pcm_slurm/idl/slurmdb_qos.proto b/adaptor/pcm_slurm/idl/slurmdb_qos.proto index 50c29c88..6ee0e044 100644 --- a/adaptor/pcm_slurm/idl/slurmdb_qos.proto +++ b/adaptor/pcm_slurm/idl/slurmdb_qos.proto @@ -39,3 +39,11 @@ message QosInfo{ double usageFactor = 27 ; double usageThres = 28 ; } + +message ListQossReq{ + SlurmVersion slurm_version = 1; +} + +message ListQossResp { + repeated QosInfo qos_infos =1; +} diff --git a/adaptor/pcm_slurm/server/slurm.go b/adaptor/pcm_slurm/server/slurm.go index 537377d1..f0867ef8 100644 --- a/adaptor/pcm_slurm/server/slurm.go +++ b/adaptor/pcm_slurm/server/slurm.go @@ -71,3 +71,13 @@ func (s *Server) GetAccount(ctx context.Context, req *slurmpb.GetAccountReq) (*s } return resp, nil } + +// ListQoss return all slurm qos +func (s *Server) ListQoss(ctx context.Context, req *slurmpb.ListQossReq) (*slurmpb.ListQossResp, error) { + resp, err := ListQoss(ctx, req) + if err != nil { + glog.Errorf("ListSlurmQoss error %+v", err) + return nil, status.Errorf(codes.Internal, err.Error()) + } + return resp, nil +} diff --git a/adaptor/pcm_slurm/server/slurmImpl.go b/adaptor/pcm_slurm/server/slurmImpl.go index e8434402..dc569e8f 100644 --- a/adaptor/pcm_slurm/server/slurmImpl.go +++ b/adaptor/pcm_slurm/server/slurmImpl.go @@ -59,3 +59,12 @@ func GetAccount(ctx context.Context, req *pbslurm.GetAccountReq) (*pbslurm.GetAc resp, _ := slurm.GetAccount(ctx, req) return resp, nil } + +func ListQoss(ctx context.Context, req *pbslurm.ListQossReq) (*pbslurm.ListQossResp, error) { + slurm, _ := slurmer.SelectSlurmVersion(req.SlurmVersion) + if slurm == nil { + return nil, nil + } + resp, _ := slurm.ListQoss(ctx, req) + return resp, nil +} diff --git a/adaptor/pcm_slurm/service/slurmdb_qos.go b/adaptor/pcm_slurm/service/slurmdb_qos.go new file mode 100644 index 00000000..773d42a4 --- /dev/null +++ b/adaptor/pcm_slurm/service/slurmdb_qos.go @@ -0,0 +1,158 @@ +package slurmer + +import "C" +import pbslurm "code.gitlink.org.cn/JCCE/PCM.git/adaptor/pcm_slurm/gen/idl" + +/* +#cgo LDFLAGS: -lslurmdb + +#include +#include +#include +#include +#include +#include +#include +#include + +typedef struct slurmdb_qos_rec { + char *description; + uint32_t id; + uint32_t flags; + uint32_t grace_time; + uint64_t grp_cpu_mins; + uint64_t grp_cpu_run_mins; + uint32_t grp_cpus; + uint32_t grp_jobs; + uint32_t grp_mem; + uint32_t grp_nodes; + uint32_t grp_submit_jobs; + uint32_t grp_wall; + uint64_t max_cpu_mins_pj; + uint64_t max_cpu_run_mins_pu; + uint32_t max_cpus_pj; + uint32_t max_cpus_pu; + uint32_t max_jobs_pu; + uint32_t max_nodes_pj; + uint32_t max_nodes_pu; + uint32_t max_submit_jobs_pu; + uint32_t max_wall_pj; + char *name; + bitstr_t *preempt_bitstr; + List preempt_list; + uint16_t preempt_mode; + uint32_t priority; + assoc_mgr_qos_usage_t *usage; + double usage_factor; + double usage_thres; +} slurmdb_qos_rec_a; + +typedef struct qos_info { + uint32_t record_count; + slurmdb_qos_rec_t *array; +} qos_info_t; + +struct qos_info get_qos_list() { + struct qos_info qosinfo; + + slurmdb_qos_cond_t *qos_cond = NULL; + void *conn = slurmdb_connection_get(); + List qoslist = slurmdb_qos_get(conn, qos_cond); + + + uint16_t size = slurm_list_count(qoslist); + qosinfo.record_count = size; + qosinfo.array = malloc(size * sizeof(slurmdb_qos_rec_t)); + //slurmdb_qos_rec_t qosArray[size]; + + slurmdb_qos_rec_t *rec = NULL; + ListIterator itr = slurm_list_iterator_create(qoslist); + + int i = 0; + while ((rec = slurm_list_next(itr))) { + qosinfo.array[i] = *rec; + i++; + } + slurmdb_connection_close(&conn); + slurm_list_destroy(qoslist); + + return qosinfo; +} + +struct slurmdb_qos_rec *qos_from_list(struct qos_info *qos_rec_t, int i) { + return (struct slurmdb_qos_rec *) &qos_rec_t->array[i]; +} +*/ +import "C" +import ( + "context" +) + +type Slurmdb_qos_rec struct { + Description string + Id uint32 + Flags uint32 + GraceTime uint32 + GrpCpuMins uint64 + GrpCpuRunMins uint64 + GrpCpus uint32 + GrpJobs uint32 + GrpMem uint32 + GrpNodes uint32 + GrpSubmitJobs uint32 + MaxCpuMinsPj uint64 + MaxCpuRunMinsPu uint64 + MaxCpusPj uint32 + MaxCpusPu uint32 + MaxJobsPu uint32 + MaxNodesPj uint32 + MaxNodesPu uint32 + MaxSubmitJobsPu uint32 + MaxWallPj uint32 + Name string + preemptList []string + preempt_mode uint16 + priority uint32 + usage_factor float64 + usage_thres float64 +} + +type QosInfoMsg struct { + RecordCount uint32 + QosList []pbslurm.QosInfo +} + +func QosDescriptorConvertCToGo(cStruct *C.struct_slurmdb_qos_rec) pbslurm.QosInfo { + var goStruct pbslurm.QosInfo + goStruct.Name = C.GoString(cStruct.name) + return goStruct +} + +func GetQosInfo() QosInfoMsg { + var goQosBuffer QosInfoMsg + cQosBuffer := C.get_qos_list() + goQosBuffer.RecordCount = uint32(cQosBuffer.record_count) + goQosBuffer.QosList = make([]pbslurm.QosInfo, cQosBuffer.record_count, cQosBuffer.record_count) + + for i := uint32(0); i < goQosBuffer.RecordCount; i++ { + qos := C.qos_from_list(&cQosBuffer, C.int(i)) + goQos := QosDescriptorConvertCToGo(qos) + goQosBuffer.QosList[i] = goQos + } + return goQosBuffer +} + +func (slurmStruct SlurmStruct) ListQoss(ctx context.Context, req *pbslurm.ListQossReq) (*pbslurm.ListQossResp, error) { + + qosList := GetQosInfo() + + resp := pbslurm.ListQossResp{} + for _, qos := range qosList.QosList { + qosInfoResult := qos + //userInfoResult.Name = user.Name + + resp.QosInfos = append(resp.QosInfos, &qosInfoResult) + } + + return &resp, nil +} diff --git a/adaptor/pcm_slurm/service/slurmer.go b/adaptor/pcm_slurm/service/slurmer.go index f882f880..a295b8f3 100644 --- a/adaptor/pcm_slurm/service/slurmer.go +++ b/adaptor/pcm_slurm/service/slurmer.go @@ -12,6 +12,7 @@ type Slurmer interface { GetAssociation(ctx context.Context, req *pbslurm.GetAssociationReq) (resp *pbslurm.GetAssociationResp, err error) //get specific slurm associations ListAccounts(ctx context.Context, req *pbslurm.ListAccountsReq) (resp *pbslurm.ListAccountsResp, err error) //list slurm accounts GetAccount(ctx context.Context, req *pbslurm.GetAccountReq) (resp *pbslurm.GetAccountResp, err error) //get specific slurm account + ListQoss(ctx context.Context, req *pbslurm.ListQossReq) (resp *pbslurm.ListQossResp, err error) //list slurm accounts } func SelectSlurmVersion(slurmVersion pbslurm.SlurmVersion) (slurmer Slurmer, err error) {