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