mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-12-01 03:07:51 +08:00
commit
5dee4c9fe1
@ -21,8 +21,8 @@ package cmd
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/apcera/termtables"
|
||||
"github.com/goodrain/rainbond/grctl/clients"
|
||||
@ -186,7 +186,7 @@ func handleRoleAndStatus(list []map[string]string) bool {
|
||||
if v["role"] == "manage" && v["status"] == "running" {
|
||||
manageFlag = true
|
||||
}
|
||||
if (v["role"] == "compute,manage" || v["role"] == "manage,compute") && v["status"] == "running" {
|
||||
if (strings.HasPrefix(v["role"], "compute,manage") || strings.HasPrefix(v["role"], "manage,compute")) && v["status"] == "running" {
|
||||
computeFlag = true
|
||||
manageFlag = true
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ func NewCmdInit() cli.Command {
|
||||
cli.StringFlag{
|
||||
Name: "role",
|
||||
Usage: "Node identity property",
|
||||
Value: "manage,compute",
|
||||
Value: "manage,compute,gateway",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "work_dir",
|
||||
|
@ -587,7 +587,7 @@ func NewCmdNode() cli.Command {
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "role,r",
|
||||
Usage: "The option is required, the allowed values are: [manage|compute]",
|
||||
Usage: "The option is required, the allowed values are: [manage|compute|gateway]",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "podCIDR,cidr",
|
||||
@ -610,8 +610,8 @@ func NewCmdNode() cli.Command {
|
||||
if c.String("root-pass") != "" && c.String("private-key") != "" {
|
||||
showError("Options private-key and root-pass are conflicting")
|
||||
}
|
||||
if c.String("role") != "compute" && c.String("role") != "manage" {
|
||||
showError("node role only support `compute` and `manage`")
|
||||
if c.String("role") != "compute" && c.String("role") != "manage" && c.String("role") != "gateway" {
|
||||
showError("node role only support `compute`, `manage` and `gateway`")
|
||||
}
|
||||
var node client.APIHostNode
|
||||
node.Role = c.String("role")
|
||||
|
@ -131,7 +131,13 @@ func getKubeletMessage(v *client.HostNode) string {
|
||||
//GetRuleNodes 获取分角色节点
|
||||
func GetRuleNodes(w http.ResponseWriter, r *http.Request) {
|
||||
rule := chi.URLParam(r, "rule")
|
||||
if rule != "compute" && rule != "manage" && rule != "storage" {
|
||||
allowRule := map[string]struct{}{
|
||||
"compute": struct{}{},
|
||||
"manage": struct{}{},
|
||||
"storage": struct{}{},
|
||||
"gateway": struct{}{},
|
||||
}
|
||||
if _, ok := allowRule[rule]; !ok {
|
||||
httputil.ReturnError(r, w, 400, rule+" rule is not define")
|
||||
return
|
||||
}
|
||||
|
@ -63,9 +63,6 @@ func (n *NodeService) AddNode(node *client.APIHostNode) (*client.HostNode, *util
|
||||
if node.Role == "" {
|
||||
return nil, utils.CreateAPIHandleError(400, fmt.Errorf("node role must not null"))
|
||||
}
|
||||
if node.Role != "manage" && node.Role != "compute" {
|
||||
return nil, utils.CreateAPIHandleError(400, fmt.Errorf("node role %s not support", node.Role))
|
||||
}
|
||||
if node.ID == "" {
|
||||
node.ID = uuid.NewV4().String()
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ func (n *Cluster) handleNodeStatus(v *client.HostNode) {
|
||||
v.NodeStatus.CurrentScheduleStatus = !k8sNode.Spec.Unschedulable
|
||||
}
|
||||
}
|
||||
if v.Role.HasRule("manage") && !v.Role.HasRule("compute") { //manage install_success == runnint
|
||||
if (v.Role.HasRule("manage") || v.Role.HasRule("gateway")) && !v.Role.HasRule("compute") { //manage install_success == runnint
|
||||
v.AvailableCPU = v.NodeStatus.NodeInfo.NumCPU
|
||||
v.AvailableMemory = int64(v.NodeStatus.NodeInfo.MemorySize)
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ type APIHostNode struct {
|
||||
ExternalIP string `json:"external_ip" validate:"external_ip|ip"`
|
||||
RootPass string `json:"root_pass,omitempty"`
|
||||
Privatekey string `json:"private_key,omitempty"`
|
||||
Role string `json:"role" validate:"role|required"`
|
||||
Role string `json:"role" validate:"role|required|in:manage,compute,gateway"`
|
||||
PodCIDR string `json:"podCIDR"`
|
||||
AutoInstall bool `json:"auto_install"`
|
||||
Labels map[string]string `json:"labels"`
|
||||
|
Loading…
Reference in New Issue
Block a user