Files
EdgeAdmin/internal/web/actions/default/clusters/create.go

48 lines
1009 B
Go
Raw Normal View History

2020-09-06 16:19:34 +08:00
package clusters
import (
2020-11-10 21:37:48 +08:00
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
2020-09-06 16:19:34 +08:00
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
2020-11-10 21:37:48 +08:00
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
2020-09-06 16:19:34 +08:00
"github.com/iwind/TeaGo/actions"
)
type CreateAction struct {
actionutils.ParentAction
}
func (this *CreateAction) Init() {
this.Nav("", "cluster", "create")
}
func (this *CreateAction) RunGet(params struct{}) {
this.Show()
}
func (this *CreateAction) RunPost(params struct {
Name string
GrantId int64
InstallDir string
Must *actions.Must
}) {
params.Must.
Field("name", params.Name).
Require("请输入集群名称")
2020-11-10 21:37:48 +08:00
createResp, err := this.RPC().NodeClusterRPC().CreateNodeCluster(this.AdminContext(), &pb.CreateNodeClusterRequest{
2020-09-06 16:19:34 +08:00
Name: params.Name,
GrantId: params.GrantId,
InstallDir: params.InstallDir,
})
if err != nil {
this.ErrorPage(err)
return
}
2020-11-10 21:37:48 +08:00
// 创建日志
this.CreateLog(oplogs.LevelInfo, "创建集群:%d", createResp.ClusterId)
2020-09-06 16:19:34 +08:00
this.Success()
}