Files
EdgeAdmin/internal/web/actions/default/clusters/cluster/delete.go

47 lines
1.2 KiB
Go
Raw Normal View History

2020-10-25 19:45:42 +08:00
package cluster
2020-10-25 16:22:36 +08:00
import (
2020-11-10 21:37:48 +08:00
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
2020-10-25 16:22:36 +08:00
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
)
type DeleteAction struct {
actionutils.ParentAction
}
2020-10-25 19:45:42 +08:00
func (this *DeleteAction) Init() {
this.Nav("", "delete", "index")
this.SecondMenu("nodes")
}
func (this *DeleteAction) RunGet(params struct{}) {
this.Show()
}
2020-10-25 16:22:36 +08:00
func (this *DeleteAction) RunPost(params struct {
ClusterId int64
}) {
// 检查有无服务正在使用
countResp, err := this.RPC().ServerRPC().CountAllEnabledServersWithNodeClusterId(this.AdminContext(), &pb.CountAllEnabledServersWithNodeClusterIdRequest{NodeClusterId: params.ClusterId})
if err != nil {
this.ErrorPage(err)
return
}
if countResp.Count > 0 {
this.Fail("有代理服务正在使用此集群,请修改这些代理服务后再删除")
}
// 删除
_, err = this.RPC().NodeClusterRPC().DeleteNodeCluster(this.AdminContext(), &pb.DeleteNodeClusterRequest{ClusterId: params.ClusterId})
if err != nil {
this.ErrorPage(err)
return
}
2020-11-10 21:37:48 +08:00
// 创建日志
2020-11-20 15:32:42 +08:00
defer this.CreateLog(oplogs.LevelInfo, "删除集群 %d", params.ClusterId)
2020-11-10 21:37:48 +08:00
2020-10-25 16:22:36 +08:00
this.Success()
}