added rpc

This commit is contained in:
tzwang 2024-09-20 11:15:00 +08:00
parent 1c76dc1687
commit 5ad743bd7d
5 changed files with 639 additions and 396 deletions

File diff suppressed because it is too large Load Diff

View File

@ -61,17 +61,18 @@ const (
HpcAC_StartInstanceService_FullMethodName = "/hpcAC.hpcAC/StartInstanceService"
HpcAC_StopInstanceService_FullMethodName = "/hpcAC.hpcAC/StopInstanceService"
HpcAC_CreateInstanceService_FullMethodName = "/hpcAC.hpcAC/CreateInstanceService"
HpcAC_GetImageList_FullMethodName = "/hpcAC.hpcAC/GetImageList"
)
// HpcACClient is the client API for HpcAC service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type HpcACClient interface {
//ListJob list all jobs
// ListJob list all jobs
ListJob(ctx context.Context, in *ListJobReq, opts ...grpc.CallOption) (*ListJobResp, error)
//ListHistoryJob list all history jobs
// ListHistoryJob list all history jobs
ListHistoryJob(ctx context.Context, in *ListHistoryJobReq, opts ...grpc.CallOption) (*ListHistoryJobResp, error)
//Submit job
// Submit job
SubmitJob(ctx context.Context, in *SubmitJobReq, opts ...grpc.CallOption) (*SubmitJobResp, error)
// ListJobManager list all job managers
ListJobManager(ctx context.Context, in *JobManagerReq, opts ...grpc.CallOption) (*ListJobManagerResp, error)
@ -79,32 +80,32 @@ type HpcACClient interface {
GetJobDetail(ctx context.Context, in *JobDetailReq, opts ...grpc.CallOption) (*GetJobDetailResp, error)
// DeleteJob delete job
DeleteJob(ctx context.Context, in *DeleteJobReq, opts ...grpc.CallOption) (*DeleteJobResp, error)
//FileContent 查看文件内容
// FileContent 查看文件内容
FileContent(ctx context.Context, in *FileDataReq, opts ...grpc.CallOption) (*FileContentResp, error)
//SelectQueueByUser 查询用户可访问队列列表
// SelectQueueByUser 查询用户可访问队列列表
SelectQueueByUser(ctx context.Context, in *QueueReq, opts ...grpc.CallOption) (*QueueResp, error)
//QueryQueueDetails 查询队列资源详细信息
// QueryQueueDetails 查询队列资源详细信息
QueryQueueDetails(ctx context.Context, in *QueueReq, opts ...grpc.CallOption) (*QueueDetailsResp, error)
///QueryUserQuotasLimit 查询用户资源限制信息
// /QueryUserQuotasLimit 查询用户资源限制信息
QueryUserQuotasLimit(ctx context.Context, in *QueueReq, opts ...grpc.CallOption) (*UserQuotasLimitResp, error)
//ParaStor Quota
// ParaStor Quota
ParaStorQuota(ctx context.Context, in *ParaStorQuotaReq, opts ...grpc.CallOption) (*ParaStorQuotaResp, error)
//WallTime
// WallTime
WallTime(ctx context.Context, in *WallTimeReq, opts ...grpc.CallOption) (*WallTimeResp, error)
//QueueJobs
// QueueJobs
QueueJobs(ctx context.Context, in *QueueJobsReq, opts ...grpc.CallOption) (*QueueJobsResp, error)
CpuCore(ctx context.Context, in *CpuCoreReq, opts ...grpc.CallOption) (*CpuCoreResp, error)
Jobs(ctx context.Context, in *JobsReq, opts ...grpc.CallOption) (*JobsResp, error)
HistoryJobDetail(ctx context.Context, in *HistoryJobDetailReq, opts ...grpc.CallOption) (*HistoryJobDetailResp, error)
// 曙光ac获取token
GetACToken(ctx context.Context, in *ACTokenReq, opts ...grpc.CallOption) (*TokenResp, error)
//曙光ac获取clusterid
// 曙光ac获取clusterid
GetACClusterId(ctx context.Context, in *ACClusterReq, opts ...grpc.CallOption) (*ClusterResp, error)
//获取曙光账号算力
// 获取曙光账号算力
GetComputingPower(ctx context.Context, in *ResourceReq, opts ...grpc.CallOption) (*CpResp, error)
//获取曙光账号cpu,内存,存储信息
// 获取曙光账号cpu,内存,存储信息
GetGeneralInfo(ctx context.Context, in *ResourceReq, opts ...grpc.CallOption) (*GiResp, error)
//曙光智算接口
// 曙光智算接口
SubmitPytorchTask(ctx context.Context, in *SubmitPytorchTaskReq, opts ...grpc.CallOption) (*SubmitTaskAiResp, error)
SubmitTensorflowTask(ctx context.Context, in *SubmitTensorflowTaskReq, opts ...grpc.CallOption) (*SubmitTaskAiResp, error)
GetImageListAi(ctx context.Context, in *GetImageListAiReq, opts ...grpc.CallOption) (*GetImageListAiResp, error)
@ -116,20 +117,21 @@ type HpcACClient interface {
GetInstanceLog(ctx context.Context, in *GetInstanceLogReq, opts ...grpc.CallOption) (*GetInstanceLogResp, error)
GetInstanceListAi(ctx context.Context, in *GetInstanceListReq, opts ...grpc.CallOption) (*GetInstanceListResp, error)
GetInferUrl(ctx context.Context, in *GetInferUrlReq, opts ...grpc.CallOption) (*GetInferUrlResp, error)
//曙光文件接口
// 曙光文件接口
GetFileList(ctx context.Context, in *GetFileListReq, opts ...grpc.CallOption) (*GetFileListResp, error)
GetFile(ctx context.Context, in *GetFileReq, opts ...grpc.CallOption) (*GetFileResp, error)
UploadFile(ctx context.Context, in *UploadFileReq, opts ...grpc.CallOption) (*UploadFileResp, error)
//用户资源
// 用户资源
GetUserInfo(ctx context.Context, in *GetUserInfoReq, opts ...grpc.CallOption) (*GetUserInfoResp, error)
GetMemberJobs(ctx context.Context, in *GetMemberJobsReq, opts ...grpc.CallOption) (*GetMemberJobsResp, error)
//容器
// 容器
GetNodeResources(ctx context.Context, in *GetNodeResourcesReq, opts ...grpc.CallOption) (*GetNodeResourcesResp, error)
GetInstanceServiceList(ctx context.Context, in *GetInstanceServiceListReq, opts ...grpc.CallOption) (*GetInstanceServiceListResp, error)
GetInstanceServiceDetail(ctx context.Context, in *GetInstanceServiceDetailReq, opts ...grpc.CallOption) (*GetInstanceServiceDetailResp, error)
StartInstanceService(ctx context.Context, in *StartInstanceServiceReq, opts ...grpc.CallOption) (*StartInstanceServiceResp, error)
StopInstanceService(ctx context.Context, in *StopInstanceServiceReq, opts ...grpc.CallOption) (*StopInstanceServiceResp, error)
CreateInstanceService(ctx context.Context, in *CreateInstanceServiceReq, opts ...grpc.CallOption) (*CreateInstanceServiceResp, error)
GetImageList(ctx context.Context, in *GetImageListReq, opts ...grpc.CallOption) (*GetImageListResp, error)
}
type hpcACClient struct {
@ -518,15 +520,24 @@ func (c *hpcACClient) CreateInstanceService(ctx context.Context, in *CreateInsta
return out, nil
}
func (c *hpcACClient) GetImageList(ctx context.Context, in *GetImageListReq, opts ...grpc.CallOption) (*GetImageListResp, error) {
out := new(GetImageListResp)
err := c.cc.Invoke(ctx, HpcAC_GetImageList_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// HpcACServer is the server API for HpcAC service.
// All implementations must embed UnimplementedHpcACServer
// for forward compatibility
type HpcACServer interface {
//ListJob list all jobs
// ListJob list all jobs
ListJob(context.Context, *ListJobReq) (*ListJobResp, error)
//ListHistoryJob list all history jobs
// ListHistoryJob list all history jobs
ListHistoryJob(context.Context, *ListHistoryJobReq) (*ListHistoryJobResp, error)
//Submit job
// Submit job
SubmitJob(context.Context, *SubmitJobReq) (*SubmitJobResp, error)
// ListJobManager list all job managers
ListJobManager(context.Context, *JobManagerReq) (*ListJobManagerResp, error)
@ -534,32 +545,32 @@ type HpcACServer interface {
GetJobDetail(context.Context, *JobDetailReq) (*GetJobDetailResp, error)
// DeleteJob delete job
DeleteJob(context.Context, *DeleteJobReq) (*DeleteJobResp, error)
//FileContent 查看文件内容
// FileContent 查看文件内容
FileContent(context.Context, *FileDataReq) (*FileContentResp, error)
//SelectQueueByUser 查询用户可访问队列列表
// SelectQueueByUser 查询用户可访问队列列表
SelectQueueByUser(context.Context, *QueueReq) (*QueueResp, error)
//QueryQueueDetails 查询队列资源详细信息
// QueryQueueDetails 查询队列资源详细信息
QueryQueueDetails(context.Context, *QueueReq) (*QueueDetailsResp, error)
///QueryUserQuotasLimit 查询用户资源限制信息
// /QueryUserQuotasLimit 查询用户资源限制信息
QueryUserQuotasLimit(context.Context, *QueueReq) (*UserQuotasLimitResp, error)
//ParaStor Quota
// ParaStor Quota
ParaStorQuota(context.Context, *ParaStorQuotaReq) (*ParaStorQuotaResp, error)
//WallTime
// WallTime
WallTime(context.Context, *WallTimeReq) (*WallTimeResp, error)
//QueueJobs
// QueueJobs
QueueJobs(context.Context, *QueueJobsReq) (*QueueJobsResp, error)
CpuCore(context.Context, *CpuCoreReq) (*CpuCoreResp, error)
Jobs(context.Context, *JobsReq) (*JobsResp, error)
HistoryJobDetail(context.Context, *HistoryJobDetailReq) (*HistoryJobDetailResp, error)
// 曙光ac获取token
GetACToken(context.Context, *ACTokenReq) (*TokenResp, error)
//曙光ac获取clusterid
// 曙光ac获取clusterid
GetACClusterId(context.Context, *ACClusterReq) (*ClusterResp, error)
//获取曙光账号算力
// 获取曙光账号算力
GetComputingPower(context.Context, *ResourceReq) (*CpResp, error)
//获取曙光账号cpu,内存,存储信息
// 获取曙光账号cpu,内存,存储信息
GetGeneralInfo(context.Context, *ResourceReq) (*GiResp, error)
//曙光智算接口
// 曙光智算接口
SubmitPytorchTask(context.Context, *SubmitPytorchTaskReq) (*SubmitTaskAiResp, error)
SubmitTensorflowTask(context.Context, *SubmitTensorflowTaskReq) (*SubmitTaskAiResp, error)
GetImageListAi(context.Context, *GetImageListAiReq) (*GetImageListAiResp, error)
@ -571,20 +582,21 @@ type HpcACServer interface {
GetInstanceLog(context.Context, *GetInstanceLogReq) (*GetInstanceLogResp, error)
GetInstanceListAi(context.Context, *GetInstanceListReq) (*GetInstanceListResp, error)
GetInferUrl(context.Context, *GetInferUrlReq) (*GetInferUrlResp, error)
//曙光文件接口
// 曙光文件接口
GetFileList(context.Context, *GetFileListReq) (*GetFileListResp, error)
GetFile(context.Context, *GetFileReq) (*GetFileResp, error)
UploadFile(context.Context, *UploadFileReq) (*UploadFileResp, error)
//用户资源
// 用户资源
GetUserInfo(context.Context, *GetUserInfoReq) (*GetUserInfoResp, error)
GetMemberJobs(context.Context, *GetMemberJobsReq) (*GetMemberJobsResp, error)
//容器
// 容器
GetNodeResources(context.Context, *GetNodeResourcesReq) (*GetNodeResourcesResp, error)
GetInstanceServiceList(context.Context, *GetInstanceServiceListReq) (*GetInstanceServiceListResp, error)
GetInstanceServiceDetail(context.Context, *GetInstanceServiceDetailReq) (*GetInstanceServiceDetailResp, error)
StartInstanceService(context.Context, *StartInstanceServiceReq) (*StartInstanceServiceResp, error)
StopInstanceService(context.Context, *StopInstanceServiceReq) (*StopInstanceServiceResp, error)
CreateInstanceService(context.Context, *CreateInstanceServiceReq) (*CreateInstanceServiceResp, error)
GetImageList(context.Context, *GetImageListReq) (*GetImageListResp, error)
mustEmbedUnimplementedHpcACServer()
}
@ -718,6 +730,9 @@ func (UnimplementedHpcACServer) StopInstanceService(context.Context, *StopInstan
func (UnimplementedHpcACServer) CreateInstanceService(context.Context, *CreateInstanceServiceReq) (*CreateInstanceServiceResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateInstanceService not implemented")
}
func (UnimplementedHpcACServer) GetImageList(context.Context, *GetImageListReq) (*GetImageListResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetImageList not implemented")
}
func (UnimplementedHpcACServer) mustEmbedUnimplementedHpcACServer() {}
// UnsafeHpcACServer may be embedded to opt out of forward compatibility for this service.
@ -1487,6 +1502,24 @@ func _HpcAC_CreateInstanceService_Handler(srv interface{}, ctx context.Context,
return interceptor(ctx, in, info, handler)
}
func _HpcAC_GetImageList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetImageListReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HpcACServer).GetImageList(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: HpcAC_GetImageList_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HpcACServer).GetImageList(ctx, req.(*GetImageListReq))
}
return interceptor(ctx, in, info, handler)
}
// HpcAC_ServiceDesc is the grpc.ServiceDesc for HpcAC service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@ -1662,6 +1695,10 @@ var HpcAC_ServiceDesc = grpc.ServiceDesc{
MethodName: "CreateInstanceService",
Handler: _HpcAC_CreateInstanceService_Handler,
},
{
MethodName: "GetImageList",
Handler: _HpcAC_GetImageList_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "hpcAC.proto",

View File

@ -48,6 +48,8 @@ type (
GetImageAiByIdResp = hpcAC.GetImageAiByIdResp
GetImageListAiReq = hpcAC.GetImageListAiReq
GetImageListAiResp = hpcAC.GetImageListAiResp
GetImageListReq = hpcAC.GetImageListReq
GetImageListResp = hpcAC.GetImageListResp
GetInferUrlReq = hpcAC.GetInferUrlReq
GetInferUrlResp = hpcAC.GetInferUrlResp
GetInstanceDetailParams = hpcAC.GetInstanceDetailParams
@ -206,6 +208,7 @@ type (
StartInstanceService(ctx context.Context, in *StartInstanceServiceReq, opts ...grpc.CallOption) (*StartInstanceServiceResp, error)
StopInstanceService(ctx context.Context, in *StopInstanceServiceReq, opts ...grpc.CallOption) (*StopInstanceServiceResp, error)
CreateInstanceService(ctx context.Context, in *CreateInstanceServiceReq, opts ...grpc.CallOption) (*CreateInstanceServiceResp, error)
GetImageList(ctx context.Context, in *GetImageListReq, opts ...grpc.CallOption) (*GetImageListResp, error)
}
defaultHpcAC struct {
@ -449,3 +452,8 @@ func (m *defaultHpcAC) CreateInstanceService(ctx context.Context, in *CreateInst
client := hpcAC.NewHpcACClient(m.cli.Conn())
return client.CreateInstanceService(ctx, in, opts...)
}
func (m *defaultHpcAC) GetImageList(ctx context.Context, in *GetImageListReq, opts ...grpc.CallOption) (*GetImageListResp, error) {
client := hpcAC.NewHpcACClient(m.cli.Conn())
return client.GetImageList(ctx, in, opts...)
}

View File

@ -0,0 +1,30 @@
package logic
import (
"context"
"gitlink.org.cn/JointCloud/pcm-ac/hpcAC"
"gitlink.org.cn/JointCloud/pcm-ac/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type GetImageListLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetImageListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetImageListLogic {
return &GetImageListLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *GetImageListLogic) GetImageList(in *hpcAC.GetImageListReq) (*hpcAC.GetImageListResp, error) {
// todo: add your logic here and delete this line
return &hpcAC.GetImageListResp{}, nil
}

View File

@ -252,3 +252,8 @@ func (s *HpcACServer) CreateInstanceService(ctx context.Context, in *hpcAC.Creat
l := logic.NewCreateInstanceServiceLogic(ctx, s.svcCtx)
return l.CreateInstanceService(in)
}
func (s *HpcACServer) GetImageList(ctx context.Context, in *hpcAC.GetImageListReq) (*hpcAC.GetImageListResp, error) {
l := logic.NewGetImageListLogic(ctx, s.svcCtx)
return l.GetImageList(in)
}