2017-11-10 11:53:05 +08:00
|
|
|
// 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/>.
|
|
|
|
|
2017-11-09 17:56:12 +08:00
|
|
|
package cmd
|
2017-11-13 14:28:41 +08:00
|
|
|
|
2017-11-09 17:56:12 +08:00
|
|
|
import (
|
2017-11-13 14:28:41 +08:00
|
|
|
"github.com/Sirupsen/logrus"
|
2017-11-10 11:53:05 +08:00
|
|
|
conf "github.com/goodrain/rainbond/cmd/grctl/option"
|
|
|
|
"github.com/goodrain/rainbond/pkg/grctl/clients"
|
2017-11-13 14:28:41 +08:00
|
|
|
"github.com/urfave/cli"
|
2017-11-09 17:56:12 +08:00
|
|
|
)
|
|
|
|
|
2017-11-13 14:28:41 +08:00
|
|
|
//GetCmds GetCmds
|
2017-11-09 17:56:12 +08:00
|
|
|
func GetCmds() []cli.Command {
|
2017-11-13 14:28:41 +08:00
|
|
|
cmds := []cli.Command{}
|
|
|
|
cmds = append(cmds, NewCmdBatchStop())
|
|
|
|
cmds = append(cmds, NewCmdStartService())
|
|
|
|
cmds = append(cmds, NewCmdStopService())
|
|
|
|
cmds = append(cmds, NewCmdTenant())
|
|
|
|
cmds = append(cmds, NewCmdTenantRes())
|
|
|
|
cmds = append(cmds, NewCmdNode())
|
|
|
|
cmds = append(cmds, NewCmdNodeRes())
|
|
|
|
cmds = append(cmds, NewCmdExec())
|
|
|
|
cmds = append(cmds, NewCmdLog())
|
|
|
|
cmds = append(cmds, NewCmdEvent())
|
|
|
|
cmds = append(cmds, NewCmdGet())
|
2017-11-22 11:40:14 +08:00
|
|
|
cmds = append(cmds, NewCmdInit())
|
|
|
|
cmds = append(cmds, NewCmdAddNode())
|
|
|
|
cmds = append(cmds, NewCmdCheckComputeServices())
|
|
|
|
cmds = append(cmds, NewCmdComputeGroup())
|
|
|
|
cmds = append(cmds, NewCmdBaseManageGroup())
|
|
|
|
cmds = append(cmds, NewCmdManageGroup())
|
|
|
|
cmds = append(cmds, NewCmdCheckManageServices())
|
|
|
|
cmds = append(cmds, NewCmdCheckManageBaseServices())
|
2017-11-22 15:09:28 +08:00
|
|
|
cmds = append(cmds, NewCmdSources())
|
2017-11-22 18:46:17 +08:00
|
|
|
cmds = append(cmds, NewCmdRegionNode())
|
2017-11-13 14:28:41 +08:00
|
|
|
//cmds = append(cmds, NewCmdPlugin())
|
2017-11-09 17:56:12 +08:00
|
|
|
//todo
|
|
|
|
return cmds
|
|
|
|
}
|
2017-11-22 15:09:28 +08:00
|
|
|
|
|
|
|
//Common Common
|
2017-11-09 17:56:12 +08:00
|
|
|
func Common(c *cli.Context) {
|
|
|
|
config, err := conf.LoadConfig(c)
|
|
|
|
if err != nil {
|
2017-11-22 11:40:14 +08:00
|
|
|
logrus.Warnf("Load config file error.", err.Error())
|
2017-11-09 17:56:12 +08:00
|
|
|
}
|
2017-11-10 17:18:57 +08:00
|
|
|
|
2017-11-09 17:56:12 +08:00
|
|
|
if err := clients.InitClient(*config.Kubernets); err != nil {
|
2017-11-22 15:17:33 +08:00
|
|
|
logrus.Errorf("error config k8s,details %s", err.Error())
|
2017-11-09 17:56:12 +08:00
|
|
|
}
|
|
|
|
//clients.SetInfo(config.RegionAPI.URL, config.RegionAPI.Token)
|
2017-11-22 11:40:14 +08:00
|
|
|
if err := clients.InitRegionClient(*config.RegionAPI); err != nil {
|
|
|
|
logrus.Warnf("error config region")
|
|
|
|
}
|
|
|
|
if err := clients.InitNodeClient("http://127.0.0.1:6100"); err != nil {
|
|
|
|
logrus.Warnf("error config region")
|
|
|
|
}
|
2017-11-10 17:18:57 +08:00
|
|
|
|
2017-11-13 14:28:41 +08:00
|
|
|
}
|