mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-30 10:48:15 +08:00
Merge pull request #125 from ysicing/V3.7-role-support
add role support
This commit is contained in:
commit
14286a5367
@ -42,6 +42,7 @@ func GetCmds() []cli.Command {
|
||||
cmds = append(cmds, NewCmdShow())
|
||||
cmds = append(cmds, NewCmdAlerting())
|
||||
cmds = append(cmds, NewCmdNotificationEvent())
|
||||
cmds = append(cmds, NewCmdReset())
|
||||
|
||||
//task相关命令
|
||||
//cmds = append(cmds, NewCmdTasks())
|
||||
|
@ -42,9 +42,9 @@ func NewCmdInit() cli.Command {
|
||||
Name: "init",
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "type",
|
||||
Usage: "node type: manage or compute",
|
||||
Value: "manage",
|
||||
Name: "role",
|
||||
Usage: "node role: master,worker",
|
||||
Value: "master",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "work_dir",
|
||||
@ -160,7 +160,7 @@ func initCluster(c *cli.Context) {
|
||||
|
||||
// start setup script to install rainbond
|
||||
fmt.Println("Begin init cluster first node,please don't exit,wait install")
|
||||
cmd := exec.Command("bash", "-c", fmt.Sprintf("cd %s ; ./setup.sh %s %s %s", c.String("work_dir"), c.String("install-type"), c.String("eip"), c.String("domain")))
|
||||
cmd := exec.Command("bash", "-c", fmt.Sprintf("cd %s ; ./setup.sh %s %s %s %s", c.String("work_dir"), c.String("role"), c.String("install-type"), c.String("eip"), c.String("domain")))
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Stdin = os.Stdin
|
||||
|
@ -446,7 +446,7 @@ func NewCmdNode() cli.Command {
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "role,r",
|
||||
Usage: "The option is required, the allowed values are: [manage|compute|storage]",
|
||||
Usage: "The option is required, the allowed values are: [master|worker]",
|
||||
},
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
@ -468,7 +468,7 @@ func NewCmdNode() cli.Command {
|
||||
|
||||
// start add node script
|
||||
fmt.Println("Begin add node, please don't exit")
|
||||
line := fmt.Sprintf("cd /opt/rainbond/install/scripts; ./%s.sh %s %s %s %s %s", c.String("role"), c.String("hostname"),
|
||||
line := fmt.Sprintf("cd /opt/rainbond/install/scripts; ./join.sh %s %s %s %s %s %s", c.String("role"), c.String("hostname"),
|
||||
c.String("internal-ip"), model, c.String("root-pass"), c.String("private-key"))
|
||||
cmd := exec.Command("bash", "-c", line)
|
||||
cmd.Stdout = os.Stdout
|
||||
|
@ -12,8 +12,8 @@ import (
|
||||
//NewCmdNode NewCmdNode
|
||||
func NewCmdNotificationEvent() cli.Command {
|
||||
c := cli.Command{
|
||||
Name: "notification",
|
||||
Usage: "应用异常通知事件。grctl notification",
|
||||
Name: "msg",
|
||||
Usage: "应用异常通知事件。grctl msg",
|
||||
Subcommands: []cli.Command{
|
||||
{
|
||||
Name: "get",
|
||||
@ -46,12 +46,12 @@ func NewCmdNotificationEvent() cli.Command {
|
||||
val, err := clients.RegionClient.Notification().GetNotification(startTime, EndTme)
|
||||
handleErr(err)
|
||||
serviceTable := termtables.CreateTable()
|
||||
serviceTable.AddHeaders("ServiceName(应用别名)", "TenantName(租户别名)", "Message(异常信息)", "Reason(异常原因)", "Count(出现次数)", "LastTime(最后一次异常时间)", "FirstTime(第一次异常时间)")
|
||||
serviceTable.AddHeaders("TenantName(租户别名)/ServiceName(应用别名)", "Message(异常信息)", "Reason(异常原因)", "Count(出现次数)", "LastTime(最后一次异常时间)", "FirstTime(第一次异常时间)")
|
||||
for _, v := range val {
|
||||
if v.KindID == "" || v.ServiceName == "" || v.TenantName == ""{
|
||||
continue
|
||||
}
|
||||
serviceTable.AddRow(v.ServiceName, v.TenantName, v.Message, v.Reason, v.Count, v.LastTime, v.FirstTime)
|
||||
serviceTable.AddRow(v.TenantName+"/"+v.ServiceName, v.Message, v.Reason, v.Count, v.LastTime, v.FirstTime)
|
||||
}
|
||||
fmt.Println(serviceTable.Render())
|
||||
return nil
|
||||
|
67
grctl/cmd/reset.go
Normal file
67
grctl/cmd/reset.go
Normal file
@ -0,0 +1,67 @@
|
||||
// RAINBOND, Application Management Platform
|
||||
// Copyright (C) 2014-2017 Goodrain Co., Ltd.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version. For any non-GPL usage of Rainbond,
|
||||
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
|
||||
// must be obtained first.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
// "io/ioutil"
|
||||
"os/exec"
|
||||
|
||||
//"github.com/goodrain/rainbond/event"
|
||||
|
||||
//"github.com/Sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
"os"
|
||||
|
||||
//"github.com/goodrain/rainbond/builder/sources"
|
||||
//"github.com/goodrain/rainbond/grctl/clients"
|
||||
//"flag"
|
||||
)
|
||||
|
||||
//NewCmdInit grctl reset
|
||||
func NewCmdReset() cli.Command {
|
||||
c := cli.Command{
|
||||
Name: "reset",
|
||||
Usage: "重置当前节点grctl reset",
|
||||
Action: func(c *cli.Context) error {
|
||||
resetCurrentNode(c)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
|
||||
func resetCurrentNode(c *cli.Context) {
|
||||
|
||||
// stop rainbond services
|
||||
fmt.Println("Start stop rainbond services")
|
||||
cmd := exec.Command("grclis", "reset")
|
||||
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Stdin = os.Stdin
|
||||
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
println(err.Error())
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
Loading…
Reference in New Issue
Block a user