Merge remote-tracking branch 'origin/master' into master0312
# Conflicts: # api/etc/pcm.yaml Former-commit-id: 8f9cd14748e6097b98692efe3449154186a65f96
This commit is contained in:
commit
88c674e0b9
|
@ -0,0 +1,13 @@
|
||||||
|
package client
|
||||||
|
|
||||||
|
type Options struct {
|
||||||
|
Url string
|
||||||
|
DataSource string
|
||||||
|
}
|
||||||
|
type Client interface {
|
||||||
|
Task(TaskOptions) (Task, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewClient(options Options) (Client, error) {
|
||||||
|
return newClient(options)
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package client
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gorm.io/driver/mysql"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"gorm.io/gorm/logger"
|
||||||
|
"gorm.io/gorm/schema"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type client struct {
|
||||||
|
url string
|
||||||
|
dataSource string
|
||||||
|
DbEngin *gorm.DB
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *client) Task(options TaskOptions) (Task, error) {
|
||||||
|
task, _ := newTask(c, &options)
|
||||||
|
return task, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func newClient(options Options) (Client, error) {
|
||||||
|
//init dbEngine
|
||||||
|
dbEngin, _ := gorm.Open(mysql.Open(options.DataSource), &gorm.Config{
|
||||||
|
NamingStrategy: schema.NamingStrategy{
|
||||||
|
SingularTable: true,
|
||||||
|
},
|
||||||
|
Logger: logger.Default.LogMode(logger.Warn),
|
||||||
|
})
|
||||||
|
sqlDB, _ := dbEngin.DB()
|
||||||
|
sqlDB.SetMaxIdleConns(10)
|
||||||
|
sqlDB.SetMaxOpenConns(50)
|
||||||
|
sqlDB.SetConnMaxLifetime(time.Hour)
|
||||||
|
c := &client{
|
||||||
|
url: options.Url,
|
||||||
|
dataSource: options.DataSource,
|
||||||
|
DbEngin: dbEngin,
|
||||||
|
}
|
||||||
|
|
||||||
|
return c, nil
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package client
|
||||||
|
|
||||||
|
type TaskOptions struct {
|
||||||
|
pullTaskInfoReq PullTaskInfoReq
|
||||||
|
pushTaskInfoReq PushTaskInfoReq
|
||||||
|
pushResourceInfoReq PushResourceInfoReq
|
||||||
|
}
|
||||||
|
|
||||||
|
type PullTaskInfoReq struct {
|
||||||
|
AdapterId int64 `json:"adapterId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PullTaskInfoResp struct {
|
||||||
|
HpcInfoList []*HpcInfo `json:"HpcInfoList,omitempty"`
|
||||||
|
CloudInfoList []*CloudInfo `json:"CloudInfoList,omitempty"`
|
||||||
|
AiInfoList []*AiInfo `json:"AiInfoList,omitempty"`
|
||||||
|
VmInfoList []*VmInfo `json:"VmInfoList,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PushTaskInfoReq struct {
|
||||||
|
AdapterId int64 `json:"adapterId"`
|
||||||
|
HpcInfoList []*HpcInfo
|
||||||
|
CloudInfoList []*CloudInfo
|
||||||
|
AiInfoList []*AiInfo
|
||||||
|
VmInfoList []*VmInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
type PushTaskInfoResp struct {
|
||||||
|
Code int64
|
||||||
|
Msg string
|
||||||
|
}
|
||||||
|
|
||||||
|
type PushResourceInfoReq struct {
|
||||||
|
AdapterId int64 `json:"adapterId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Task interface {
|
||||||
|
PullTaskInfo(pullTaskInfoReq PullTaskInfoReq) (*PullTaskInfoResp, error)
|
||||||
|
PushTaskInfo(pushTaskInfoReq PushTaskInfoReq) (*PushTaskInfoResp, error)
|
||||||
|
PushResourceInfo(pushResourceInfoReq PushResourceInfoReq)
|
||||||
|
}
|
|
@ -0,0 +1,156 @@
|
||||||
|
package client
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jinzhu/copier"
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"log"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
type task struct {
|
||||||
|
sync.RWMutex
|
||||||
|
client *client
|
||||||
|
options *TaskOptions
|
||||||
|
log log.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
func newTask(client *client, options *TaskOptions) (*task, error) {
|
||||||
|
task := &task{
|
||||||
|
RWMutex: sync.RWMutex{},
|
||||||
|
client: client,
|
||||||
|
options: options,
|
||||||
|
log: log.Logger{},
|
||||||
|
}
|
||||||
|
return task, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t task) PullTaskInfo(pullTaskInfoReq PullTaskInfoReq) (*PullTaskInfoResp, error) {
|
||||||
|
result := PullTaskInfoResp{}
|
||||||
|
// 查询p端类型
|
||||||
|
var kind int32
|
||||||
|
t.client.DbEngin.Raw("select type as kind from `t_adapter` where id = ?", pullTaskInfoReq.AdapterId).Scan(&kind)
|
||||||
|
// 查询云智超中的数据列表
|
||||||
|
switch kind {
|
||||||
|
case 2:
|
||||||
|
var hpcModelList []models.TaskHpc
|
||||||
|
findModelList(pullTaskInfoReq.AdapterId, t.client.DbEngin, &hpcModelList)
|
||||||
|
utils.Convert(hpcModelList, &result.HpcInfoList)
|
||||||
|
if len(result.HpcInfoList) > 0 {
|
||||||
|
for i, hpcInfo := range hpcModelList {
|
||||||
|
err := copier.CopyWithOption(result.HpcInfoList[i], hpcInfo, copier.Option{Converters: utils.Converters})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var clusterType string
|
||||||
|
t.client.DbEngin.Raw("SELECT label FROM `t_cluster` where id = ? ", hpcInfo.ClusterId).Scan(&clusterType)
|
||||||
|
|
||||||
|
result.HpcInfoList[i].ClusterType = clusterType
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 0:
|
||||||
|
var cloudModelList []models.Cloud
|
||||||
|
findModelList(pullTaskInfoReq.AdapterId, t.client.DbEngin, &cloudModelList)
|
||||||
|
utils.Convert(cloudModelList, &result.CloudInfoList)
|
||||||
|
case 1:
|
||||||
|
var aiModelList []models.Ai
|
||||||
|
findModelList(pullTaskInfoReq.AdapterId, t.client.DbEngin, &aiModelList)
|
||||||
|
utils.Convert(aiModelList, &result.AiInfoList)
|
||||||
|
}
|
||||||
|
return &result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t task) PushTaskInfo(pushTaskInfoReq PushTaskInfoReq) (*PushTaskInfoResp, error) {
|
||||||
|
// 查询p端类型
|
||||||
|
var kind int32
|
||||||
|
t.client.DbEngin.Raw("select type as kind from t_adapter where id = ?", pushTaskInfoReq.AdapterId).Scan(&kind)
|
||||||
|
switch kind {
|
||||||
|
case 0:
|
||||||
|
for _, cloudInfo := range pushTaskInfoReq.CloudInfoList {
|
||||||
|
t.client.DbEngin.Exec("update cloud set status = ?,start_time = ?,result = ? where participant_id = ? and id = ?",
|
||||||
|
cloudInfo.Status, cloudInfo.StartTime, cloudInfo.Result, pushTaskInfoReq.AdapterId, cloudInfo.Id)
|
||||||
|
syncTask(t.client.DbEngin, cloudInfo.TaskId)
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
for _, hpcInfo := range pushTaskInfoReq.HpcInfoList {
|
||||||
|
t.client.DbEngin.Exec("update task_hpc set status = ?,start_time = ?,job_id = ? where cluster_id = ? and task_id = ? and name = ?",
|
||||||
|
hpcInfo.Status, hpcInfo.StartTime, hpcInfo.RunningTime, hpcInfo.JobId, pushTaskInfoReq.AdapterId, hpcInfo.TaskId, hpcInfo.Name)
|
||||||
|
syncTask(t.client.DbEngin, hpcInfo.TaskId)
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
for _, aiInfo := range pushTaskInfoReq.AiInfoList {
|
||||||
|
t.client.DbEngin.Exec("update ai set status = ?,start_time = ?,project_id = ?,job_id = ? where participant_id = ? and task_id = ? and name = ?",
|
||||||
|
aiInfo.Status, aiInfo.StartTime, aiInfo.ProjectId, aiInfo.JobId, pushTaskInfoReq.AdapterId, aiInfo.TaskId, aiInfo.Name)
|
||||||
|
syncTask(t.client.DbEngin, aiInfo.TaskId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return &PushTaskInfoResp{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t task) PushResourceInfo(pushResourceInfoReq PushResourceInfoReq) {
|
||||||
|
//TODO implement me
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func findModelList(participantId int64, dbEngin *gorm.DB, data interface{}) error {
|
||||||
|
tx := dbEngin.Where("cluster_id = (select id from t_cluster where adapter_id = ?) AND status NOT IN ?", participantId, []string{"Deleted", "Succeeded", "Completed", "Failed"}).Find(data)
|
||||||
|
if tx.Error != nil {
|
||||||
|
return tx.Error
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func syncTask(gorm *gorm.DB, taskId int64) {
|
||||||
|
|
||||||
|
var allStatus string
|
||||||
|
tx := gorm.Raw("SELECT CONCAT_WS(',',GROUP_CONCAT(DISTINCT h.status) ,GROUP_CONCAT(DISTINCT a.status) ,GROUP_CONCAT(DISTINCT c.status))as status from task t left join hpc h on t.id = h.task_id left join cloud c on t.id = c.task_id left join ai a on t.id = a.task_id where t.id = ?", taskId).Scan(&allStatus)
|
||||||
|
if tx.Error != nil {
|
||||||
|
logx.Error(tx.Error)
|
||||||
|
}
|
||||||
|
// 子状态统一则修改主任务状态
|
||||||
|
statusArray := strings.Split(allStatus, ",")
|
||||||
|
if len(removeRepeatedElement(statusArray)) == 1 {
|
||||||
|
updateTask(gorm, taskId, statusArray[0])
|
||||||
|
|
||||||
|
}
|
||||||
|
// 子任务包含失败状态 主任务则失败
|
||||||
|
if strings.Contains(allStatus, constants.Failed) {
|
||||||
|
updateTask(gorm, taskId, constants.Failed)
|
||||||
|
|
||||||
|
}
|
||||||
|
if strings.Contains(allStatus, constants.Running) {
|
||||||
|
updateTask(gorm, taskId, constants.Running)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateTask(gorm *gorm.DB, taskId int64, status string) {
|
||||||
|
var task models.Task
|
||||||
|
gorm.Where("id = ? ", taskId).Find(&task)
|
||||||
|
if task.Status != status {
|
||||||
|
task.Status = status
|
||||||
|
gorm.Updates(&task)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func removeRepeatedElement(arr []string) (newArr []string) {
|
||||||
|
newArr = make([]string, 0)
|
||||||
|
for i := 0; i < len(arr); i++ {
|
||||||
|
repeat := false
|
||||||
|
for j := i + 1; j < len(arr); j++ {
|
||||||
|
if arr[i] == arr[j] {
|
||||||
|
repeat = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !repeat {
|
||||||
|
newArr = append(newArr, arr[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
|
@ -0,0 +1,94 @@
|
||||||
|
package client
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type HpcInfo struct {
|
||||||
|
Id int64 `json:"id"` // id
|
||||||
|
TaskId int64 `json:"task_id"` // 任务id
|
||||||
|
JobId string `json:"job_id"` // 作业id(在第三方系统中的作业id)
|
||||||
|
ClusterId int64 `json:"cluster_id"` // 执行任务的集群id
|
||||||
|
ClusterType string `json:"cluster_type"` // 执行任务的集群类型
|
||||||
|
Name string `json:"name"` // 名称
|
||||||
|
Status string `json:"status"` // 状态
|
||||||
|
CmdScript string `json:"cmd_script"`
|
||||||
|
StartTime string `json:"start_time"` // 开始时间
|
||||||
|
RunningTime int64 `json:"running_time"` // 运行时间
|
||||||
|
DerivedEs string `json:"derived_es"`
|
||||||
|
Cluster string `json:"cluster"`
|
||||||
|
BlockId int64 `json:"block_id"`
|
||||||
|
AllocNodes int64 `json:"alloc_nodes"`
|
||||||
|
AllocCpu int64 `json:"alloc_cpu"`
|
||||||
|
CardCount int64 `json:"card_count"` // 卡数
|
||||||
|
Version string `json:"version"`
|
||||||
|
Account string `json:"account"`
|
||||||
|
WorkDir string `json:"work_dir"` // 工作路径
|
||||||
|
AssocId int64 `json:"assoc_id"`
|
||||||
|
ExitCode int64 `json:"exit_code"`
|
||||||
|
WallTime string `json:"wall_time"` // 最大运行时间
|
||||||
|
Result string `json:"result"` // 运行结果
|
||||||
|
DeletedAt sql.NullTime `json:"deleted_at"` // 删除时间
|
||||||
|
YamlString string `json:"yaml_string"`
|
||||||
|
AppType string `json:"app_type"` // 应用类型
|
||||||
|
AppName string `json:"app_name"` // 应用名称
|
||||||
|
Queue string `json:"queue"` // 队列名称
|
||||||
|
SubmitType string `json:"submit_type"` // cmd(命令行模式)
|
||||||
|
NNode string `json:"n_node"` // 节点个数(当指定该参数时,GAP_NODE_STRING必须为"")
|
||||||
|
StdOutFile string `json:"std_out_file"` // 工作路径/std.err.%j
|
||||||
|
StdErrFile string `json:"std_err_file"` // 工作路径/std.err.%j
|
||||||
|
StdInput string `json:"std_input"`
|
||||||
|
Environment string `json:"environment"`
|
||||||
|
DeletedFlag int64 `json:"deleted_flag"` // 是否删除(0-否,1-是)
|
||||||
|
CreatedBy int64 `json:"created_by"` // 创建人
|
||||||
|
CreatedTime time.Time `json:"created_time"` // 创建时间
|
||||||
|
UpdatedBy int64 `json:"updated_by"` // 更新人
|
||||||
|
UpdatedTime time.Time `json:"updated_time"` // 更新时间
|
||||||
|
}
|
||||||
|
|
||||||
|
type CloudInfo struct {
|
||||||
|
Participant int64 `json:"participant,omitempty"`
|
||||||
|
Id int64 `json:"id,omitempty"`
|
||||||
|
TaskId int64 `json:"taskId,omitempty"`
|
||||||
|
ApiVersion string `json:"apiVersion,omitempty"`
|
||||||
|
Kind string `json:"kind,omitempty"`
|
||||||
|
Namespace string `json:"namespace,omitempty"`
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
StartTime string `json:"startTime,omitempty"`
|
||||||
|
RunningTime int64 `json:"runningTime,omitempty"`
|
||||||
|
Result string `json:"result,omitempty"`
|
||||||
|
YamlString string `json:"yamlString,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AiInfo struct {
|
||||||
|
ParticipantId int64 `json:"participantId,omitempty"`
|
||||||
|
TaskId int64 `json:"taskId,omitempty"`
|
||||||
|
ProjectId string `json:"project_id,omitempty"`
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
StartTime string `json:"startTime,omitempty"`
|
||||||
|
RunningTime int64 `json:"runningTime,omitempty"`
|
||||||
|
Result string `json:"result,omitempty"`
|
||||||
|
JobId string `json:"jobId,omitempty"`
|
||||||
|
CreateTime string `json:"createTime,omitempty"`
|
||||||
|
ImageUrl string `json:"imageUrl,omitempty"`
|
||||||
|
Command string `json:"command,omitempty"`
|
||||||
|
FlavorId string `json:"flavorId,omitempty"`
|
||||||
|
SubscriptionId string `json:"subscriptionId,omitempty"`
|
||||||
|
ItemVersionId string `json:"itemVersionId,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type VmInfo struct {
|
||||||
|
ParticipantId int64 `json:"participantId,omitempty"`
|
||||||
|
TaskId int64 `json:"taskId,omitempty"`
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
FlavorRef string `json:"flavor_ref,omitempty"`
|
||||||
|
ImageRef string `json:"image_ref,omitempty"`
|
||||||
|
NetworkUuid string `json:"network_uuid,omitempty"`
|
||||||
|
BlockUuid string `json:"block_uuid,omitempty"`
|
||||||
|
SourceType string `json:"source_type,omitempty"`
|
||||||
|
DeleteOnTermination bool `json:"delete_on_termination,omitempty"`
|
||||||
|
State string `json:"state,omitempty"`
|
||||||
|
}
|
|
@ -22,7 +22,7 @@ type (
|
||||||
centerResourcesResp {
|
centerResourcesResp {
|
||||||
CentersIndex []CenterIndex `json:"centersIndex"`
|
CentersIndex []CenterIndex `json:"centersIndex"`
|
||||||
}
|
}
|
||||||
CenterIndex{
|
CenterIndex {
|
||||||
name string `json:"name"`
|
name string `json:"name"`
|
||||||
cpu float32 `json:"cpu"`
|
cpu float32 `json:"cpu"`
|
||||||
memory float32 `json:"memory"`
|
memory float32 `json:"memory"`
|
||||||
|
@ -30,6 +30,20 @@ type (
|
||||||
centerType string `json:"centerType"`
|
centerType string `json:"centerType"`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
type (
|
||||||
|
syncClusterLoadReq {
|
||||||
|
clusterLoadRecords []ClusterLoadRecord `json:"clusterLoadRecords"`
|
||||||
|
}
|
||||||
|
ClusterLoadRecord {
|
||||||
|
ClusterName string `json:"clusterName"`
|
||||||
|
CpuUsage float64 `json:"cpuUsage"`
|
||||||
|
MemoryUsage float64 `json:"memoryUsage"`
|
||||||
|
DiskUsage float64 `json:"diskUsage"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
type (
|
type (
|
||||||
getClusterListReq {
|
getClusterListReq {
|
||||||
Id int64 `form:"id"`
|
Id int64 `form:"id"`
|
||||||
|
@ -528,6 +542,7 @@ type (
|
||||||
Nickname string `form:"nickname,optional"`
|
Nickname string `form:"nickname,optional"`
|
||||||
Version string `form:"version,optional"`
|
Version string `form:"version,optional"`
|
||||||
Server string `form:"server,optional"`
|
Server string `form:"server,optional"`
|
||||||
|
PageInfo
|
||||||
}
|
}
|
||||||
AdapterReq {
|
AdapterReq {
|
||||||
Id string `json:"id,optional" db:"id"`
|
Id string `json:"id,optional" db:"id"`
|
||||||
|
@ -578,54 +593,83 @@ type (
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
type ClusterReq {
|
type (
|
||||||
Id string `form:"id,optional"`
|
ClusterReq {
|
||||||
AdapterId string `form:"adapterId,optional"`
|
Id string `form:"id,optional"`
|
||||||
Name string `json:"name,optional"`
|
AdapterId string `form:"adapterId,optional"`
|
||||||
Nickname string `json:"nickname,optional"`
|
Name string `form:"name,optional"`
|
||||||
Description string `json:"description,optional"`
|
Nickname string `form:"nickname,optional"`
|
||||||
Server string `json:"server,optional"`
|
Description string `form:"description,optional"`
|
||||||
MonitorServer string `json:"monitorServer,optional"`
|
Server string `form:"server,optional"`
|
||||||
Username string `json:"username,optional"`
|
MonitorServer string `form:"monitorServer,optional"`
|
||||||
Password string `json:"password,optional"`
|
Username string `form:"username,optional"`
|
||||||
Token string `json:"token,optional"`
|
Password string `form:"password,optional"`
|
||||||
Ak string `json:"ak,optional"`
|
Token string `form:"token,optional"`
|
||||||
Sk string `json:"sk,optional"`
|
Ak string `form:"ak,optional"`
|
||||||
Region string `json:"region,optional"`
|
Sk string `form:"sk,optional"`
|
||||||
ProjectId string `json:"projectId,optional"`
|
Region string `form:"region,optional"`
|
||||||
Version string `json:"version,optional"`
|
ProjectId string `form:"projectId,optional"`
|
||||||
Label string `json:"label,optional"`
|
Version string `form:"version,optional"`
|
||||||
OwnerId string `json:"ownerId,omitempty,optional"`
|
Label string `form:"label,optional"`
|
||||||
AuthType string `json:"authType,optional"`
|
OwnerId string `form:"ownerId,omitempty,optional"`
|
||||||
Type string `json:"type,optional"`
|
AuthType string `form:"authType,optional"`
|
||||||
}
|
Type string `form:"type,optional"`
|
||||||
|
producerDict string `form:"producerDict,optional"`
|
||||||
|
regionDict string `form:"regionDict,optional"`
|
||||||
|
PageInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
ClusterCreateReq {
|
||||||
|
Id string `json:"id,optional"`
|
||||||
|
AdapterId string `json:"adapterId,optional"`
|
||||||
|
Name string `json:"name,optional"`
|
||||||
|
Nickname string `json:"nickname,optional"`
|
||||||
|
Description string `json:"description,optional"`
|
||||||
|
Server string `json:"server,optional"`
|
||||||
|
MonitorServer string `json:"monitorServer,optional"`
|
||||||
|
Username string `json:"username,optional"`
|
||||||
|
Password string `json:"password,optional"`
|
||||||
|
Token string `json:"token,optional"`
|
||||||
|
Ak string `json:"ak,optional"`
|
||||||
|
Sk string `json:"sk,optional"`
|
||||||
|
Region string `json:"region,optional"`
|
||||||
|
ProjectId string `json:"projectId,optional"`
|
||||||
|
Version string `json:"version,optional"`
|
||||||
|
Label string `json:"label,optional"`
|
||||||
|
OwnerId string `json:"ownerId,omitempty,optional"`
|
||||||
|
AuthType string `json:"authType,optional"`
|
||||||
|
producerDict string `json:"producerDict,optional"`
|
||||||
|
regionDict string `json:"regionDict,optional"`
|
||||||
|
}
|
||||||
|
ClusterInfo {
|
||||||
|
Id string `json:"id,omitempty" db:"id"`
|
||||||
|
AdapterId string `json:"adapterId,omitempty" db:"adapter_id"`
|
||||||
|
Name string `json:"name,omitempty" db:"name"`
|
||||||
|
Nickname string `json:"nickname,omitempty" db:"nickname"`
|
||||||
|
Description string `json:"description,omitempty" db:"description"`
|
||||||
|
Server string `json:"server,omitempty" db:"server"`
|
||||||
|
MonitorServer string `json:"monitorServer,omitempty" db:"monitor_server"`
|
||||||
|
Username string `json:"username,omitempty" db:"username"`
|
||||||
|
Password string `json:"password,omitempty" db:"password"`
|
||||||
|
Token string `json:"token,omitempty" db:"token"`
|
||||||
|
Ak string `json:"ak,omitempty" db:"ak"`
|
||||||
|
Sk string `json:"sk,omitempty" db:"sk"`
|
||||||
|
Region string `json:"region,omitempty" db:"region"`
|
||||||
|
ProjectId string `json:"projectId,omitempty" db:"project_id"`
|
||||||
|
Version string `json:"version,omitempty" db:"version"`
|
||||||
|
Label string `json:"label,omitempty" db:"label"`
|
||||||
|
OwnerId string `json:"ownerId,omitempty" db:"owner_id"`
|
||||||
|
AuthType string `json:"authType,omitempty" db:"auth_type"`
|
||||||
|
producerDict string `json:"producerDict,omitempty" db:"producer_dict"`
|
||||||
|
regionDict string `json:"regionDict,omitempty" db:"region_dict"`
|
||||||
|
CreateTime string `json:"createTime,omitempty" db:"created_time" gorm:"autoCreateTime"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
type ClusterDelReq {
|
type ClusterDelReq {
|
||||||
Id string `form:"id,optional"`
|
Id string `form:"id,optional"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClusterInfo {
|
|
||||||
Id string `json:"id,omitempty" db:"id"`
|
|
||||||
AdapterId string `json:"adapterId,omitempty" db:"adapter_id"`
|
|
||||||
Name string `json:"name,omitempty" db:"name"`
|
|
||||||
Nickname string `json:"nickname,omitempty" db:"nickname"`
|
|
||||||
Description string `json:"description,omitempty" db:"description"`
|
|
||||||
Server string `json:"server,omitempty" db:"server"`
|
|
||||||
MonitorServer string `json:"monitorServer,omitempty" db:"monitor_server"`
|
|
||||||
Username string `json:"username,omitempty" db:"username"`
|
|
||||||
Password string `json:"password,omitempty" db:"password"`
|
|
||||||
Token string `json:"token,omitempty" db:"token"`
|
|
||||||
Ak string `json:"ak,omitempty" db:"ak"`
|
|
||||||
Sk string `json:"sk,omitempty" db:"sk"`
|
|
||||||
Region string `json:"region,omitempty" db:"region"`
|
|
||||||
ProjectId string `json:"projectId,omitempty" db:"project_id"`
|
|
||||||
Version string `json:"version,omitempty" db:"version"`
|
|
||||||
Label string `json:"label,omitempty" db:"label"`
|
|
||||||
OwnerId string `json:"ownerId,omitempty" db:"owner_id"`
|
|
||||||
AuthType string `json:"authType,omitempty" db:"auth_type"`
|
|
||||||
CreateTime string `json:"createTime,omitempty" db:"created_time" gorm:"autoCreateTime"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ClusterResp {
|
type ClusterResp {
|
||||||
List ClusterInfo `json:"list,omitempty"`
|
List ClusterInfo `json:"list,omitempty"`
|
||||||
}
|
}
|
||||||
|
@ -638,7 +682,7 @@ type clusterSumReq {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type clusterSumReqResp{
|
type clusterSumReqResp {
|
||||||
ClusterSum int `json:"ClusterSum,omitempty"`
|
ClusterSum int `json:"ClusterSum,omitempty"`
|
||||||
AdapterSum int `json:"AdapterSum,omitempty"`
|
AdapterSum int `json:"AdapterSum,omitempty"`
|
||||||
TaskSum int `json:"TaskSum,omitempty"`
|
TaskSum int `json:"TaskSum,omitempty"`
|
||||||
|
@ -691,6 +735,7 @@ type (
|
||||||
Description string `form:"description,optional"`
|
Description string `form:"description,optional"`
|
||||||
Type string `form:"type,optional"`
|
Type string `form:"type,optional"`
|
||||||
Status string `form:"status,optional"`
|
Status string `form:"status,optional"`
|
||||||
|
PageInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
DictEditReq {
|
DictEditReq {
|
||||||
|
@ -741,6 +786,7 @@ type (
|
||||||
Type string `form:"type,optional"`
|
Type string `form:"type,optional"`
|
||||||
ParentId string `form:"parentId,optional"`
|
ParentId string `form:"parentId,optional"`
|
||||||
Status string `form:"status,optional"`
|
Status string `form:"status,optional"`
|
||||||
|
PageInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
DictItemEditReq {
|
DictItemEditReq {
|
||||||
|
@ -772,6 +818,10 @@ type (
|
||||||
DictItems {
|
DictItems {
|
||||||
List []DictItemInfo `json:"list,omitempty"`
|
List []DictItemInfo `json:"list,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DictCodeReq {
|
||||||
|
DictCode string `path:"dictCode"`
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
@ -782,4 +832,22 @@ type (
|
||||||
CIds {
|
CIds {
|
||||||
Ids []string `json:"ids,omitempty" validate:"required"`
|
Ids []string `json:"ids,omitempty" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FId {
|
||||||
|
Id string `form:"id":"id,omitempty" validate:"required"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
PageInfo {
|
||||||
|
PageNum int `form:"pageNum"`
|
||||||
|
PageSize int `form:"pageSize"`
|
||||||
|
}
|
||||||
|
|
||||||
|
PageResult {
|
||||||
|
List interface{} `json:"list,omitempty"`
|
||||||
|
Total int64 `json:"total,omitempty"`
|
||||||
|
PageNum int `json:"pageNum,omitempty"`
|
||||||
|
PageSize int `json:"pageSize,omitempty"`
|
||||||
|
}
|
||||||
)
|
)
|
|
@ -104,6 +104,14 @@ service pcm {
|
||||||
@doc "Center Resources top3"
|
@doc "Center Resources top3"
|
||||||
@handler centerResourcesHandler
|
@handler centerResourcesHandler
|
||||||
get /core/centerResources returns (centerResourcesResp)
|
get /core/centerResources returns (centerResourcesResp)
|
||||||
|
|
||||||
|
@doc "Synchronize Cluster Load Information"
|
||||||
|
@handler syncClusterLoadHandler
|
||||||
|
post /core/syncClusterLoad (syncClusterLoadReq)
|
||||||
|
|
||||||
|
@doc "metrics"
|
||||||
|
@handler metricsHandler
|
||||||
|
get /core/metrics
|
||||||
}
|
}
|
||||||
|
|
||||||
//hpc二级接口
|
//hpc二级接口
|
||||||
|
@ -814,7 +822,7 @@ service pcm {
|
||||||
|
|
||||||
service pcm {
|
service pcm {
|
||||||
@handler AdaptersListHandler
|
@handler AdaptersListHandler
|
||||||
get /adapter/list (AdapterQueryReq) returns (AdapterListResp)
|
get /adapter/list (AdapterQueryReq) returns (PageResult)
|
||||||
|
|
||||||
@handler CreateAdapterHandler
|
@handler CreateAdapterHandler
|
||||||
post /adapter/create (AdapterCreateReq) returns (AdapterResp)
|
post /adapter/create (AdapterCreateReq) returns (AdapterResp)
|
||||||
|
@ -829,22 +837,22 @@ service pcm {
|
||||||
get /adapter/get (AdapterDelReq) returns (AdapterInfo)
|
get /adapter/get (AdapterDelReq) returns (AdapterInfo)
|
||||||
|
|
||||||
@handler ClusterListHandler
|
@handler ClusterListHandler
|
||||||
get /adapter/cluster/list (ClusterReq) returns (ClusterListResp)
|
get /adapter/cluster/list (ClusterReq) returns (PageResult)
|
||||||
|
|
||||||
@handler CreateClusterHandler
|
@handler CreateClusterHandler
|
||||||
post /adapter/cluster/create (ClusterReq) returns (ClusterResp)
|
post /adapter/cluster/create (ClusterCreateReq) returns (ClusterResp)
|
||||||
|
|
||||||
@handler UpdateClusterHandler
|
@handler UpdateClusterHandler
|
||||||
put /adapter/cluster/update (ClusterReq) returns (ClusterResp)
|
put /adapter/cluster/update (ClusterCreateReq) returns (ClusterResp)
|
||||||
|
|
||||||
@handler DeleteClusterHandler
|
@handler DeleteClusterHandler
|
||||||
delete /adapter/cluster/delete (ClusterDelReq) returns (ClusterResp)
|
delete /adapter/cluster/delete (FId) returns (ClusterResp)
|
||||||
|
|
||||||
@handler GetClusterHandler
|
@handler GetClusterHandler
|
||||||
get /adapter/cluster/get (ClusterDelReq) returns (ClusterResp)
|
get /adapter/cluster/get (FId) returns (ClusterResp)
|
||||||
|
|
||||||
@handler GetAdapterRelationHandler
|
@handler GetAdapterRelationHandler
|
||||||
get /adapter/relation (AdapterQueryReq) returns (AdapterRelationResp)
|
get /adapter/relation (AdapterQueryReq) returns (PageResult)
|
||||||
|
|
||||||
@handler GetClusterSumHandler
|
@handler GetClusterSumHandler
|
||||||
get /adapter/clusterSum (clusterSumReq) returns (clusterSumReqResp)
|
get /adapter/clusterSum (clusterSumReq) returns (clusterSumReqResp)
|
||||||
|
@ -882,7 +890,7 @@ service pcm {
|
||||||
get /dict/:id (CId) returns (DictResp)
|
get /dict/:id (CId) returns (DictResp)
|
||||||
|
|
||||||
@handler ListDict
|
@handler ListDict
|
||||||
get /dicts (DictReq) returns (Dicts)
|
get /dicts (DictReq) returns (PageResult)
|
||||||
|
|
||||||
@handler AddDict
|
@handler AddDict
|
||||||
post /dict (DictEditReq) returns (DictResp)
|
post /dict (DictEditReq) returns (DictResp)
|
||||||
|
@ -897,7 +905,7 @@ service pcm {
|
||||||
get /dictItem/:id (CId) returns (DictItemResp)
|
get /dictItem/:id (CId) returns (DictItemResp)
|
||||||
|
|
||||||
@handler ListDictItem
|
@handler ListDictItem
|
||||||
get /dictItems (DictItemReq) returns (DictItems)
|
get /dictItems (DictItemReq) returns (PageResult)
|
||||||
|
|
||||||
@handler AddDictItem
|
@handler AddDictItem
|
||||||
post /dictItem (DictItemEditReq) returns (DictItemResp)
|
post /dictItem (DictItemEditReq) returns (DictItemResp)
|
||||||
|
@ -907,4 +915,7 @@ service pcm {
|
||||||
|
|
||||||
@handler DeleteDictItem
|
@handler DeleteDictItem
|
||||||
delete /dictItem/:id (CId) returns (DictItemResp)
|
delete /dictItem/:id (CId) returns (DictItemResp)
|
||||||
|
|
||||||
|
@handler ListDictItemByCode
|
||||||
|
get /dictItem/code/:dictCode (DictCodeReq) returns (PageResult)
|
||||||
}
|
}
|
|
@ -36,8 +36,6 @@ type (
|
||||||
absolute Absolute `json:"absolute,optional"`
|
absolute Absolute `json:"absolute,optional"`
|
||||||
}
|
}
|
||||||
GetComputeLimitsReq {
|
GetComputeLimitsReq {
|
||||||
Limit int32 `json:"limit,optional"`
|
|
||||||
OffSet int32 `json:"offSet,optional"`
|
|
||||||
Platform string `json:"platform,optional"`
|
Platform string `json:"platform,optional"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,8 +66,6 @@ type (
|
||||||
absolute VolumeAbsolute `json:"absolute,optional"`
|
absolute VolumeAbsolute `json:"absolute,optional"`
|
||||||
}
|
}
|
||||||
GetVolumeLimitsReq {
|
GetVolumeLimitsReq {
|
||||||
Limit int32 `json:"limit,optional"`
|
|
||||||
OffSet int32 `json:"offSet,optional"`
|
|
||||||
Platform string `json:"platform,optional"`
|
Platform string `json:"platform,optional"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ Port: 8999
|
||||||
Timeout: 50000
|
Timeout: 50000
|
||||||
|
|
||||||
DB:
|
DB:
|
||||||
DataSource: root:uJpLd6u-J?HC1@(47.92.88.143:3306)/pcm?parseTime=true&loc=Local
|
DataSource: root:uJpLd6u-J?HC1@(10.206.0.12:3306)/pcm?parseTime=true&loc=Local
|
||||||
|
|
||||||
Redis:
|
Redis:
|
||||||
Host: 10.206.0.12:6379
|
Host: 10.206.0.12:6379
|
||||||
|
|
|
@ -1,28 +1,24 @@
|
||||||
package adapters
|
package adapters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func AdaptersListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
func AdaptersListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
var req types.AdapterQueryReq
|
var req types.AdapterQueryReq
|
||||||
if err := httpx.Parse(r, &req); err != nil {
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
result.ParamErrorResult(r, w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
l := adapters.NewAdaptersListLogic(r.Context(), svcCtx)
|
l := adapters.NewAdaptersListLogic(r.Context(), svcCtx)
|
||||||
resp, err := l.AdaptersList(&req)
|
resp, err := l.AdaptersList(&req)
|
||||||
if err != nil {
|
result.HttpResult(r, w, resp, err)
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
|
||||||
} else {
|
|
||||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,24 @@
|
||||||
package adapters
|
package adapters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ClusterListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
func ClusterListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
var req types.ClusterReq
|
var req types.ClusterReq
|
||||||
if err := httpx.Parse(r, &req); err != nil {
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
result.ParamErrorResult(r, w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
l := adapters.NewClusterListLogic(r.Context(), svcCtx)
|
l := adapters.NewClusterListLogic(r.Context(), svcCtx)
|
||||||
resp, err := l.ClusterList(&req)
|
resp, err := l.ClusterList(&req)
|
||||||
if err != nil {
|
result.HttpResult(r, w, resp, err)
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
|
||||||
} else {
|
|
||||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,24 @@
|
||||||
package adapters
|
package adapters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CreateAdapterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
func CreateAdapterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
var req types.AdapterCreateReq
|
var req types.AdapterCreateReq
|
||||||
if err := httpx.Parse(r, &req); err != nil {
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
result.ParamErrorResult(r, w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
l := adapters.NewCreateAdapterLogic(r.Context(), svcCtx)
|
l := adapters.NewCreateAdapterLogic(r.Context(), svcCtx)
|
||||||
resp, err := l.CreateAdapter(&req)
|
resp, err := l.CreateAdapter(&req)
|
||||||
if err != nil {
|
result.HttpResult(r, w, resp, err)
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
|
||||||
} else {
|
|
||||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,24 @@
|
||||||
package adapters
|
package adapters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CreateClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
func CreateClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
var req types.ClusterReq
|
var req types.ClusterCreateReq
|
||||||
if err := httpx.Parse(r, &req); err != nil {
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
result.ParamErrorResult(r, w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
l := adapters.NewCreateClusterLogic(r.Context(), svcCtx)
|
l := adapters.NewCreateClusterLogic(r.Context(), svcCtx)
|
||||||
resp, err := l.CreateCluster(&req)
|
resp, err := l.CreateCluster(&req)
|
||||||
if err != nil {
|
result.HttpResult(r, w, resp, err)
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
|
||||||
} else {
|
|
||||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,24 @@
|
||||||
package adapters
|
package adapters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func DeleteAdapterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
func DeleteAdapterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
var req types.AdapterDelReq
|
var req types.AdapterDelReq
|
||||||
if err := httpx.Parse(r, &req); err != nil {
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
result.ParamErrorResult(r, w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
l := adapters.NewDeleteAdapterLogic(r.Context(), svcCtx)
|
l := adapters.NewDeleteAdapterLogic(r.Context(), svcCtx)
|
||||||
resp, err := l.DeleteAdapter(&req)
|
resp, err := l.DeleteAdapter(&req)
|
||||||
if err != nil {
|
result.HttpResult(r, w, resp, err)
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
|
||||||
} else {
|
|
||||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,24 @@
|
||||||
package adapters
|
package adapters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func DeleteClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
func DeleteClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
var req types.ClusterDelReq
|
var req types.FId
|
||||||
if err := httpx.Parse(r, &req); err != nil {
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
result.ParamErrorResult(r, w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
l := adapters.NewDeleteClusterLogic(r.Context(), svcCtx)
|
l := adapters.NewDeleteClusterLogic(r.Context(), svcCtx)
|
||||||
resp, err := l.DeleteCluster(&req)
|
resp, err := l.DeleteCluster(&req)
|
||||||
if err != nil {
|
result.HttpResult(r, w, resp, err)
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
|
||||||
} else {
|
|
||||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,24 @@
|
||||||
package adapters
|
package adapters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetAdapterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
func GetAdapterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
var req types.AdapterDelReq
|
var req types.AdapterDelReq
|
||||||
if err := httpx.Parse(r, &req); err != nil {
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
result.ParamErrorResult(r, w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
l := adapters.NewGetAdapterLogic(r.Context(), svcCtx)
|
l := adapters.NewGetAdapterLogic(r.Context(), svcCtx)
|
||||||
resp, err := l.GetAdapter(&req)
|
resp, err := l.GetAdapter(&req)
|
||||||
if err != nil {
|
result.HttpResult(r, w, resp, err)
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
|
||||||
} else {
|
|
||||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,24 @@
|
||||||
package adapters
|
package adapters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetAdapterRelationHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
func GetAdapterRelationHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
var req types.AdapterQueryReq
|
var req types.AdapterQueryReq
|
||||||
if err := httpx.Parse(r, &req); err != nil {
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
result.ParamErrorResult(r, w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
l := adapters.NewGetAdapterRelationLogic(r.Context(), svcCtx)
|
l := adapters.NewGetAdapterRelationLogic(r.Context(), svcCtx)
|
||||||
resp, err := l.GetAdapterRelation(&req)
|
resp, err := l.GetAdapterRelation(&req)
|
||||||
if err != nil {
|
result.HttpResult(r, w, resp, err)
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
|
||||||
} else {
|
|
||||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,24 @@
|
||||||
package adapters
|
package adapters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
func GetClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
var req types.ClusterDelReq
|
var req types.FId
|
||||||
if err := httpx.Parse(r, &req); err != nil {
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
result.ParamErrorResult(r, w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
l := adapters.NewGetClusterLogic(r.Context(), svcCtx)
|
l := adapters.NewGetClusterLogic(r.Context(), svcCtx)
|
||||||
resp, err := l.GetCluster(&req)
|
resp, err := l.GetCluster(&req)
|
||||||
if err != nil {
|
result.HttpResult(r, w, resp, err)
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
|
||||||
} else {
|
|
||||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,24 @@
|
||||||
package adapters
|
package adapters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetClusterSumHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
func GetClusterSumHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
var req types.ClusterSumReq
|
var req types.ClusterSumReq
|
||||||
if err := httpx.Parse(r, &req); err != nil {
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
result.ParamErrorResult(r, w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
l := adapters.NewGetClusterSumLogic(r.Context(), svcCtx)
|
l := adapters.NewGetClusterSumLogic(r.Context(), svcCtx)
|
||||||
resp, err := l.GetClusterSum(&req)
|
resp, err := l.GetClusterSum(&req)
|
||||||
if err != nil {
|
result.HttpResult(r, w, resp, err)
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
|
||||||
} else {
|
|
||||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,24 @@
|
||||||
package adapters
|
package adapters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func UpdateAdapterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
func UpdateAdapterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
var req types.AdapterReq
|
var req types.AdapterReq
|
||||||
if err := httpx.Parse(r, &req); err != nil {
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
result.ParamErrorResult(r, w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
l := adapters.NewUpdateAdapterLogic(r.Context(), svcCtx)
|
l := adapters.NewUpdateAdapterLogic(r.Context(), svcCtx)
|
||||||
resp, err := l.UpdateAdapter(&req)
|
resp, err := l.UpdateAdapter(&req)
|
||||||
if err != nil {
|
result.HttpResult(r, w, resp, err)
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
|
||||||
} else {
|
|
||||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,24 @@
|
||||||
package adapters
|
package adapters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func UpdateClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
func UpdateClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
var req types.ClusterReq
|
var req types.ClusterCreateReq
|
||||||
if err := httpx.Parse(r, &req); err != nil {
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
result.ParamErrorResult(r, w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
l := adapters.NewUpdateClusterLogic(r.Context(), svcCtx)
|
l := adapters.NewUpdateClusterLogic(r.Context(), svcCtx)
|
||||||
resp, err := l.UpdateCluster(&req)
|
resp, err := l.UpdateCluster(&req)
|
||||||
if err != nil {
|
result.HttpResult(r, w, resp, err)
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
|
||||||
} else {
|
|
||||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
)
|
||||||
|
|
||||||
|
func MetricsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return promhttp.Handler().ServeHTTP
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func SyncClusterLoadHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.SyncClusterLoadReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := core.NewSyncClusterLoadLogic(r.Context(), svcCtx)
|
||||||
|
err := l.SyncClusterLoad(&req)
|
||||||
|
result.HttpResult(r, w, nil, err)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package dictionary
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/dictionary"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ListDictItemByCodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.DictCodeReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
result.ParamErrorResult(r, w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := dictionary.NewListDictItemByCodeLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.ListDictItemByCode(&req)
|
||||||
|
result.HttpResult(r, w, resp, err)
|
||||||
|
}
|
||||||
|
}
|
|
@ -124,6 +124,16 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
Path: "/core/centerResources",
|
Path: "/core/centerResources",
|
||||||
Handler: core.CenterResourcesHandler(serverCtx),
|
Handler: core.CenterResourcesHandler(serverCtx),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodPost,
|
||||||
|
Path: "/core/syncClusterLoad",
|
||||||
|
Handler: core.SyncClusterLoadHandler(serverCtx),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/core/metrics",
|
||||||
|
Handler: core.MetricsHandler(serverCtx),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
rest.WithPrefix("/pcm/v1"),
|
rest.WithPrefix("/pcm/v1"),
|
||||||
)
|
)
|
||||||
|
@ -1135,6 +1145,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
Path: "/dictItem/:id",
|
Path: "/dictItem/:id",
|
||||||
Handler: dictionary.DeleteDictItemHandler(serverCtx),
|
Handler: dictionary.DeleteDictItemHandler(serverCtx),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/dictItem/code/:dictCode",
|
||||||
|
Handler: dictionary.ListDictItemByCodeHandler(serverCtx),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
rest.WithPrefix("/pcm/v1"),
|
rest.WithPrefix("/pcm/v1"),
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,8 +2,6 @@ package adapters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
|
||||||
|
@ -24,16 +22,38 @@ func NewAdaptersListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Adap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *AdaptersListLogic) AdaptersList(req *types.AdapterQueryReq) (resp *types.AdapterListResp, err error) {
|
func (l *AdaptersListLogic) AdaptersList(req *types.AdapterQueryReq) (resp *types.PageResult, err error) {
|
||||||
resp = &types.AdapterListResp{}
|
limit := req.PageSize
|
||||||
sqlStr := "select * from t_adapter where `deleted_at` IS NULL ORDER BY create_time Desc"
|
offset := req.PageSize * (req.PageNum - 1)
|
||||||
|
resp = &types.PageResult{}
|
||||||
|
var list []types.AdapterInfo
|
||||||
|
db := l.svcCtx.DbEngin.Model(&types.AdapterInfo{}).Table("t_adapter")
|
||||||
|
|
||||||
if req.Name != "" {
|
if req.Name != "" {
|
||||||
sqlStr = fmt.Sprintf("select * from t_adapter where `deleted_at` IS NULL and name like '%%%s%%' ORDER BY create_time Desc", req.Name)
|
db = db.Where("name LIKE ?", "%"+req.Name+"%")
|
||||||
}
|
}
|
||||||
tx := l.svcCtx.DbEngin.Raw(sqlStr).Scan(&resp.List)
|
if req.Nickname != "" {
|
||||||
if tx.Error != nil {
|
db = db.Where("nickname LIKE ?", "%"+req.Nickname+"%")
|
||||||
logx.Errorf(tx.Error.Error())
|
|
||||||
return nil, tx.Error
|
|
||||||
}
|
}
|
||||||
|
if req.Type != "" {
|
||||||
|
db = db.Where("type = ?", req.Type)
|
||||||
|
}
|
||||||
|
if req.Version != "" {
|
||||||
|
db = db.Where("version = ?", req.Version)
|
||||||
|
}
|
||||||
|
var total int64
|
||||||
|
err = db.Count(&total).Error
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
db = db.Where("deleted_at is null").Limit(limit).Offset(offset)
|
||||||
|
err = db.Order("create_time desc").Find(&list).Error
|
||||||
|
|
||||||
|
resp.List = list
|
||||||
|
resp.PageSize = req.PageSize
|
||||||
|
resp.PageNum = req.PageNum
|
||||||
|
resp.Total = total
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,6 @@ package adapters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
|
||||||
|
@ -24,20 +22,56 @@ func NewClusterListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Clust
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *ClusterListLogic) ClusterList(req *types.ClusterReq) (resp *types.ClusterListResp, err error) {
|
func (l *ClusterListLogic) ClusterList(req *types.ClusterReq) (resp *types.PageResult, err error) {
|
||||||
resp = &types.ClusterListResp{}
|
limit := req.PageSize
|
||||||
|
offset := req.PageSize * (req.PageNum - 1)
|
||||||
|
resp = &types.PageResult{}
|
||||||
|
var list []types.ClusterInfo
|
||||||
|
db := l.svcCtx.DbEngin.Model(&types.AdapterInfo{}).Table("t_adapter")
|
||||||
|
|
||||||
sql := fmt.Sprintf(`select c.* from t_cluster c left join t_adapter a on c.adapter_id = a.id where c.deleted_at is null`)
|
db = db.Joins("left join t_cluster on t_adapter.id = t_cluster.adapter_id").
|
||||||
|
Where("t_cluster.deleted_at is null")
|
||||||
|
if req.Name != "" {
|
||||||
|
db = db.Where("t_cluster.name LIKE ?", "%"+req.Name+"%")
|
||||||
|
}
|
||||||
if req.AdapterId != "" {
|
if req.AdapterId != "" {
|
||||||
sql = fmt.Sprintf(`select * from t_cluster where adapter_id = %s and deleted_at is null `, req.AdapterId)
|
db = db.Where("t_cluster.adapter_id = ?", req.AdapterId)
|
||||||
|
}
|
||||||
|
if req.Nickname != "" {
|
||||||
|
db = db.Where("t_cluster.nickname LIKE ?", "%"+req.Nickname+"%")
|
||||||
|
}
|
||||||
|
if req.Label != "" {
|
||||||
|
db = db.Where("t_cluster.label = ?", req.Label)
|
||||||
|
}
|
||||||
|
if req.Version != "" {
|
||||||
|
db = db.Where("t_cluster.version = ?", req.Version)
|
||||||
|
}
|
||||||
|
if req.ProducerDict != "" {
|
||||||
|
db = db.Where("t_cluster.producer_dict = ?", req.ProducerDict)
|
||||||
|
}
|
||||||
|
if req.RegionDict != "" {
|
||||||
|
db = db.Where("t_cluster.region_dict = ?", req.RegionDict)
|
||||||
}
|
}
|
||||||
if req.Type != "" {
|
if req.Type != "" {
|
||||||
sql = fmt.Sprintf(`select c.* from t_cluster c left join t_adapter a on c.adapter_id = a.id where c.deleted_at is null and a.type = %s`, req.Type)
|
db = db.Where("t_adapter.type = ?", req.Type)
|
||||||
}
|
}
|
||||||
tx := l.svcCtx.DbEngin.Raw(sql).Scan(&resp.List)
|
|
||||||
if tx.Error != nil {
|
//count total
|
||||||
logx.Errorf(tx.Error.Error())
|
var total int64
|
||||||
return nil, tx.Error
|
err = db.Select("*").Count(&total).Error
|
||||||
|
if err != nil {
|
||||||
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
db = db.Limit(limit).Offset(offset)
|
||||||
|
err = db.Select("t_cluster.*").Order("t_cluster.create_time desc").Scan(&list).Error
|
||||||
|
if err != nil {
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
resp.List = list
|
||||||
|
resp.PageSize = req.PageSize
|
||||||
|
resp.PageNum = req.PageNum
|
||||||
|
resp.Total = total
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ func NewCreateClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Cre
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *CreateClusterLogic) CreateCluster(req *types.ClusterReq) (resp *types.ClusterResp, err error) {
|
func (l *CreateClusterLogic) CreateCluster(req *types.ClusterCreateReq) (resp *types.ClusterResp, err error) {
|
||||||
adapter := &types.AdapterInfo{}
|
adapter := &types.AdapterInfo{}
|
||||||
result := l.svcCtx.DbEngin.Table("t_adapter").First(&adapter, req.AdapterId)
|
result := l.svcCtx.DbEngin.Table("t_adapter").First(&adapter, req.AdapterId)
|
||||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ func NewDeleteClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Del
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *DeleteClusterLogic) DeleteCluster(req *types.ClusterDelReq) (resp *types.ClusterResp, err error) {
|
func (l *DeleteClusterLogic) DeleteCluster(req *types.FId) (resp *types.ClusterResp, err error) {
|
||||||
db := l.svcCtx.DbEngin.Table("t_cluster").Where("id = ?", req.Id).First(&types.ClusterInfo{})
|
db := l.svcCtx.DbEngin.Table("t_cluster").Where("id = ?", req.Id).First(&types.ClusterInfo{})
|
||||||
if db.Error != nil {
|
if db.Error != nil {
|
||||||
logx.Errorf("err %v", db.Error.Error())
|
logx.Errorf("err %v", db.Error.Error())
|
||||||
|
|
|
@ -2,7 +2,6 @@ package adapters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
|
||||||
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
@ -25,19 +24,32 @@ func NewGetAdapterRelationLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *GetAdapterRelationLogic) GetAdapterRelation(req *types.AdapterQueryReq) (resp *types.AdapterRelationResp, err error) {
|
func (l *GetAdapterRelationLogic) GetAdapterRelation(req *types.AdapterQueryReq) (resp *types.PageResult, err error) {
|
||||||
resp = &types.AdapterRelationResp{}
|
resp = &types.PageResult{}
|
||||||
adapter := make([]types.AdapterInfo, 0)
|
var list []types.AdapterInfo
|
||||||
sqlStr := "select * from t_adapter where `deleted_at` IS NULL ORDER BY create_time Desc"
|
db := l.svcCtx.DbEngin.Model(&types.AdapterInfo{}).Table("t_adapter")
|
||||||
|
|
||||||
if req.Name != "" {
|
if req.Name != "" {
|
||||||
sqlStr = fmt.Sprintf("select * from t_adapter where `deleted_at` IS NULL and name like '%%%s%%' ORDER BY create_time Desc", req.Name)
|
db = db.Where("name LIKE ?", "%"+req.Name+"%")
|
||||||
}
|
}
|
||||||
tx := l.svcCtx.DbEngin.Raw(sqlStr).Scan(&adapter)
|
if req.Nickname != "" {
|
||||||
if tx.Error != nil {
|
db = db.Where("nickname LIKE ?", "%"+req.Nickname+"%")
|
||||||
logx.Errorf(tx.Error.Error())
|
|
||||||
return nil, tx.Error
|
|
||||||
}
|
}
|
||||||
for _, v := range adapter {
|
if req.Type != "" {
|
||||||
|
db = db.Where("type = ?", req.Type)
|
||||||
|
}
|
||||||
|
if req.Version != "" {
|
||||||
|
db = db.Where("version = ?", req.Version)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = db.Where("deleted_at is null").Order("create_time desc").Find(&list).Error
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
rlist := make([]*types.ClusterRelationInfo, 0)
|
||||||
|
for _, v := range list {
|
||||||
cr := &types.ClusterRelationInfo{}
|
cr := &types.ClusterRelationInfo{}
|
||||||
utils.Convert(&v, &cr)
|
utils.Convert(&v, &cr)
|
||||||
clusters := make([]*types.ClusterInfo, 0)
|
clusters := make([]*types.ClusterInfo, 0)
|
||||||
|
@ -64,11 +76,12 @@ func (l *GetAdapterRelationLogic) GetAdapterRelation(req *types.AdapterQueryReq)
|
||||||
cr.COwnerId = c.OwnerId
|
cr.COwnerId = c.OwnerId
|
||||||
cr.CAuthType = c.AuthType
|
cr.CAuthType = c.AuthType
|
||||||
cr.CCreateTime = c.CreateTime
|
cr.CCreateTime = c.CreateTime
|
||||||
resp.List = append(resp.List, cr)
|
rlist = append(rlist, cr)
|
||||||
}
|
}
|
||||||
if len(clusters) == 0 {
|
if len(clusters) == 0 {
|
||||||
resp.List = append(resp.List, cr)
|
rlist = append(rlist, cr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
resp.List = rlist
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ func NewGetClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetClu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *GetClusterLogic) GetCluster(req *types.ClusterDelReq) (resp *types.ClusterInfo, err error) {
|
func (l *GetClusterLogic) GetCluster(req *types.FId) (resp *types.ClusterInfo, err error) {
|
||||||
resp = &types.ClusterInfo{}
|
resp = &types.ClusterInfo{}
|
||||||
db := l.svcCtx.DbEngin.Table("t_cluster").Where("id = ?", req.Id).First(&resp)
|
db := l.svcCtx.DbEngin.Table("t_cluster").Where("id = ?", req.Id).First(&resp)
|
||||||
if db.Error != nil {
|
if db.Error != nil {
|
||||||
|
|
|
@ -26,7 +26,7 @@ func NewUpdateClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Upd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *UpdateClusterLogic) UpdateCluster(req *types.ClusterReq) (resp *types.ClusterResp, err error) {
|
func (l *UpdateClusterLogic) UpdateCluster(req *types.ClusterCreateReq) (resp *types.ClusterResp, err error) {
|
||||||
cluster := &types.ClusterInfo{}
|
cluster := &types.ClusterInfo{}
|
||||||
result := l.svcCtx.DbEngin.Table("t_cluster").First(&cluster, req.Id)
|
result := l.svcCtx.DbEngin.Table("t_cluster").First(&cluster, req.Id)
|
||||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
)
|
||||||
|
|
||||||
|
type MetricsLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewMetricsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MetricsLogic {
|
||||||
|
return &MetricsLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *MetricsLogic) Metrics() error {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/tracker"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SyncClusterLoadLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSyncClusterLoadLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SyncClusterLoadLogic {
|
||||||
|
return &SyncClusterLoadLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *SyncClusterLoadLogic) SyncClusterLoad(req *types.SyncClusterLoadReq) error {
|
||||||
|
if len(req.ClusterLoadRecords) != 0 {
|
||||||
|
for _, record := range req.ClusterLoadRecords {
|
||||||
|
tracker.ClusterCpuGauge.WithLabelValues(record.ClusterName).Set(record.CpuUsage)
|
||||||
|
tracker.ClusterMemoryGauge.WithLabelValues(record.ClusterName).Set(record.MemoryUsage)
|
||||||
|
tracker.ClusterDiskGauge.WithLabelValues(record.ClusterName).Set(record.DiskUsage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -30,6 +30,7 @@ func (l *EditDictItemLogic) EditDictItem(req *types.DictItemEditReq) (resp *type
|
||||||
dictItem := &types.DictItemInfo{}
|
dictItem := &types.DictItemInfo{}
|
||||||
result := l.svcCtx.DbEngin.Table("t_dict_item").First(&dictItem, req.Id)
|
result := l.svcCtx.DbEngin.Table("t_dict_item").First(&dictItem, req.Id)
|
||||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||||
|
logx.Errorf("Dictionary data editing failure. errors: %s", err.Error())
|
||||||
return nil, errors.New("DictItem does not exist")
|
return nil, errors.New("DictItem does not exist")
|
||||||
}
|
}
|
||||||
utils.Convert(req, &dictItem)
|
utils.Convert(req, &dictItem)
|
||||||
|
|
|
@ -31,6 +31,7 @@ func (l *EditDictLogic) EditDict(req *types.DictEditReq) (resp *types.DictResp,
|
||||||
dict := &types.DictInfo{}
|
dict := &types.DictInfo{}
|
||||||
result := l.svcCtx.DbEngin.Table("t_dict").First(&dict, req.Id)
|
result := l.svcCtx.DbEngin.Table("t_dict").First(&dict, req.Id)
|
||||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||||
|
logx.Errorf("Dictionary editing failure. errors: %s", err.Error())
|
||||||
return nil, errors.New("Dict does not exist")
|
return nil, errors.New("Dict does not exist")
|
||||||
}
|
}
|
||||||
utils.Convert(req, &dict)
|
utils.Convert(req, &dict)
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
package dictionary
|
||||||
|
|
||||||
|
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 ListDictItemByCodeLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewListDictItemByCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListDictItemByCodeLogic {
|
||||||
|
return &ListDictItemByCodeLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *ListDictItemByCodeLogic) ListDictItemByCode(req *types.DictCodeReq) (resp *types.PageResult, err error) {
|
||||||
|
var dictList []types.DictItemInfo
|
||||||
|
resp = &types.PageResult{}
|
||||||
|
db := l.svcCtx.DbEngin.Model(&types.DictInfo{}).Table("t_dict")
|
||||||
|
|
||||||
|
// 左连接查询
|
||||||
|
db.Select("t_dict_item.*").Joins("left join t_dict_item on t_dict.id = t_dict_item.dict_id").
|
||||||
|
Where("t_dict.dict_code = ?", req.DictCode).
|
||||||
|
Where("t_dict_item.status", 1).
|
||||||
|
Order("t_dict_item.sort_order").Scan(&dictList)
|
||||||
|
if err != nil {
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
resp.List = dictList
|
||||||
|
return resp, nil
|
||||||
|
}
|
|
@ -2,8 +2,6 @@ package dictionary
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
|
||||||
|
@ -24,16 +22,44 @@ func NewListDictItemLogic(ctx context.Context, svcCtx *svc.ServiceContext) *List
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *ListDictItemLogic) ListDictItem(req *types.DictItemReq) (resp *types.DictItems, err error) {
|
func (l *ListDictItemLogic) ListDictItem(req *types.DictItemReq) (resp *types.PageResult, err error) {
|
||||||
resp = &types.DictItems{}
|
limit := req.PageSize
|
||||||
sql := fmt.Sprintf(`select c.* from t_dict_item c left join t_dict a on c.dict_id = a.id where c.deleted_at is null ORDER BY create_time Desc`)
|
offset := req.PageSize * (req.PageNum - 1)
|
||||||
|
resp = &types.PageResult{}
|
||||||
|
var dictList []types.DictItemInfo
|
||||||
|
db := l.svcCtx.DbEngin.Model(&types.DictItemInfo{}).Table("t_dict_item")
|
||||||
|
|
||||||
if req.ItemText != "" {
|
if req.ItemText != "" {
|
||||||
sql = fmt.Sprintf(`select c.* from t_dict_item c left join t_dict a on c.dict_id = a.id where c.deleted_at is null and c.item_text like '%%%s%%'`, req.ItemText)
|
db = db.Where("item_text LIKE ?", "%"+req.ItemText+"%")
|
||||||
}
|
}
|
||||||
tx := l.svcCtx.DbEngin.Raw(sql).Scan(&resp.List)
|
if req.ItemValue != "" {
|
||||||
if tx.Error != nil {
|
db = db.Where("item_value LIKE ?", "%"+req.ItemValue+"%")
|
||||||
logx.Errorf(tx.Error.Error())
|
|
||||||
return nil, tx.Error
|
|
||||||
}
|
}
|
||||||
|
if req.Type != "" {
|
||||||
|
db = db.Where("type = ?", req.Type)
|
||||||
|
}
|
||||||
|
if req.ParentId != "" {
|
||||||
|
db = db.Where("parent_id = ?", req.ParentId)
|
||||||
|
}
|
||||||
|
if req.Status != "" {
|
||||||
|
db = db.Where("status = ?", req.Status)
|
||||||
|
}
|
||||||
|
if req.DictId != "" {
|
||||||
|
db = db.Where("dict_id = ?", req.DictId)
|
||||||
|
}
|
||||||
|
var total int64
|
||||||
|
err = db.Count(&total).Error
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
db = db.Limit(limit).Offset(offset)
|
||||||
|
err = db.Order("create_time desc").Find(&dictList).Error
|
||||||
|
|
||||||
|
resp.List = dictList
|
||||||
|
resp.PageSize = req.PageSize
|
||||||
|
resp.PageNum = req.PageNum
|
||||||
|
resp.Total = total
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,6 @@ package dictionary
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||||
|
|
||||||
|
@ -24,16 +22,38 @@ func NewListDictLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListDict
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *ListDictLogic) ListDict(req *types.DictReq) (resp *types.Dicts, err error) {
|
func (l *ListDictLogic) ListDict(req *types.DictReq) (resp *types.PageResult, err error) {
|
||||||
resp = &types.Dicts{}
|
limit := req.PageSize
|
||||||
sqlStr := "select * from t_dict where `deleted_at` IS NULL ORDER BY create_time Desc"
|
offset := req.PageSize * (req.PageNum - 1)
|
||||||
|
resp = &types.PageResult{}
|
||||||
|
var dictList []types.DictInfo
|
||||||
|
db := l.svcCtx.DbEngin.Model(&types.DictInfo{}).Table("t_dict")
|
||||||
|
|
||||||
if req.DictName != "" {
|
if req.DictName != "" {
|
||||||
sqlStr = fmt.Sprintf("select * from t_dict where `deleted_at` IS NULL and dict_name like '%%%s%%' ORDER BY create_time Desc", req.DictName)
|
db = db.Where("dict_name LIKE ?", "%"+req.DictName+"%")
|
||||||
}
|
}
|
||||||
tx := l.svcCtx.DbEngin.Raw(sqlStr).Scan(&resp.List)
|
if req.DictCode != "" {
|
||||||
if tx.Error != nil {
|
db = db.Where("dict_code LIKE ?", "%"+req.DictCode+"%")
|
||||||
logx.Errorf(tx.Error.Error())
|
|
||||||
return nil, tx.Error
|
|
||||||
}
|
}
|
||||||
|
if req.Type != "" {
|
||||||
|
db = db.Where("type = ?", req.Type)
|
||||||
|
}
|
||||||
|
if req.Status != "" {
|
||||||
|
db = db.Where("status = ?", req.Status)
|
||||||
|
}
|
||||||
|
var total int64
|
||||||
|
err = db.Count(&total).Error
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
db = db.Limit(limit).Offset(offset)
|
||||||
|
err = db.Order("create_time desc").Find(&dictList).Error
|
||||||
|
|
||||||
|
resp.List = dictList
|
||||||
|
resp.PageSize = req.PageSize
|
||||||
|
resp.PageNum = req.PageNum
|
||||||
|
resp.Total = total
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,8 @@ const (
|
||||||
SAILINGSI = "sailingsi"
|
SAILINGSI = "sailingsi"
|
||||||
MLU = "MLU"
|
MLU = "MLU"
|
||||||
CAMBRICONMLU290 = 256
|
CAMBRICONMLU290 = 256
|
||||||
GCU = "enflame"
|
GCU = "GCU"
|
||||||
|
ENFLAME = "enflame"
|
||||||
EnflameT20 = 128
|
EnflameT20 = 128
|
||||||
BASE_TOPS = 128
|
BASE_TOPS = 128
|
||||||
CAMBRICON = "cambricon"
|
CAMBRICON = "cambricon"
|
||||||
|
@ -57,7 +58,7 @@ const (
|
||||||
var (
|
var (
|
||||||
cardAliasMap = map[string]string{
|
cardAliasMap = map[string]string{
|
||||||
MLU: CAMBRICON,
|
MLU: CAMBRICON,
|
||||||
GCU: GCU,
|
GCU: ENFLAME,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -341,11 +342,10 @@ func (o *OctopusLink) generateResourceId(option *option.AiOption) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if option.ResourceType == CARD {
|
if option.ResourceType == CARD {
|
||||||
err = setResourceIdByCard(option, specResp, MLU)
|
err = setResourceIdByCard(option, specResp, GCU)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -418,16 +418,23 @@ func (o *OctopusLink) generateImageId(option *option.AiOption) error {
|
||||||
if !preImgResp.Success {
|
if !preImgResp.Success {
|
||||||
return errors.New("failed to get PresetImages")
|
return errors.New("failed to get PresetImages")
|
||||||
}
|
}
|
||||||
for _, image := range preImgResp.Payload.Images {
|
|
||||||
if strings.Contains(image.ImageName, option.TaskType) && strings.Contains(image.ImageName, cardAliasMap[option.ComputeCard]) {
|
if option.ResourceType == CARD {
|
||||||
option.ImageId = image.Id
|
for _, image := range preImgResp.Payload.Images {
|
||||||
return nil
|
if strings.Contains(image.ImageName, cardAliasMap[option.ComputeCard]) {
|
||||||
|
option.ImageId = image.Id
|
||||||
|
return nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors.New("failed to get ImageId")
|
return errors.New("failed to get ImageId")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OctopusLink) generateAlgorithmId(option *option.AiOption) error {
|
func (o *OctopusLink) generateAlgorithmId(option *option.AiOption) error {
|
||||||
|
// temporarily set algorithm to cnn
|
||||||
|
option.AlgorithmName = "cnn"
|
||||||
|
|
||||||
req := &octopus.GetMyAlgorithmListReq{
|
req := &octopus.GetMyAlgorithmListReq{
|
||||||
Platform: o.platform,
|
Platform: o.platform,
|
||||||
PageIndex: o.pageIndex,
|
PageIndex: o.pageIndex,
|
||||||
|
@ -442,18 +449,33 @@ func (o *OctopusLink) generateAlgorithmId(option *option.AiOption) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, algorithm := range resp.Payload.Algorithms {
|
for _, algorithm := range resp.Payload.Algorithms {
|
||||||
if algorithm.FrameworkName == strings.Title(option.TaskType) && strings.Contains(algorithm.AlgorithmName, option.DatasetsName) {
|
if algorithm.FrameworkName == strings.Title(option.TaskType) {
|
||||||
|
ns := strings.Split(algorithm.AlgorithmName, UNDERSCORE)
|
||||||
|
if ns[0] != option.DatasetsName {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if ns[1] != option.AlgorithmName {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if ns[2] != option.ResourceType {
|
||||||
|
continue
|
||||||
|
}
|
||||||
option.AlgorithmId = algorithm.AlgorithmId
|
option.AlgorithmId = algorithm.AlgorithmId
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return errors.New("failed to get AlgorithmId")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OctopusLink) generateCmd(option *option.AiOption) error {
|
func (o *OctopusLink) generateCmd(option *option.AiOption) error {
|
||||||
if option.Cmd == "" {
|
if option.Cmd == "" {
|
||||||
option.Cmd = TRAIN_CMD
|
switch option.ComputeCard {
|
||||||
|
case GCU:
|
||||||
|
option.Cmd = "cd /code; python3 train.py"
|
||||||
|
default:
|
||||||
|
option.Cmd = TRAIN_CMD
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -57,17 +57,17 @@ var RESOURCESGAIMAP = map[string]ResourceSpecSGAI{
|
||||||
},
|
},
|
||||||
"OBtVaaXAv9n9FbLR7pWAoa3yR13jXwNc": {
|
"OBtVaaXAv9n9FbLR7pWAoa3yR13jXwNc": {
|
||||||
CPU: 2,
|
CPU: 2,
|
||||||
GPU: 1,
|
GPU: 3,
|
||||||
RAM: 4 * RAM_SIZE_1G,
|
RAM: 4 * RAM_SIZE_1G,
|
||||||
},
|
},
|
||||||
"sBWfpkntUzsWYly11kdwEHZOYYIsFmve": {
|
"sBWfpkntUzsWYly11kdwEHZOYYIsFmve": {
|
||||||
CPU: 5,
|
CPU: 4,
|
||||||
GPU: 1,
|
GPU: 4,
|
||||||
RAM: 10 * RAM_SIZE_1G,
|
RAM: 8 * RAM_SIZE_1G,
|
||||||
},
|
},
|
||||||
"jeYBVPwyIALjVYNzHvysh2o5CsBpBLp2": {
|
"jeYBVPwyIALjVYNzHvysh2o5CsBpBLp2": {
|
||||||
CPU: 5,
|
CPU: 5,
|
||||||
GPU: 2,
|
GPU: 5,
|
||||||
RAM: 10 * RAM_SIZE_1G,
|
RAM: 10 * RAM_SIZE_1G,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -75,9 +75,9 @@ var RESOURCESGAIMAP = map[string]ResourceSpecSGAI{
|
||||||
var RESOURCESPECSAI = map[string]string{
|
var RESOURCESPECSAI = map[string]string{
|
||||||
"WodTB2rJ8SobMgQ1nrtR245jxOrsovFi": "CPU:1, DCU:1, RAM:2G",
|
"WodTB2rJ8SobMgQ1nrtR245jxOrsovFi": "CPU:1, DCU:1, RAM:2G",
|
||||||
"6d41v1XV53MQPmQOJ5kNatIck9yl8nWZ": "CPU:1, DCU:2, RAM:2G",
|
"6d41v1XV53MQPmQOJ5kNatIck9yl8nWZ": "CPU:1, DCU:2, RAM:2G",
|
||||||
"OBtVaaXAv9n9FbLR7pWAoa3yR13jXwNc": "CPU:2, DCU:1, RAM:4G",
|
"OBtVaaXAv9n9FbLR7pWAoa3yR13jXwNc": "CPU:2, DCU:3, RAM:4G",
|
||||||
"sBWfpkntUzsWYly11kdwEHZOYYIsFmve": "CPU:5, DCU:1, RAM:10G",
|
"sBWfpkntUzsWYly11kdwEHZOYYIsFmve": "CPU:4, DCU:4, RAM:8G",
|
||||||
"jeYBVPwyIALjVYNzHvysh2o5CsBpBLp2": "CPU:5, DCU:2, RAM:10G",
|
"jeYBVPwyIALjVYNzHvysh2o5CsBpBLp2": "CPU:5, DCU:5, RAM:10G",
|
||||||
}
|
}
|
||||||
|
|
||||||
type ResourceSpecSGAI struct {
|
type ResourceSpecSGAI struct {
|
||||||
|
@ -352,18 +352,29 @@ func (s *ShuguangAi) generateResourceId(option *option.AiOption) error {
|
||||||
|
|
||||||
if option.ResourceType == CPU {
|
if option.ResourceType == CPU {
|
||||||
option.ResourceId = "WodTB2rJ8SobMgQ1nrtR245jxOrsovFi"
|
option.ResourceId = "WodTB2rJ8SobMgQ1nrtR245jxOrsovFi"
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if option.ResourceType == CARD {
|
if option.ResourceType == CARD {
|
||||||
if option.Tops == 0 {
|
if 0 <= option.Tops && option.Tops <= DCU_TOPS {
|
||||||
option.ResourceId = "WodTB2rJ8SobMgQ1nrtR245jxOrsovFi"
|
option.ResourceId = "WodTB2rJ8SobMgQ1nrtR245jxOrsovFi"
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if option.Tops > DCU_TOPS {
|
cardNum := 5
|
||||||
|
for k, v := range RESOURCESGAIMAP {
|
||||||
|
for i := 1; i <= cardNum; i++ {
|
||||||
|
if float64(i)*DCU_TOPS <= option.Tops && option.Tops <= float64(v.GPU)*DCU_TOPS {
|
||||||
|
option.ResourceId = k
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if option.Tops > float64(cardNum)*DCU_TOPS {
|
||||||
option.ResourceId = "jeYBVPwyIALjVYNzHvysh2o5CsBpBLp2"
|
option.ResourceId = "jeYBVPwyIALjVYNzHvysh2o5CsBpBLp2"
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//Todo add more dcu specs
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors.New("failed to get ResourceId")
|
return errors.New("failed to get ResourceId")
|
||||||
|
@ -386,7 +397,12 @@ func (s *ShuguangAi) generateImageId(option *option.AiOption) error {
|
||||||
return errors.New("failed to get imageId")
|
return errors.New("failed to get imageId")
|
||||||
}
|
}
|
||||||
|
|
||||||
if option.ResourceType == CPU {
|
for _, datum := range resp.Data {
|
||||||
|
ns := strings.Split(datum.Version, COLON)
|
||||||
|
if ns[0] == "jupyterlab-pytorch" {
|
||||||
|
option.ImageId = datum.ImageId
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,6 +428,7 @@ func (s *ShuguangAi) generateAlgorithmId(option *option.AiOption) error {
|
||||||
if ns[0] == option.DatasetsName {
|
if ns[0] == option.DatasetsName {
|
||||||
algorithmId = option.TaskType + DASH + file.Name
|
algorithmId = option.TaskType + DASH + file.Name
|
||||||
option.AlgorithmId = algorithmId
|
option.AlgorithmId = algorithmId
|
||||||
|
option.AlgorithmName = ns[1]
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -430,6 +447,23 @@ func (s *ShuguangAi) generateEnv(option *option.AiOption) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ShuguangAi) generateParams(option *option.AiOption) error {
|
func (s *ShuguangAi) generateParams(option *option.AiOption) error {
|
||||||
|
if option.ResourceType == "" {
|
||||||
|
return errors.New("ResourceType not set")
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
//epoch := "epoch" + COMMA + "1"
|
||||||
|
//option.Params = append(option.Params, epoch)
|
||||||
|
|
||||||
|
switch option.ResourceType {
|
||||||
|
case CPU:
|
||||||
|
card := "card" + COMMA + CPU
|
||||||
|
option.Params = append(option.Params, card)
|
||||||
|
return nil
|
||||||
|
case CARD:
|
||||||
|
card := "card" + COMMA + "cuda:0"
|
||||||
|
option.Params = append(option.Params, card)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return errors.New("failed to set params")
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ type Linkage interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
COLON = ":"
|
||||||
PY_PARAM_PREFIX = "--"
|
PY_PARAM_PREFIX = "--"
|
||||||
SPACE = " "
|
SPACE = " "
|
||||||
UNDERSCORE = "_"
|
UNDERSCORE = "_"
|
||||||
|
|
|
@ -38,6 +38,7 @@ import (
|
||||||
"gitlink.org.cn/jcce-pcm/pcm-participant-octopus/octopusclient"
|
"gitlink.org.cn/jcce-pcm/pcm-participant-octopus/octopusclient"
|
||||||
"gorm.io/driver/mysql"
|
"gorm.io/driver/mysql"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
"gorm.io/gorm/logger"
|
||||||
"gorm.io/gorm/schema"
|
"gorm.io/gorm/schema"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -84,6 +85,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
||||||
NamingStrategy: schema.NamingStrategy{
|
NamingStrategy: schema.NamingStrategy{
|
||||||
SingularTable: true, // 使用单数表名,启用该选项,此时,`User` 的表名应该是 `t_user`
|
SingularTable: true, // 使用单数表名,启用该选项,此时,`User` 的表名应该是 `t_user`
|
||||||
},
|
},
|
||||||
|
Logger: logger.Default.LogMode(logger.Info),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Errorf("数据库连接失败, err%v", err)
|
logx.Errorf("数据库连接失败, err%v", err)
|
||||||
|
|
|
@ -24,6 +24,17 @@ type CenterIndex struct {
|
||||||
CenterType string `json:"centerType"`
|
CenterType string `json:"centerType"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SyncClusterLoadReq struct {
|
||||||
|
ClusterLoadRecords []ClusterLoadRecord `json:"clusterLoadRecords"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClusterLoadRecord struct {
|
||||||
|
ClusterName string `json:"clusterName"`
|
||||||
|
CpuUsage float64 `json:"cpuUsage"`
|
||||||
|
MemoryUsage float64 `json:"memoryUsage"`
|
||||||
|
DiskUsage float64 `json:"diskUsage"`
|
||||||
|
}
|
||||||
|
|
||||||
type GetClusterListReq struct {
|
type GetClusterListReq struct {
|
||||||
Id int64 `form:"id"`
|
Id int64 `form:"id"`
|
||||||
}
|
}
|
||||||
|
@ -504,6 +515,7 @@ type AdapterQueryReq struct {
|
||||||
Nickname string `form:"nickname,optional"`
|
Nickname string `form:"nickname,optional"`
|
||||||
Version string `form:"version,optional"`
|
Version string `form:"version,optional"`
|
||||||
Server string `form:"server,optional"`
|
Server string `form:"server,optional"`
|
||||||
|
PageInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
type AdapterReq struct {
|
type AdapterReq struct {
|
||||||
|
@ -564,6 +576,31 @@ type AdapterRelation struct {
|
||||||
type ClusterReq struct {
|
type ClusterReq struct {
|
||||||
Id string `form:"id,optional"`
|
Id string `form:"id,optional"`
|
||||||
AdapterId string `form:"adapterId,optional"`
|
AdapterId string `form:"adapterId,optional"`
|
||||||
|
Name string `form:"name,optional"`
|
||||||
|
Nickname string `form:"nickname,optional"`
|
||||||
|
Description string `form:"description,optional"`
|
||||||
|
Server string `form:"server,optional"`
|
||||||
|
MonitorServer string `form:"monitorServer,optional"`
|
||||||
|
Username string `form:"username,optional"`
|
||||||
|
Password string `form:"password,optional"`
|
||||||
|
Token string `form:"token,optional"`
|
||||||
|
Ak string `form:"ak,optional"`
|
||||||
|
Sk string `form:"sk,optional"`
|
||||||
|
Region string `form:"region,optional"`
|
||||||
|
ProjectId string `form:"projectId,optional"`
|
||||||
|
Version string `form:"version,optional"`
|
||||||
|
Label string `form:"label,optional"`
|
||||||
|
OwnerId string `form:"ownerId,omitempty,optional"`
|
||||||
|
AuthType string `form:"authType,optional"`
|
||||||
|
Type string `form:"type,optional"`
|
||||||
|
ProducerDict string `form:"producerDict,optional"`
|
||||||
|
RegionDict string `form:"regionDict,optional"`
|
||||||
|
PageInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClusterCreateReq struct {
|
||||||
|
Id string `json:"id,optional"`
|
||||||
|
AdapterId string `json:"adapterId,optional"`
|
||||||
Name string `json:"name,optional"`
|
Name string `json:"name,optional"`
|
||||||
Nickname string `json:"nickname,optional"`
|
Nickname string `json:"nickname,optional"`
|
||||||
Description string `json:"description,optional"`
|
Description string `json:"description,optional"`
|
||||||
|
@ -580,11 +617,8 @@ type ClusterReq struct {
|
||||||
Label string `json:"label,optional"`
|
Label string `json:"label,optional"`
|
||||||
OwnerId string `json:"ownerId,omitempty,optional"`
|
OwnerId string `json:"ownerId,omitempty,optional"`
|
||||||
AuthType string `json:"authType,optional"`
|
AuthType string `json:"authType,optional"`
|
||||||
Type string `json:"type,optional"`
|
ProducerDict string `json:"producerDict,optional"`
|
||||||
}
|
RegionDict string `json:"regionDict,optional"`
|
||||||
|
|
||||||
type ClusterDelReq struct {
|
|
||||||
Id string `form:"id,optional"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClusterInfo struct {
|
type ClusterInfo struct {
|
||||||
|
@ -606,9 +640,15 @@ type ClusterInfo struct {
|
||||||
Label string `json:"label,omitempty" db:"label"`
|
Label string `json:"label,omitempty" db:"label"`
|
||||||
OwnerId string `json:"ownerId,omitempty" db:"owner_id"`
|
OwnerId string `json:"ownerId,omitempty" db:"owner_id"`
|
||||||
AuthType string `json:"authType,omitempty" db:"auth_type"`
|
AuthType string `json:"authType,omitempty" db:"auth_type"`
|
||||||
|
ProducerDict string `json:"producerDict,omitempty" db:"producer_dict"`
|
||||||
|
RegionDict string `json:"regionDict,omitempty" db:"region_dict"`
|
||||||
CreateTime string `json:"createTime,omitempty" db:"created_time" gorm:"autoCreateTime"`
|
CreateTime string `json:"createTime,omitempty" db:"created_time" gorm:"autoCreateTime"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ClusterDelReq struct {
|
||||||
|
Id string `form:"id,optional"`
|
||||||
|
}
|
||||||
|
|
||||||
type ClusterResp struct {
|
type ClusterResp struct {
|
||||||
List ClusterInfo `json:"list,omitempty"`
|
List ClusterInfo `json:"list,omitempty"`
|
||||||
}
|
}
|
||||||
|
@ -672,6 +712,7 @@ type DictReq struct {
|
||||||
Description string `form:"description,optional"`
|
Description string `form:"description,optional"`
|
||||||
Type string `form:"type,optional"`
|
Type string `form:"type,optional"`
|
||||||
Status string `form:"status,optional"`
|
Status string `form:"status,optional"`
|
||||||
|
PageInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
type DictEditReq struct {
|
type DictEditReq struct {
|
||||||
|
@ -721,6 +762,7 @@ type DictItemReq struct {
|
||||||
Type string `form:"type,optional"`
|
Type string `form:"type,optional"`
|
||||||
ParentId string `form:"parentId,optional"`
|
ParentId string `form:"parentId,optional"`
|
||||||
Status string `form:"status,optional"`
|
Status string `form:"status,optional"`
|
||||||
|
PageInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
type DictItemEditReq struct {
|
type DictItemEditReq struct {
|
||||||
|
@ -753,6 +795,10 @@ type DictItems struct {
|
||||||
List []DictItemInfo `json:"list,omitempty"`
|
List []DictItemInfo `json:"list,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DictCodeReq struct {
|
||||||
|
DictCode string `path:"dictCode"`
|
||||||
|
}
|
||||||
|
|
||||||
type CId struct {
|
type CId struct {
|
||||||
Id string `path:"id":"id,omitempty" validate:"required"`
|
Id string `path:"id":"id,omitempty" validate:"required"`
|
||||||
}
|
}
|
||||||
|
@ -761,6 +807,22 @@ type CIds struct {
|
||||||
Ids []string `json:"ids,omitempty" validate:"required"`
|
Ids []string `json:"ids,omitempty" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type FId struct {
|
||||||
|
Id string `form:"id":"id,omitempty" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PageInfo struct {
|
||||||
|
PageNum int `form:"pageNum"`
|
||||||
|
PageSize int `form:"pageSize"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PageResult struct {
|
||||||
|
List interface{} `json:"list,omitempty"`
|
||||||
|
Total int64 `json:"total,omitempty"`
|
||||||
|
PageNum int `json:"pageNum,omitempty"`
|
||||||
|
PageSize int `json:"pageSize,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
type Job struct {
|
type Job struct {
|
||||||
SlurmVersion string `json:"slurmVersion"`
|
SlurmVersion string `json:"slurmVersion"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
@ -2507,8 +2569,6 @@ type Limits struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetComputeLimitsReq struct {
|
type GetComputeLimitsReq struct {
|
||||||
Limit int32 `json:"limit,optional"`
|
|
||||||
OffSet int32 `json:"offSet,optional"`
|
|
||||||
Platform string `json:"platform,optional"`
|
Platform string `json:"platform,optional"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2541,8 +2601,6 @@ type VolumeLimits struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetVolumeLimitsReq struct {
|
type GetVolumeLimitsReq struct {
|
||||||
Limit int32 `json:"limit,optional"`
|
|
||||||
OffSet int32 `json:"offSet,optional"`
|
|
||||||
Platform string `json:"platform,optional"`
|
Platform string `json:"platform,optional"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
6
go.mod
6
go.mod
|
@ -27,7 +27,6 @@ require (
|
||||||
gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240307072630-6ff50727536a
|
gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240307072630-6ff50727536a
|
||||||
gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5
|
gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5
|
||||||
gitlink.org.cn/jcce-pcm/pcm-ac v0.0.0-20240301085553-f6ad88fa357a
|
gitlink.org.cn/jcce-pcm/pcm-ac v0.0.0-20240301085553-f6ad88fa357a
|
||||||
gitlink.org.cn/jcce-pcm/pcm-coordinator v0.1.19
|
|
||||||
gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d
|
gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d
|
||||||
gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20231101085149-724c7c4cc090
|
gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20231101085149-724c7c4cc090
|
||||||
gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20240222124813-e275cfa342f4
|
gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20240222124813-e275cfa342f4
|
||||||
|
@ -44,6 +43,7 @@ require (
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
|
||||||
github.com/Microsoft/go-winio v0.6.1 // indirect
|
github.com/Microsoft/go-winio v0.6.1 // indirect
|
||||||
github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 // indirect
|
github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 // indirect
|
||||||
github.com/alibabacloud-go/tea v1.1.17 // indirect
|
github.com/alibabacloud-go/tea v1.1.17 // indirect
|
||||||
|
@ -97,9 +97,6 @@ require (
|
||||||
github.com/prometheus/procfs v0.12.0 // indirect
|
github.com/prometheus/procfs v0.12.0 // indirect
|
||||||
github.com/redis/go-redis/v9 v9.5.1 // indirect
|
github.com/redis/go-redis/v9 v9.5.1 // indirect
|
||||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||||
gitlink.org.cn/jcce-pcm/pcm-participant-kubernetes v0.0.0-20231214084401-de9ac5db7246 // indirect
|
|
||||||
gitlink.org.cn/jcce-pcm/pcm-participant-openstack v0.0.0-20231102023739-81a3d353c10d // indirect
|
|
||||||
gitlink.org.cn/jcce-pcm/pcm-slurm v0.0.0-20231107115628-f74106c47dfa // indirect
|
|
||||||
go.etcd.io/etcd/api/v3 v3.5.12 // indirect
|
go.etcd.io/etcd/api/v3 v3.5.12 // indirect
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.12 // indirect
|
go.etcd.io/etcd/client/pkg/v3 v3.5.12 // indirect
|
||||||
go.etcd.io/etcd/client/v3 v3.5.12 // indirect
|
go.etcd.io/etcd/client/v3 v3.5.12 // indirect
|
||||||
|
@ -117,6 +114,7 @@ require (
|
||||||
go.uber.org/multierr v1.11.0 // indirect
|
go.uber.org/multierr v1.11.0 // indirect
|
||||||
go.uber.org/zap v1.27.0 // indirect
|
go.uber.org/zap v1.27.0 // indirect
|
||||||
golang.org/x/crypto v0.21.0 // indirect
|
golang.org/x/crypto v0.21.0 // indirect
|
||||||
|
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
|
||||||
golang.org/x/mod v0.15.0 // indirect
|
golang.org/x/mod v0.15.0 // indirect
|
||||||
golang.org/x/net v0.22.0 // indirect
|
golang.org/x/net v0.22.0 // indirect
|
||||||
golang.org/x/oauth2 v0.18.0 // indirect
|
golang.org/x/oauth2 v0.18.0 // indirect
|
||||||
|
|
8
go.sum
8
go.sum
|
@ -1006,20 +1006,12 @@ gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5 h1:+/5vnz
|
||||||
gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5/go.mod h1:97AlUXN13g9UN3+9/DzCHpeoU5sbdyv0IQuTEHNexzQ=
|
gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5/go.mod h1:97AlUXN13g9UN3+9/DzCHpeoU5sbdyv0IQuTEHNexzQ=
|
||||||
gitlink.org.cn/jcce-pcm/pcm-ac v0.0.0-20240301085553-f6ad88fa357a h1:fY1KmyZ6O7wVBvgt2HB+C9e1DncJdk/Wkv8m5Qz7abw=
|
gitlink.org.cn/jcce-pcm/pcm-ac v0.0.0-20240301085553-f6ad88fa357a h1:fY1KmyZ6O7wVBvgt2HB+C9e1DncJdk/Wkv8m5Qz7abw=
|
||||||
gitlink.org.cn/jcce-pcm/pcm-ac v0.0.0-20240301085553-f6ad88fa357a/go.mod h1:oMaWf5sEDFKTfCbIlT6/7IFI3f6PsuiRnWzzQruSF5Q=
|
gitlink.org.cn/jcce-pcm/pcm-ac v0.0.0-20240301085553-f6ad88fa357a/go.mod h1:oMaWf5sEDFKTfCbIlT6/7IFI3f6PsuiRnWzzQruSF5Q=
|
||||||
gitlink.org.cn/jcce-pcm/pcm-coordinator v0.1.19 h1:qeBcLo7NTGPsowxxgc7dD+fdWHEOZBrt1vY26+3wv+k=
|
|
||||||
gitlink.org.cn/jcce-pcm/pcm-coordinator v0.1.19/go.mod h1:0dHxKCTjH3ud1qRQZjE6EqXSs3NTOpiHWTpaip4mrWE=
|
|
||||||
gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d h1:DHjl/rLuH2gKYtY0MKMGNQDHFT12APg25RlMUQo+tHk=
|
gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d h1:DHjl/rLuH2gKYtY0MKMGNQDHFT12APg25RlMUQo+tHk=
|
||||||
gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d/go.mod h1:r/KLzUpupCV5jdxSfgDhc2pVjP0fBi3VhAWRttsBn30=
|
gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d/go.mod h1:r/KLzUpupCV5jdxSfgDhc2pVjP0fBi3VhAWRttsBn30=
|
||||||
gitlink.org.cn/jcce-pcm/pcm-participant-kubernetes v0.0.0-20231214084401-de9ac5db7246 h1:VVyI1H3hRv5tDWHt41jIlrucmxF10z3bMqv/hIwCcw0=
|
|
||||||
gitlink.org.cn/jcce-pcm/pcm-participant-kubernetes v0.0.0-20231214084401-de9ac5db7246/go.mod h1:LM+XeDayimN6b1AY7AhNbbhq9HJyS0u7tszMCNsNmAo=
|
|
||||||
gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20231101085149-724c7c4cc090 h1:jztlHo72bcWM1jUwvG3Hfk2K+AJL0RvlsdIqlktH/MI=
|
gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20231101085149-724c7c4cc090 h1:jztlHo72bcWM1jUwvG3Hfk2K+AJL0RvlsdIqlktH/MI=
|
||||||
gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20231101085149-724c7c4cc090/go.mod h1:pisJKAI8FRFFUcBaH3Gob+ENXWRM97rpuYmv9s1raag=
|
gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20231101085149-724c7c4cc090/go.mod h1:pisJKAI8FRFFUcBaH3Gob+ENXWRM97rpuYmv9s1raag=
|
||||||
gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20240222124813-e275cfa342f4 h1:NrxKAZ5uAzshB9EHcPw+XTOTzpxb5HslNRMYBrFC1Qo=
|
gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20240222124813-e275cfa342f4 h1:NrxKAZ5uAzshB9EHcPw+XTOTzpxb5HslNRMYBrFC1Qo=
|
||||||
gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20240222124813-e275cfa342f4/go.mod h1:uyvpVqG1jHDXX+ubXI0RBwnWXzVykD/mliqGQIDvRoo=
|
gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20240222124813-e275cfa342f4/go.mod h1:uyvpVqG1jHDXX+ubXI0RBwnWXzVykD/mliqGQIDvRoo=
|
||||||
gitlink.org.cn/jcce-pcm/pcm-participant-openstack v0.0.0-20231102023739-81a3d353c10d h1:hdSxVD+AN7W6j847/GsnNgOAX5IdRQRV1KLz+d4FlS0=
|
|
||||||
gitlink.org.cn/jcce-pcm/pcm-participant-openstack v0.0.0-20231102023739-81a3d353c10d/go.mod h1:m75SVNfNa1TUBlQtBfR0CeETQ0ez2RIUqlSCn1Mb/js=
|
|
||||||
gitlink.org.cn/jcce-pcm/pcm-slurm v0.0.0-20231107115628-f74106c47dfa h1:U0YV9ju5OPpUe8iUk4OEUtYJlINgpI0vgLC1IfZ2JUY=
|
|
||||||
gitlink.org.cn/jcce-pcm/pcm-slurm v0.0.0-20231107115628-f74106c47dfa/go.mod h1:tqj8GWoM2P21agWvJyUwN1U37CqfALwZTkRs9Ekgrbw=
|
|
||||||
go.etcd.io/etcd/api/v3 v3.5.7/go.mod h1:9qew1gCdDDLu+VwmeG+iFpL+QlpHTo7iubavdVDgCAA=
|
go.etcd.io/etcd/api/v3 v3.5.7/go.mod h1:9qew1gCdDDLu+VwmeG+iFpL+QlpHTo7iubavdVDgCAA=
|
||||||
go.etcd.io/etcd/api/v3 v3.5.12 h1:W4sw5ZoU2Juc9gBWuLk5U6fHfNVyY1WC5g9uiXZio/c=
|
go.etcd.io/etcd/api/v3 v3.5.12 h1:W4sw5ZoU2Juc9gBWuLk5U6fHfNVyY1WC5g9uiXZio/c=
|
||||||
go.etcd.io/etcd/api/v3 v3.5.12/go.mod h1:Ot+o0SWSyT6uHhA56al1oCED0JImsRiU9Dc26+C2a+4=
|
go.etcd.io/etcd/api/v3 v3.5.12/go.mod h1:Ot+o0SWSyT6uHhA56al1oCED0JImsRiU9Dc26+C2a+4=
|
||||||
|
|
|
@ -254,6 +254,7 @@ type ControllerOption struct {
|
||||||
Namespace string
|
Namespace string
|
||||||
Kind string
|
Kind string
|
||||||
WorkloadName string
|
WorkloadName string
|
||||||
|
PodsName string
|
||||||
Level string
|
Level string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/prometheus/client_golang/api"
|
"github.com/prometheus/client_golang/api"
|
||||||
v1 "github.com/prometheus/client_golang/api/prometheus/v1"
|
v1 "github.com/prometheus/client_golang/api/prometheus/v1"
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/common/model"
|
"github.com/prometheus/common/model"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -25,6 +26,30 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ClusterCpuGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||||
|
Name: "cluster_cpu_usage",
|
||||||
|
Help: "Cluster CPU Utilization Rate.",
|
||||||
|
}, []string{"cluster_name"})
|
||||||
|
ClusterMemoryGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||||
|
Name: "cluster_memory_usage",
|
||||||
|
Help: "Cluster Memory Utilization Rate.",
|
||||||
|
}, []string{"cluster_name"})
|
||||||
|
ClusterDiskGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||||
|
Name: "cluster_disk_usage",
|
||||||
|
Help: "Cluster Disk Utilization Rate.",
|
||||||
|
}, []string{"cluster_name"})
|
||||||
|
metrics = []prometheus.Collector{
|
||||||
|
ClusterCpuGauge,
|
||||||
|
ClusterMemoryGauge,
|
||||||
|
ClusterDiskGauge,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
prometheus.MustRegister(metrics...)
|
||||||
|
}
|
||||||
|
|
||||||
type Prometheus struct {
|
type Prometheus struct {
|
||||||
prometheus Interface
|
prometheus Interface
|
||||||
client v1.API
|
client v1.API
|
||||||
|
|
|
@ -4,7 +4,8 @@ ListenOn: 0.0.0.0:2004
|
||||||
Timeout: 15000 # 15s,设置rpc服务的响应的超时时间,若超过15s还未返回则结束请求
|
Timeout: 15000 # 15s,设置rpc服务的响应的超时时间,若超过15s还未返回则结束请求
|
||||||
|
|
||||||
DB:
|
DB:
|
||||||
DataSource: root:uJpLd6u-J?HC1@(10.206.0.12:3306)/pcm?parseTime=true
|
# DataSource: root:uJpLd6u-J?HC1@(10.206.0.12:3306)/pcm?parseTime=true
|
||||||
|
DataSource: root:uJpLd6u-J?HC1@(47.92.88.143:3306)/pcm?parseTime=true
|
||||||
|
|
||||||
#链路追踪
|
#链路追踪
|
||||||
# Telemetry:
|
# Telemetry:
|
||||||
|
|
Loading…
Reference in New Issue