| @@ -3,6 +3,10 @@ package slurm; | |||
| option go_package = "/slurmpb"; | |||
| import "idl/slurm_node.proto"; | |||
| import "idl/slurm_partition.proto"; | |||
| import "idl/slurm_reservation.proto"; | |||
| import "idl/slurm_ping.proto"; | |||
| import "idl/slurmdb_cluster.proto"; | |||
| import "idl/slurmdb_user.proto"; | |||
| import "idl/slurmdb_assoc.proto"; | |||
| import "idl/slurmdb_account.proto"; | |||
| @@ -10,6 +14,7 @@ import "idl/slurmdb_qos.proto"; | |||
| import "idl/slurmdb_wckey.proto"; | |||
| // Slurm Services | |||
| service SlurmService { | |||
| @@ -51,4 +56,34 @@ service SlurmService { | |||
| // get specific wckey info from slurmdb | |||
| rpc GetWckey(GetWckeyReq) returns (GetWckeyResp); | |||
| // list all Cluster from slurmdb | |||
| rpc ListClusters(ListClustersReq) returns (ListClustersResp); | |||
| // get specific user info from slurmdb | |||
| rpc GetCluster(GetClusterReq) returns (GetClusterResp); | |||
| // add new user | |||
| rpc AddCluster(AddClusterReq) returns (AddClusterResp); | |||
| // delete specific user | |||
| rpc DeleteCluster(DeleteClusterReq) returns (DeleteClusterResp); | |||
| // list all Node from slurm | |||
| rpc ListNodes(ListNodesReq) returns (ListNodesResp); | |||
| // get specific Node info from slurm | |||
| rpc GetNode(GetNodeReq) returns (GetNodeResp); | |||
| // list all Partition from slurm | |||
| rpc ListPartitions(ListPartitionsReq) returns (ListPartitionsResp); | |||
| // get specific Partition info from slurm | |||
| rpc GetPartition(GetPartitionReq) returns (GetPartitionResp); | |||
| // list all Reservation from slurm | |||
| rpc ListReservations(ListReservationsReq) returns (ListReservationsResp); | |||
| // get specific Reservation info from slurm | |||
| rpc GetReservation(GetReservationReq) returns (GetReservationResp); | |||
| } | |||
| @@ -29,4 +29,23 @@ http: | |||
| get: "/apis/slurm/listWckeys" | |||
| - selector: slurm.SlurmService.GetWckey | |||
| get: "/apis/slurm/getWckey" | |||
| - selector: slurm.SlurmService.ListClusters | |||
| get: "/apis/slurm/listClusters" | |||
| - selector: slurm.SlurmService.GetCluster | |||
| get: "/apis/slurm/getCluster" | |||
| - selector: slurm.SlurmService.AddCluster | |||
| post: "/apis/slurm/addCluster" | |||
| - selector: slurm.SlurmService.DeleteCluster | |||
| delete: "/apis/slurm/deleteCluster" | |||
| - selector: slurm.SlurmService.ListNodes | |||
| get: "/apis/slurm/listNodes" | |||
| - selector: slurm.SlurmService.GetNode | |||
| get: "/apis/slurm/getNode" | |||
| - selector: slurm.SlurmService.ListPartitions | |||
| get: "/apis/slurm/listPartitions" | |||
| - selector: slurm.SlurmService.GetPartition | |||
| get: "/apis/slurm/getPartition" | |||
| - selector: slurm.SlurmService.ListReservations | |||
| get: "/apis/slurm/listReservations" | |||
| - selector: slurm.SlurmService.GetReservation | |||
| get: "/apis/slurm/getReservation" | |||
| @@ -141,3 +141,103 @@ func (s *Server) GetWckey(ctx context.Context, req *slurmpb.GetWckeyReq) (*slurm | |||
| } | |||
| return resp, nil | |||
| } | |||
| // ListUsers return all slurm Clusters | |||
| func (s *Server) ListClusters(ctx context.Context, req *slurmpb.ListClustersReq) (*slurmpb.ListClustersResp, error) { | |||
| resp, err := ListClusters(ctx, req) | |||
| if err != nil { | |||
| glog.Errorf("ListSlurmUsers error %+v", err) | |||
| return nil, status.Errorf(codes.Internal, err.Error()) | |||
| } | |||
| return resp, nil | |||
| } | |||
| // GetUser return specific slurm user | |||
| func (s *Server) GetCluster(ctx context.Context, req *slurmpb.GetClusterReq) (*slurmpb.GetClusterResp, error) { | |||
| resp, err := GetCluster(ctx, req) | |||
| if err != nil { | |||
| glog.Errorf("GetSlurmUser error %+v", err) | |||
| return nil, status.Errorf(codes.Internal, err.Error()) | |||
| } | |||
| return resp, nil | |||
| } | |||
| // DeleteUser delete specific slurm user | |||
| func (s *Server) DeleteCluster(ctx context.Context, req *slurmpb.DeleteClusterReq) (*slurmpb.DeleteClusterResp, error) { | |||
| resp, err := DeleteCluster(ctx, req) | |||
| if err != nil { | |||
| glog.Errorf("DeleteSlurmUser error %+v", err) | |||
| return nil, status.Errorf(codes.Internal, err.Error()) | |||
| } | |||
| return resp, nil | |||
| } | |||
| // AddCluster add slurm user | |||
| func (s *Server) AddCluster(ctx context.Context, req *slurmpb.AddClusterReq) (*slurmpb.AddClusterResp, error) { | |||
| resp, err := AddCluster(ctx, req) | |||
| if err != nil { | |||
| glog.Errorf("AddSlurmCluster error %+v", err) | |||
| return nil, status.Errorf(codes.Internal, err.Error()) | |||
| } | |||
| return resp, nil | |||
| } | |||
| // GetNode return specific slurm user | |||
| func (s *Server) GetNode(ctx context.Context, req *slurmpb.GetNodeReq) (*slurmpb.GetNodeResp, error) { | |||
| resp, err := GetNode(ctx, req) | |||
| if err != nil { | |||
| glog.Errorf("GetSlurmUser error %+v", err) | |||
| return nil, status.Errorf(codes.Internal, err.Error()) | |||
| } | |||
| return resp, nil | |||
| } | |||
| // ListUsers return all slurm Clusters | |||
| func (s *Server) ListNodes(ctx context.Context, req *slurmpb.ListNodesReq) (*slurmpb.ListNodesResp, error) { | |||
| resp, err := ListNodes(ctx, req) | |||
| if err != nil { | |||
| glog.Errorf("ListSlurmNodes error %+v", err) | |||
| return nil, status.Errorf(codes.Internal, err.Error()) | |||
| } | |||
| return resp, nil | |||
| } | |||
| // ListUsers return all slurm Clusters | |||
| func (s *Server) ListPartitions(ctx context.Context, req *slurmpb.ListPartitionsReq) (*slurmpb.ListPartitionsResp, error) { | |||
| resp, err := ListPartitions(ctx, req) | |||
| if err != nil { | |||
| glog.Errorf("ListPartitions error %+v", err) | |||
| return nil, status.Errorf(codes.Internal, err.Error()) | |||
| } | |||
| return resp, nil | |||
| } | |||
| // GetNode return specific slurm user | |||
| func (s *Server) GetPartition(ctx context.Context, req *slurmpb.GetPartitionReq) (*slurmpb.GetPartitionResp, error) { | |||
| resp, err := GetPartition(ctx, req) | |||
| if err != nil { | |||
| glog.Errorf("GetPartition error %+v", err) | |||
| return nil, status.Errorf(codes.Internal, err.Error()) | |||
| } | |||
| return resp, nil | |||
| } | |||
| // GetReservation return specific slurm user | |||
| func (s *Server) GetReservation(ctx context.Context, req *slurmpb.GetReservationReq) (*slurmpb.GetReservationResp, error) { | |||
| resp, err := GetReservation(ctx, req) | |||
| if err != nil { | |||
| glog.Errorf("GetPartition error %+v", err) | |||
| return nil, status.Errorf(codes.Internal, err.Error()) | |||
| } | |||
| return resp, nil | |||
| } | |||
| // ListUsers return all slurm Clusters | |||
| func (s *Server) ListReservations(ctx context.Context, req *slurmpb.ListReservationsReq) (*slurmpb.ListReservationsResp, error) { | |||
| resp, err := ListReservations(ctx, req) | |||
| if err != nil { | |||
| glog.Errorf("ListReservations error %+v", err) | |||
| return nil, status.Errorf(codes.Internal, err.Error()) | |||
| } | |||
| return resp, nil | |||
| } | |||
| @@ -122,3 +122,93 @@ func GetWckey(ctx context.Context, req *pbslurm.GetWckeyReq) (*pbslurm.GetWckeyR | |||
| resp, _ := slurm.GetWckey(ctx, req) | |||
| return resp, nil | |||
| } | |||
| func ListClusters(ctx context.Context, req *pbslurm.ListClustersReq) (*pbslurm.ListClustersResp, error) { | |||
| slurm, _ := slurmer.SelectSlurmVersion(req.SlurmVersion) | |||
| if slurm == nil { | |||
| return nil, nil | |||
| } | |||
| resp, _ := slurm.ListClusters(ctx, req) | |||
| return resp, nil | |||
| } | |||
| func GetCluster(ctx context.Context, req *pbslurm.GetClusterReq) (*pbslurm.GetClusterResp, error) { | |||
| slurm, _ := slurmer.SelectSlurmVersion(req.SlurmVersion) | |||
| if slurm == nil { | |||
| return nil, nil | |||
| } | |||
| resp, _ := slurm.GetCluster(ctx, req) | |||
| return resp, nil | |||
| } | |||
| func DeleteCluster(ctx context.Context, req *pbslurm.DeleteClusterReq) (*pbslurm.DeleteClusterResp, error) { | |||
| slurm, _ := slurmer.SelectSlurmVersion(req.SlurmVersion) | |||
| if slurm == nil { | |||
| return nil, nil | |||
| } | |||
| resp, _ := slurm.DeleteCluster(ctx, req) | |||
| return resp, nil | |||
| } | |||
| func AddCluster(ctx context.Context, req *pbslurm.AddClusterReq) (*pbslurm.AddClusterResp, error) { | |||
| slurm, _ := slurmer.SelectSlurmVersion(req.SlurmVersion) | |||
| if slurm == nil { | |||
| return nil, nil | |||
| } | |||
| resp, _ := slurm.AddCluster(ctx, req) | |||
| return resp, nil | |||
| } | |||
| func ListNodes(ctx context.Context, req *pbslurm.ListNodesReq) (*pbslurm.ListNodesResp, error) { | |||
| slurm, _ := slurmer.SelectSlurmVersion(req.SlurmVersion) | |||
| if slurm == nil { | |||
| return nil, nil | |||
| } | |||
| resp, _ := slurm.ListNodes(ctx, req) | |||
| return resp, nil | |||
| } | |||
| func GetNode(ctx context.Context, req *pbslurm.GetNodeReq) (*pbslurm.GetNodeResp, error) { | |||
| slurm, _ := slurmer.SelectSlurmVersion(req.SlurmVersion) | |||
| if slurm == nil { | |||
| return nil, nil | |||
| } | |||
| resp, _ := slurm.GetNode(ctx, req) | |||
| return resp, nil | |||
| } | |||
| func ListPartitions(ctx context.Context, req *pbslurm.ListPartitionsReq) (*pbslurm.ListPartitionsResp, error) { | |||
| slurm, _ := slurmer.SelectSlurmVersion(req.SlurmVersion) | |||
| if slurm == nil { | |||
| return nil, nil | |||
| } | |||
| resp, _ := slurm.ListPartitions(ctx, req) | |||
| return resp, nil | |||
| } | |||
| func GetPartition(ctx context.Context, req *pbslurm.GetPartitionReq) (*pbslurm.GetPartitionResp, error) { | |||
| slurm, _ := slurmer.SelectSlurmVersion(req.SlurmVersion) | |||
| if slurm == nil { | |||
| return nil, nil | |||
| } | |||
| resp, _ := slurm.GetPartition(ctx, req) | |||
| return resp, nil | |||
| } | |||
| func GetReservation(ctx context.Context, req *pbslurm.GetReservationReq) (*pbslurm.GetReservationResp, error) { | |||
| slurm, _ := slurmer.SelectSlurmVersion(req.SlurmVersion) | |||
| if slurm == nil { | |||
| return nil, nil | |||
| } | |||
| resp, _ := slurm.GetReservation(ctx, req) | |||
| return resp, nil | |||
| } | |||
| func ListReservations(ctx context.Context, req *pbslurm.ListReservationsReq) (*pbslurm.ListReservationsResp, error) { | |||
| slurm, _ := slurmer.SelectSlurmVersion(req.SlurmVersion) | |||
| if slurm == nil { | |||
| return nil, nil | |||
| } | |||
| resp, _ := slurm.ListReservations(ctx, req) | |||
| return resp, nil | |||
| } | |||
| @@ -149,7 +149,7 @@ func Get_all_nodes() NodeInfoMsg { | |||
| return go_node_buffer | |||
| } | |||
| func NodeDescriptorConvertCToGo(cStruct *C.struct_slurmdb_account_rec) pbslurm.NodeInfo { | |||
| func NodeDescriptorConvertCToGo(cStruct *C.struct_node_info) pbslurm.NodeInfo { | |||
| var goStruct pbslurm.NodeInfo | |||
| goStruct.Name = C.GoString(cStruct.name) | |||
| return goStruct | |||
| @@ -160,9 +160,8 @@ func GetNodeInfo() NodeInfoMsg { | |||
| cNodeBuffer := C.get_node_info() | |||
| goNodeBuffer.RecordCount = uint32(cNodeBuffer.record_count) | |||
| goNodeBuffer.NodeInfoList = make([]pbslurm.NodeInfo, cNodeBuffer.record_count, cNodeBuffer.record_count) | |||
| for i := uint32(0); i < goNodeBuffer.RecordCount; i++ { | |||
| Node := C.node_from_list(&cNodeBuffer, C.int(i)) | |||
| Node := C.node_from_list(cNodeBuffer, C.int(i)) | |||
| goNode := NodeDescriptorConvertCToGo(Node) | |||
| goNodeBuffer.NodeInfoList[i] = goNode | |||
| } | |||
| @@ -107,14 +107,14 @@ func GetPartitionsInfo() PartitionInfoMsg { | |||
| goPartitionBuffer.PartitionInfoList = make([]pbslurm.PartitionInfo, cPartitionBuffer.record_count, cPartitionBuffer.record_count) | |||
| for i := uint32(0); i < goPartitionBuffer.RecordCount; i++ { | |||
| partition := C.partition_from_list(&cPartitionBuffer, C.int(i)) | |||
| partition := C.partition_from_list(cPartitionBuffer, C.int(i)) | |||
| goPartition := PartitionDescriptorConvertCToGo(partition) | |||
| goPartitionBuffer.PartitionInfoList[i] = goPartition | |||
| } | |||
| return goPartitionBuffer | |||
| } | |||
| func PartitionDescriptorConvertCToGo(cStruct *C.struct_slurmdb_partition_rec) pbslurm.PartitionInfo { | |||
| func PartitionDescriptorConvertCToGo(cStruct *C.struct_partition_info) pbslurm.PartitionInfo { | |||
| var goStruct pbslurm.PartitionInfo | |||
| goStruct.Name = C.GoString(cStruct.name) | |||
| return goStruct | |||
| @@ -95,19 +95,19 @@ func (slurmStruct SlurmStruct) ListReservations(ctx context.Context, req *pbslur | |||
| func GetReservationsInfo() ReservationInfoMsg { | |||
| var goReservationBuffer ReservationInfoMsg | |||
| cReservationBuffer := C.get_reservation_info() | |||
| cReservationBuffer := C.get_reserve_info() | |||
| goReservationBuffer.RecordCount = uint32(cReservationBuffer.record_count) | |||
| goReservationBuffer.ReservationList = make([]pbslurm.ReservationInfo, cReservationBuffer.record_count, cReservationBuffer.record_count) | |||
| for i := uint32(0); i < goReservationBuffer.RecordCount; i++ { | |||
| Reservation := C.reservation_from_list(&cReservationBuffer, C.int(i)) | |||
| Reservation := C.reservation_from_list(cReservationBuffer, C.int(i)) | |||
| goReservation := ReservationDescriptorConvertCToGo(Reservation) | |||
| goReservationBuffer.ReservationList[i] = goReservation | |||
| } | |||
| return goReservationBuffer | |||
| } | |||
| func ReservationDescriptorConvertCToGo(cStruct *C.struct_slurmdb_reservation_rec) pbslurm.ReservationInfo { | |||
| func ReservationDescriptorConvertCToGo(cStruct *C.struct_reserve_info) pbslurm.ReservationInfo { | |||
| var goStruct pbslurm.ReservationInfo | |||
| goStruct.Name = C.GoString(cStruct.name) | |||
| return goStruct | |||
| @@ -24,7 +24,7 @@ type Slurmer interface { | |||
| DeleteCluster(ctx context.Context, req *pbslurm.DeleteClusterReq) (resp *pbslurm.DeleteClusterResp, err error) | |||
| AddCluster(ctx context.Context, req *pbslurm.AddClusterReq) (resp *pbslurm.AddClusterResp, err error) | |||
| ListNodes(ctx context.Context, req *pbslurm.ListNodesReq) (resp *pbslurm.ListNodesResp, err error) | |||
| GetNode(ctx context.Context, req *pbslurm.GetNodeResp) (resp *pbslurm.GetNodeResp, err error) | |||
| GetNode(ctx context.Context, req *pbslurm.GetNodeReq) (resp *pbslurm.GetNodeResp, err error) | |||
| ListPartitions(ctx context.Context, req *pbslurm.ListPartitionsReq) (resp *pbslurm.ListPartitionsResp, err error) | |||
| GetPartition(ctx context.Context, req *pbslurm.GetPartitionReq) (resp *pbslurm.GetPartitionResp, err error) | |||
| ListReservations(ctx context.Context, req *pbslurm.ListReservationsReq) (resp *pbslurm.ListReservationsResp, err error) | |||