repeat cluster name validate
Former-commit-id: 9c04866bf2dce4392d3c1224c1b7b9100d4283b9
This commit is contained in:
parent
dfdedd7689
commit
d80c49dccb
|
@ -22,7 +22,6 @@ type (
|
|||
Name string `form:"name"` // 名称
|
||||
Address string `form:"address"` // 地址
|
||||
token string `form:"token"` // 数算集群token
|
||||
Type string `form:"type"` // 参与者类型:CLOUD-数算集群;AI-智算集群;HPC-超算集群
|
||||
MetricsUrl string `form:"metricsUrl"` //监控url
|
||||
}
|
||||
|
||||
|
|
|
@ -177,11 +177,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||
Path: "/cloud/deleteCluster",
|
||||
Handler: cloud.DeleteClusterHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/cloud/listCluster",
|
||||
Handler: cloud.ListCloudClusterHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/cloud/noticeTenant",
|
||||
|
|
|
@ -23,11 +23,15 @@ func NewDeleteClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Del
|
|||
}
|
||||
}
|
||||
|
||||
func (l *DeleteClusterLogic) DeleteCluster(req *types.DeleteClusterReq) (resp *types.CloudResp, err error) {
|
||||
func (l *DeleteClusterLogic) DeleteCluster(req *types.DeleteClusterReq) (*types.CloudResp, error) {
|
||||
// 删除集群信息
|
||||
var resp types.CloudResp
|
||||
tx := l.svcCtx.DbEngin.Where("name = ?", req.Name).Delete(&models.ScParticipantPhyInfo{})
|
||||
if tx.Error != nil {
|
||||
return nil, tx.Error
|
||||
}
|
||||
return
|
||||
resp.Code = string(200)
|
||||
resp.Msg = "success"
|
||||
resp.Data = ""
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/models"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
|
@ -26,14 +27,24 @@ func NewRegisterClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *R
|
|||
}
|
||||
}
|
||||
|
||||
func (l *RegisterClusterLogic) RegisterCluster(req *types.RegisterClusterReq) (resp *types.CloudResp, err error) {
|
||||
// 查询出所有p端信息
|
||||
func (l *RegisterClusterLogic) RegisterCluster(req *types.RegisterClusterReq) (*types.CloudResp, error) {
|
||||
var ms []models.ScParticipantPhyInfo
|
||||
var resp types.CloudResp
|
||||
|
||||
l.svcCtx.DbEngin.Raw("select * from sc_participant_phy_info where `name` = ?", req.Name).Scan(&ms)
|
||||
if len(ms) != 0 {
|
||||
resp.Code = "400"
|
||||
resp.Msg = "cluster name already exist"
|
||||
resp.Data = ""
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
participant := models.ScParticipantPhyInfo{}
|
||||
|
||||
participant.Token = req.Token
|
||||
participant.Name = req.Name
|
||||
participant.Address = req.Address
|
||||
participant.Type = req.Type
|
||||
participant.Type = "SEALOS"
|
||||
participant.Id = utils.GenSnowflakeID()
|
||||
participant.MetricsUrl = req.MetricsUrl
|
||||
participant.CreatedTime = time.Now()
|
||||
|
@ -43,5 +54,8 @@ func (l *RegisterClusterLogic) RegisterCluster(req *types.RegisterClusterReq) (r
|
|||
if tx.Error != nil {
|
||||
return nil, tx.Error
|
||||
}
|
||||
return
|
||||
resp.Code = string(200)
|
||||
resp.Msg = "success"
|
||||
resp.Data = "participantId:" + strconv.FormatInt(participant.Id, 10)
|
||||
return &resp, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue