数算列表接口
Former-commit-id: 1086a71a5fc77ce13f8c143218d7985985ef85f2
This commit is contained in:
parent
8dc3c3b51a
commit
13fad5ec21
|
@ -1,36 +1,57 @@
|
|||
syntax = "v1"
|
||||
|
||||
info(
|
||||
title: "cloud core"
|
||||
desc: "cloud core微服务"
|
||||
author: "zhangwei"
|
||||
email: ""
|
||||
title: "cloud core"
|
||||
desc: "cloud core微服务"
|
||||
author: "zhangwei"
|
||||
email: ""
|
||||
)
|
||||
/******************find datasetList start*************************/
|
||||
|
||||
type ApplyReq{
|
||||
YamlString string `json:"yamlString" copier:"yamlString"`
|
||||
type ApplyReq {
|
||||
YamlString string `json:"yamlString" copier:"yamlString"`
|
||||
}
|
||||
|
||||
type DeleteReq{
|
||||
YamlString string `json:"yamlString" copier:"yamlString"`
|
||||
type DeleteReq {
|
||||
YamlString string `json:"yamlString" copier:"yamlString"`
|
||||
}
|
||||
|
||||
type ApplyResp{
|
||||
Code int32 `json:"code,omitempty"`
|
||||
Msg string `json:"msg,omitempty"`
|
||||
DataSet []DataSet `json:"dataSet,omitempty"`
|
||||
type ApplyResp {
|
||||
Code int32 `json:"code,omitempty"`
|
||||
Msg string `json:"msg,omitempty"`
|
||||
DataSet []DataSet `json:"dataSet,omitempty"`
|
||||
}
|
||||
|
||||
type DeleteResp{
|
||||
Code int32 `json:"code,omitempty"`
|
||||
Msg string `json:"msg,omitempty"`
|
||||
Data string `json:"data,omitempty"`
|
||||
type DeleteResp {
|
||||
Code int32 `json:"code,omitempty"`
|
||||
Msg string `json:"msg,omitempty"`
|
||||
Data string `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type DataSet{
|
||||
ApiVersion int32 `json:"apiVersion,omitempty"`
|
||||
Kind string `json:"kind,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
NameSpace string `json:"nameSpace,omitempty"`
|
||||
type DataSet {
|
||||
ApiVersion int32 `json:"apiVersion,omitempty"`
|
||||
Kind string `json:"kind,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
NameSpace string `json:"nameSpace,omitempty"`
|
||||
}
|
||||
|
||||
type cloudListResp {
|
||||
Clouds []Cloud `json:"clouds"`
|
||||
|
||||
}
|
||||
type Cloud{
|
||||
Id int64 `json:"id"` // id
|
||||
TaskId int64 `json:"taskId"` // 任务id
|
||||
ParticipantId int64 `json:"participantId"` // 集群静态信息id
|
||||
ApiVersion string `json:"apiVersion"`
|
||||
Name string `json:"name"` // 名称
|
||||
Namespace string `json:"namespace"` // 命名空间
|
||||
Kind string `json:"kind"` // 种类
|
||||
Status string `json:"status"` // 状态
|
||||
StartTime string `json:"startTime"` // 开始时间
|
||||
RunningTime int64 `json:"runningTime"` // 运行时长
|
||||
CreatedBy int64 `json:"createdBy"` // 创建人
|
||||
CreatedTime string `json:"createdTime"` // 创建时间
|
||||
YamlString string `json:"yamlString"`
|
||||
Result string `json:"result"`
|
||||
}
|
|
@ -25,49 +25,49 @@ info(
|
|||
service pcm {
|
||||
@handler scheduleTaskByYamlHandler
|
||||
post /core/scheduleTaskByYaml (scheduleTaskByYamlReq) returns ()
|
||||
|
||||
|
||||
@handler scheduleTaskHandler
|
||||
post /core/scheduleTask (scheduleTaskReq) returns ()
|
||||
|
||||
|
||||
@handler TaskListHandler
|
||||
get /core/taskList () returns (taskListResp)
|
||||
|
||||
|
||||
@handler JobTotalHandler
|
||||
get /core/jobTotal () returns (jobTotalResp)
|
||||
|
||||
|
||||
@handler listCenterHandler
|
||||
get /core/listCenter () returns (listCenterResp)
|
||||
|
||||
|
||||
@handler listClusterHandler
|
||||
get /core/listCluster/:centerId (listClusterReq) returns (listClusterResp)
|
||||
|
||||
|
||||
@handler submitJobHandler
|
||||
post /core/submitJob (submitJobReq) returns (submitJobResp)
|
||||
|
||||
|
||||
@handler getRegionHandler
|
||||
get /core/getRegion () returns (getRegionResp)
|
||||
|
||||
|
||||
@handler listRegionHandler
|
||||
get /core/listRegion () returns (listRegionResp)
|
||||
|
||||
|
||||
@handler getComputingPowerHandler
|
||||
get /core/getComputingPower returns (cpResp)
|
||||
|
||||
|
||||
@handler getGeneralInfoHandler
|
||||
get /core/getGeneralInfo () returns (GiResp)
|
||||
|
||||
|
||||
@handler listDomainResourceHandler
|
||||
get /core/listDomainResource returns (DomainResourceResp)
|
||||
|
||||
|
||||
@handler getResourcePanelConfigHandler
|
||||
get /core/getResourcePanelConfigHandler () returns (ResourcePanelConfigResp)
|
||||
|
||||
|
||||
@handler putResourcePanelConfigHandler
|
||||
put /core/resourcePanelConfigHandler (ResourcePanelConfigReq) returns ()
|
||||
|
||||
|
||||
@handler nodeAssetsHandler
|
||||
get /core/assets () returns (NodeAssetsResp)
|
||||
|
||||
|
||||
}
|
||||
|
||||
//hpc二级接口
|
||||
|
@ -78,10 +78,10 @@ service pcm {
|
|||
service pcm {
|
||||
@handler listJobHandler
|
||||
get /hpc/listJob (listJobReq) returns (listJobResp)
|
||||
|
||||
|
||||
@handler listHistoryJobHandler
|
||||
get /hpc/listHistoryJob (listHistoryJobReq) returns (listHistoryJobResp)
|
||||
|
||||
|
||||
@handler queueAssetsHandler
|
||||
get /queue/assets () returns (QueueAssetsResp)
|
||||
}
|
||||
|
@ -92,12 +92,12 @@ service pcm {
|
|||
group : cloud
|
||||
)
|
||||
service pcm {
|
||||
@handler applyYamlHandler
|
||||
get /cloud/ApplyYaml (ApplyReq) returns (ApplyResp)
|
||||
|
||||
@handler cloudListHandler
|
||||
get /task/list () returns (cloudListResp)
|
||||
|
||||
@handler deleteYamlHandler
|
||||
get /cloud/DeleteYaml (ApplyReq) returns (DeleteResp)
|
||||
|
||||
|
||||
}
|
||||
|
||||
//智算二级接口
|
||||
|
@ -108,10 +108,10 @@ service pcm {
|
|||
service pcm {
|
||||
@handler listDataSetHandler
|
||||
get /ai/listDataSet/:projectId (DataSetReq) returns (DataSetResp)
|
||||
|
||||
|
||||
@handler CreateDataSetHandler
|
||||
post /ai/createDataSet/:projectId (CreateDataSetReq) returns (CreateDataSetResp)
|
||||
|
||||
|
||||
@handler DeleteDataSetHandler
|
||||
delete /ai/deleteDataSet/:projectId/:datasetId (DeleteDataSetReq) returns (DeleteDataSetResp)
|
||||
// creat task 创建导入任务
|
||||
|
@ -142,7 +142,7 @@ service pcm {
|
|||
// ShowAlgorithmByUuid 展示算法详情
|
||||
@handler ShowAlgorithmByUuid
|
||||
get /ai/ShowAlgorithmByUuid/:projectId/:algorithmId (ShowAlgorithmByUuidReq) returns (ShowAlgorithmByUuidResp)
|
||||
|
||||
|
||||
// creat export task 创建导出任务
|
||||
@handler CreateExportTaskHandler
|
||||
post /ai/CreateExportTask/:projectId/:datasetId (CreateExportTaskReq) returns (ExportTaskDataResp)
|
||||
|
@ -150,11 +150,11 @@ service pcm {
|
|||
get /ai/GetExportTasksOfDataset/:projectId/:datasetId (GetExportTasksOfDatasetReq) returns (GetExportTasksOfDatasetResp)
|
||||
@handler GetExportTaskStatusOfDatasetHandler
|
||||
get /ai/GetExportTaskStatusOfDataset/:projectId/:resourceId/:taskId (GetExportTaskStatusOfDatasetReq) returns (GetExportTaskStatusOfDatasetResp)
|
||||
|
||||
|
||||
// create processor task 创建处理任务
|
||||
@handler CreateProcessorTaskHandler
|
||||
post /ai/CreateProcessorTask (CreateProcessorTaskReq) returns (CreateProcessorTaskResp)
|
||||
|
||||
|
||||
// create service 创建服务
|
||||
@handler CreateServiceHandler
|
||||
post /ai/CreateService/:projectId (CreateServiceReq) returns (CreateServiceResp)
|
||||
|
@ -170,7 +170,7 @@ service pcm {
|
|||
// ListClusters查询专属资源池列表
|
||||
@handler ListClustersHandler
|
||||
get /ai/ListClusters (ListClustersReq) returns (ListClustersResp)
|
||||
|
||||
|
||||
/******************Notebook Method start*************************/
|
||||
@handler listNotebookHandler
|
||||
get /ai/listNotebook (ListNotebookReq) returns (ListNotebookResp)
|
||||
|
@ -185,7 +185,7 @@ service pcm {
|
|||
@handler mountNotebookStorageHandler
|
||||
post /ai/mountNotebookStorage (MountNotebookStorageReq) returns (MountNotebookStorageResp)
|
||||
/******************Notebook Method end*************************/
|
||||
|
||||
|
||||
/******************Visualization Job Method start*************************/
|
||||
@handler getVisualizationJobHandler
|
||||
get /ai/getVisualizationJob (GetVisualizationJobReq) returns (GetVisualizationJobResp)
|
||||
|
@ -216,16 +216,16 @@ service pcm {
|
|||
service pcm {
|
||||
@handler uploadHandler
|
||||
post /upload () returns ()
|
||||
|
||||
|
||||
@handler chunkHandler
|
||||
post /chunk () returns ()
|
||||
|
||||
|
||||
@handler imageListHandler
|
||||
get /image/list () returns (imageListResp)
|
||||
|
||||
|
||||
@handler dataSetCheckHandler
|
||||
get /dataSet/check/:fileMd5 (checkReq) returns (checkResp)
|
||||
|
||||
|
||||
@handler uploadDataSetHandler
|
||||
post /dataSet/upload () returns ()
|
||||
}
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
package cloud
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/cloud"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
||||
)
|
||||
|
||||
func ApplyYamlHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ApplyReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := cloud.NewApplyYamlLogic(r.Context(), svcCtx)
|
||||
resp, err := l.ApplyYaml(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package cloud
|
||||
|
||||
import (
|
||||
"gitlink.org.cn/jcce-pcm/utils/result"
|
||||
"net/http"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/cloud"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
)
|
||||
|
||||
func CloudListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := cloud.NewCloudListLogic(r.Context(), svcCtx)
|
||||
resp, err := l.CloudList()
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
|
@ -123,8 +123,8 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/cloud/ApplyYaml",
|
||||
Handler: cloud.ApplyYamlHandler(serverCtx),
|
||||
Path: "/task/list",
|
||||
Handler: cloud.CloudListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
package cloud
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ApplyYamlLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewApplyYamlLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ApplyYamlLogic {
|
||||
return &ApplyYamlLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *ApplyYamlLogic) ApplyYaml(req *types.ApplyReq) (resp *types.ApplyResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package cloud
|
||||
|
||||
import (
|
||||
"context"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/model"
|
||||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CloudListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewCloudListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CloudListLogic {
|
||||
return &CloudListLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CloudListLogic) CloudList() (resp *types.CloudListResp, err error) {
|
||||
// 查询数据库中数算任务列表
|
||||
var clouds []*model.Cloud
|
||||
tx := l.svcCtx.DbEngin.Find(&clouds)
|
||||
if tx.Error != nil {
|
||||
return nil, tx.Error
|
||||
}
|
||||
result := types.CloudListResp{}
|
||||
tool.Convert(clouds, &result.Clouds)
|
||||
return &result, nil
|
||||
}
|
|
@ -17,6 +17,7 @@ func NewHpcScheduler(val string) *hpcScheduler {
|
|||
|
||||
func (h *hpcScheduler) getNewStructForDb(task *types.TaskInfo, participantId int64) (interface{}, error) {
|
||||
hpc := model.Hpc{
|
||||
Id: tool.GenSnowflakeID(),
|
||||
TaskId: task.TaskId,
|
||||
Status: "Saved",
|
||||
ParticipantId: participantId,
|
||||
|
|
|
@ -2592,3 +2592,24 @@ type DataSet struct {
|
|||
Name string `json:"name,omitempty"`
|
||||
NameSpace string `json:"nameSpace,omitempty"`
|
||||
}
|
||||
|
||||
type CloudListResp struct {
|
||||
Clouds []Cloud `json:"clouds"`
|
||||
}
|
||||
|
||||
type Cloud struct {
|
||||
Id int64 `json:"id"` // id
|
||||
TaskId int64 `json:"taskId"` // 任务id
|
||||
ParticipantId int64 `json:"participantId"` // 集群静态信息id
|
||||
ApiVersion string `json:"apiVersion"`
|
||||
Name string `json:"name"` // 名称
|
||||
Namespace string `json:"namespace"` // 命名空间
|
||||
Kind string `json:"kind"` // 种类
|
||||
Status string `json:"status"` // 状态
|
||||
StartTime string `json:"startTime"` // 开始时间
|
||||
RunningTime int64 `json:"runningTime"` // 运行时长
|
||||
CreatedBy int64 `json:"createdBy"` // 创建人
|
||||
CreatedTime string `json:"createdTime"` // 创建时间
|
||||
YamlString string `json:"yamlString"`
|
||||
Result string `json:"result"`
|
||||
}
|
||||
|
|
|
@ -45,8 +45,11 @@ func (l *SyncInfoLogic) SyncInfo(in *pcmCore.SyncInfoReq) (*pcmCore.SyncInfoResp
|
|||
}
|
||||
case "hpc":
|
||||
for _, hpcInfo := range in.HpcInfoList {
|
||||
tx := db.Exec("update hpc set status = ?,derived_es = ?,assoc_id = ?,exit_code = ?,version = ?,alloc_cpu = ?,alloc_nodes = ?,cluster = ?,block_id = ?,start_time = ?,running_time = ?,job_id = ? where participant_id = ? and task_id = ? and name = ?",
|
||||
hpcInfo.Status, hpcInfo.DerivedEs, hpcInfo.AssocId, hpcInfo.ExitCode, hpcInfo.Version, hpcInfo.AllocCpu, hpcInfo.AllocNodes, hpcInfo.Cluster, hpcInfo.BlockId, hpcInfo.StartTime, hpcInfo.RunningTime, hpcInfo.JobId, in.ParticipantId, hpcInfo.TaskId, hpcInfo.Name)
|
||||
//tx := db.Exec("update hpc set status = ?,derived_es = ?,assoc_id = ?,exit_code = ?,version = ?,alloc_cpu = ?,alloc_nodes = ?,cluster = ?,block_id = ?,start_time = ?,running_time = ?,job_id = ? where participant_id = ? and task_id = ? and name = ?",
|
||||
// hpcInfo.Status, hpcInfo.DerivedEs, hpcInfo.AssocId, hpcInfo.ExitCode, hpcInfo.Version, hpcInfo.AllocCpu, hpcInfo.AllocNodes, hpcInfo.Cluster, hpcInfo.BlockId, hpcInfo.StartTime, hpcInfo.RunningTime, hpcInfo.JobId, in.ParticipantId, hpcInfo.TaskId, hpcInfo.Name)
|
||||
//print(tx.Error)
|
||||
tx := db.Exec("update hpc set status = ?,start_time = ?,running_time = ?,job_id = ? where participant_id = ? and task_id = ? and name = ?",
|
||||
hpcInfo.Status, hpcInfo.StartTime, hpcInfo.RunningTime, hpcInfo.JobId, in.ParticipantId, hpcInfo.TaskId, hpcInfo.Name)
|
||||
print(tx.Error)
|
||||
}
|
||||
case "ai":
|
||||
|
|
Loading…
Reference in New Issue