换成单集群模式
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package apps
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -33,28 +34,6 @@ func (this *CreateAction) RunGet(params struct{}) {
|
||||
}
|
||||
this.Data["clusters"] = clusters
|
||||
|
||||
defaultPrimaryClusterId := int64(0)
|
||||
for _, cluster := range clusterResp.GetClusters() {
|
||||
if cluster.GetIsDefault() {
|
||||
defaultPrimaryClusterId = cluster.GetId()
|
||||
break
|
||||
}
|
||||
}
|
||||
if defaultPrimaryClusterId <= 0 && len(clusters) > 0 {
|
||||
defaultPrimaryClusterId = clusters[0].GetInt64("id")
|
||||
}
|
||||
this.Data["defaultPrimaryClusterId"] = defaultPrimaryClusterId
|
||||
|
||||
defaultBackupClusterId := int64(0)
|
||||
for _, cluster := range clusters {
|
||||
clusterId := cluster.GetInt64("id")
|
||||
if clusterId > 0 && clusterId != defaultPrimaryClusterId {
|
||||
defaultBackupClusterId = clusterId
|
||||
break
|
||||
}
|
||||
}
|
||||
this.Data["defaultBackupClusterId"] = defaultBackupClusterId
|
||||
|
||||
usersResp, err := this.RPC().UserRPC().ListEnabledUsers(this.AdminContext(), &pb.ListEnabledUsersRequest{
|
||||
Offset: 0,
|
||||
Size: 10_000,
|
||||
@@ -77,28 +56,28 @@ func (this *CreateAction) RunGet(params struct{}) {
|
||||
}
|
||||
|
||||
func (this *CreateAction) RunPost(params struct {
|
||||
Name string
|
||||
PrimaryClusterId int64
|
||||
BackupClusterId int64
|
||||
UserId int64
|
||||
Name string
|
||||
ClusterId int64
|
||||
UserId int64
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
params.Must.Field("name", params.Name).Require("请输入应用名称")
|
||||
params.Must.Field("primaryClusterId", params.PrimaryClusterId).Gt(0, "请输入主服务集群")
|
||||
if params.BackupClusterId > 0 && params.BackupClusterId == params.PrimaryClusterId {
|
||||
this.FailField("backupClusterId", "备用服务集群必须和主服务集群不一致")
|
||||
if params.ClusterId <= 0 {
|
||||
this.FailField("clusterId", "请选择集群")
|
||||
return
|
||||
}
|
||||
|
||||
clusterIdsJSON, _ := json.Marshal([]int64{params.ClusterId})
|
||||
|
||||
createResp, err := this.RPC().HTTPDNSAppRPC().CreateHTTPDNSApp(this.AdminContext(), &pb.CreateHTTPDNSAppRequest{
|
||||
Name: params.Name,
|
||||
AppId: "app" + strconv.FormatInt(time.Now().UnixNano()%1_000_000_000_000, 36),
|
||||
PrimaryClusterId: params.PrimaryClusterId,
|
||||
BackupClusterId: params.BackupClusterId,
|
||||
IsOn: true,
|
||||
SignEnabled: true,
|
||||
UserId: params.UserId,
|
||||
Name: params.Name,
|
||||
AppId: "app" + strconv.FormatInt(time.Now().UnixNano()%1_000_000_000_000, 36),
|
||||
ClusterIdsJSON: clusterIdsJSON,
|
||||
IsOn: true,
|
||||
SignEnabled: true,
|
||||
UserId: params.UserId,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
Reference in New Issue
Block a user