jcos registCluster and deleteCluster
Former-commit-id: 7dd50995c0bd8163d0445c2a44e4a21692a664e9
This commit is contained in:
parent
94a73f6517
commit
2620759f8b
|
@ -19,12 +19,15 @@ type ControllerMetricsReq {
|
|||
|
||||
type (
|
||||
RegisterClusterReq {
|
||||
Name string `json:"name"` // 名称
|
||||
Address string `json:"address"` // 地址
|
||||
token string `json:"token"` // 数算集群token
|
||||
Type string `json:"type"` // 参与者类型:CLOUD-数算集群;AI-智算集群;HPC-超算集群
|
||||
ParticipantId int64 `json:"name"` // participant id
|
||||
MetricsUrl string `json:"metricsUrl"` //监控url
|
||||
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
|
||||
}
|
||||
|
||||
deleteClusterReq {
|
||||
Name string `form:"name"` // 名称
|
||||
}
|
||||
|
||||
ListCloudResp{
|
||||
|
|
|
@ -152,7 +152,7 @@ service pcm {
|
|||
|
||||
@doc "数算集群删除"
|
||||
@handler deleteClusterHandler
|
||||
post /cloud/deleteCluster (RegisterClusterReq) returns (CloudResp)
|
||||
post /cloud/deleteCluster (deleteClusterReq) returns (CloudResp)
|
||||
|
||||
@doc "数算集群查询"
|
||||
@handler listCloudClusterHandler
|
||||
|
|
|
@ -1,24 +1,28 @@
|
|||
package cloud
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/cloud"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
||||
"gitlink.org.cn/jcce-pcm/utils/result"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func DeleteClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.RegisterClusterReq
|
||||
var req types.DeleteClusterReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := cloud.NewDeleteClusterLogic(r.Context(), svcCtx)
|
||||
resp, err := l.DeleteCluster(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,28 @@
|
|||
package cloud
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/cloud"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
||||
"gitlink.org.cn/jcce-pcm/utils/result"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func UpdateTenantHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.UpdateTenantReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := cloud.NewUpdateTenantLogic(r.Context(), svcCtx)
|
||||
resp, err := l.UpdateTenant(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@ package cloud
|
|||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/models"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
@ -23,8 +23,11 @@ func NewDeleteClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Del
|
|||
}
|
||||
}
|
||||
|
||||
func (l *DeleteClusterLogic) DeleteCluster(req *types.RegisterClusterReq) (resp *types.CloudResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
func (l *DeleteClusterLogic) DeleteCluster(req *types.DeleteClusterReq) (resp *types.CloudResp, err error) {
|
||||
// 删除集群信息
|
||||
tx := l.svcCtx.DbEngin.Where("name = ?", req.Name).Delete(&models.ScParticipantPhyInfo{})
|
||||
if tx.Error != nil {
|
||||
return nil, tx.Error
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -2,6 +2,9 @@ package cloud
|
|||
|
||||
import (
|
||||
"context"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/models"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils"
|
||||
"time"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
||||
|
@ -24,7 +27,21 @@ func NewRegisterClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *R
|
|||
}
|
||||
|
||||
func (l *RegisterClusterLogic) RegisterCluster(req *types.RegisterClusterReq) (resp *types.CloudResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
// 查询出所有p端信息
|
||||
participant := models.ScParticipantPhyInfo{}
|
||||
|
||||
participant.Token = req.Token
|
||||
participant.Name = req.Name
|
||||
participant.Address = req.Address
|
||||
participant.Type = req.Type
|
||||
participant.Id = utils.GenSnowflakeID()
|
||||
participant.MetricsUrl = req.MetricsUrl
|
||||
participant.CreatedTime = time.Now()
|
||||
participant.UpdatedTime = time.Now()
|
||||
|
||||
tx := l.svcCtx.DbEngin.Create(&participant)
|
||||
if tx.Error != nil {
|
||||
return nil, tx.Error
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package cloud
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type UpdateTenantLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewUpdateTenantLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateTenantLogic {
|
||||
return &UpdateTenantLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *UpdateTenantLogic) UpdateTenant(req *types.UpdateTenantReq) (resp *types.CloudResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return
|
||||
}
|
|
@ -3337,12 +3337,15 @@ type ControllerMetricsReq struct {
|
|||
}
|
||||
|
||||
type RegisterClusterReq struct {
|
||||
Name string `json:"name"` // 名称
|
||||
Address string `json:"address"` // 地址
|
||||
Token string `json:"token"` // 数算集群token
|
||||
Type string `json:"type"` // 参与者类型:CLOUD-数算集群;AI-智算集群;HPC-超算集群
|
||||
ParticipantId int64 `json:"name"` // participant id
|
||||
MetricsUrl string `json:"metricsUrl"` //监控url
|
||||
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
|
||||
}
|
||||
|
||||
type DeleteClusterReq struct {
|
||||
Name string `form:"name"` // 名称
|
||||
}
|
||||
|
||||
type ListCloudResp struct {
|
||||
|
|
Loading…
Reference in New Issue