|
- package hpc
-
- import (
- "context"
-
- "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
- "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
-
- "github.com/zeromicro/go-zero/core/logx"
- )
-
- type ResourceLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
-
- func NewResourceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ResourceLogic {
- return &ResourceLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
-
- func (l *ResourceLogic) Resource(req *types.HpcResourceReq) (resp *types.HpcResourceResp, err error) {
-
- l.svcCtx.DbEngin.Raw("SELECT th.NAME as job_name,t.description as job_desc,t.commit_time as submit_time,th.STATUS as job_status,ta.name as adapter_name,tc.name as cluster_name,tc.label as cluster_type FROM task_hpc th LEFT JOIN task t ON t.id = th.task_id JOIN t_cluster tc on th.cluster_id = tc.id JOIN t_adapter ta on tc.adapter_id = ta.id")
-
- hpcResource := types.HPCResource{
- GPUCardsTotal: 0,
- CPUCoresTotal: 0,
- RAMTotal: 0,
- GPUCardsUsed: 0,
- CPUCoresUsed: 0,
- RAMUsed: 0,
- GPURate: 0,
- CPURate: 0,
- RAMRate: 0,
- }
-
- resp = &types.HpcResourceResp{
- Code: 200,
- Msg: "success",
- HPCResource: hpcResource,
- }
- return resp, nil
- }
|