Short: "Truncate visibility tables",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
- fmt.Println("clear called")
+ fmt.Println("Uncomplete command")
},
}
import (
"fmt"
+ "os"
"gopkg.in/resty.v1"
"github.com/spf13/cobra"
)
var visibilityclearCmd = &cobra.Command{
Use: "visibility",
- Short: "Clear visibility tables",
+ Short: "Clear visibility data",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
clearCollector()
}
func clearCollector() {
+ checkControllerIP()
url := controllerIP + "/visibility/clear"
resp, err := resty.R().
Get(url)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Cannot connect to controller: %v\n", err)
+ os.Exit(1)
}
fmt.Printf("\n%v\n", resp)
}
var createCmd = &cobra.Command{
Use: "create",
- Short: "Create resources including IDS rules, L7 testplans, etc.",
+ Short: "Create clover configurations and deployments",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
- fmt.Println("create called")
+ fmt.Println("Incomplete command")
},
}
import (
"fmt"
"io/ioutil"
-
+ "os"
"gopkg.in/resty.v1"
"github.com/ghodss/yaml"
"github.com/spf13/cobra"
func init() {
providercreateCmd.AddCommand(dockerregistryCmd)
- dockerregistryCmd.Flags().StringVarP(&cloverFile, "file", "f", "", "Input yaml file to add kubernetes provider")
+ dockerregistryCmd.Flags().StringVarP(&cloverFile, "file", "f", "",
+ "Input yaml file to add docker registry")
dockerregistryCmd.MarkFlagRequired("file")
}
func createDockerRegistry() {
+ checkControllerIP()
url := controllerIP + "/halyard/addregistry"
in, err := ioutil.ReadFile(cloverFile)
if err != nil {
- fmt.Println("Please specify a valid rule definition yaml file")
- return
+ fmt.Println("Please specify a valid yaml file")
+ os.Exit(1)
}
out_json, err := yaml.YAMLToJSON(in)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Invalid yaml: %v\n", err)
+ os.Exit(1)
}
resp, err := resty.R().
SetBody(out_json).
Post(url)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Cannot connect to controller: %v\n", err)
+ os.Exit(1)
}
fmt.Printf("\n%v\n", resp)
import (
"fmt"
+ "os"
"io/ioutil"
"gopkg.in/resty.v1"
"github.com/ghodss/yaml"
var idsrulesCmd = &cobra.Command{
Use: "idsrules",
- Short: "Create one or many IDS rules from yaml file",
+ Short: "Create one or many snort IDS rules from yaml file",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
createIDSRules()
func init() {
createCmd.AddCommand(idsrulesCmd)
- idsrulesCmd.Flags().StringVarP(&cloverFile, "file", "f", "", "Input yaml file to add IDS rules")
+ idsrulesCmd.Flags().StringVarP(&cloverFile, "file", "f", "",
+ "Input yaml file to add IDS rules")
idsrulesCmd.MarkFlagRequired("file")
}
func createIDSRules() {
+ checkControllerIP()
url := controllerIP + "/snort/addrule"
in, err := ioutil.ReadFile(cloverFile)
if err != nil {
fmt.Println("Please specify a valid rule definition yaml file")
- return
+ os.Exit(1)
}
out_json, err := yaml.YAMLToJSON(in)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Invalid yaml: %v\n", err)
+ os.Exit(1)
}
resp, err := resty.R().
SetHeader("Content-Type", "application/json").
SetBody(out_json).
Post(url)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Cannot connect to controller: %v\n", err)
+ os.Exit(1)
}
fmt.Printf("\n%v\n", resp)
- //fmt.Println(string(out_json))
-
}
"time"
"io/ioutil"
"strings"
-
+ "os"
"gopkg.in/resty.v1"
"github.com/ghodss/yaml"
"github.com/spf13/cobra"
var kubeproviderCmd = &cobra.Command{
Use: "kubernetes",
- Short: "Add one kubernete provider from yaml file to spinnaker",
+ Short: "Add one kubernetes provider from yaml file to spinnaker",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
createProvider()
func init() {
providercreateCmd.AddCommand(kubeproviderCmd)
- kubeproviderCmd.Flags().StringVarP(&cloverFile, "file", "f", "", "Input yaml file to add kubernetes provider")
+ kubeproviderCmd.Flags().StringVarP(&cloverFile, "file", "f", "",
+ "Input yaml file to add kubernetes provider")
kubeproviderCmd.MarkFlagRequired("file")
}
func createProvider() {
+ checkControllerIP()
url := controllerIP + "/halyard/addkube"
in, err := ioutil.ReadFile(cloverFile)
if err != nil {
- fmt.Println("Please specify a valid rule definition yaml file")
- return
+ fmt.Println("Please specify a valid yaml file")
+ os.Exit(1)
}
t := Kubernetes{}
newconfig, _ := yaml.Marshal(&t)
out_json, err := yaml.YAMLToJSON(newconfig)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Invalid yaml: %v\n", err)
+ os.Exit(1)
}
resp, err := resty.R().
SetHeader("Content-Type", "application/json").
SetBody(out_json).
Post(url)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Cannot connect to controller: %v\n", err)
+ os.Exit(1)
}
fmt.Printf("\n%v\n", resp)
import (
"fmt"
+ "os"
"gopkg.in/resty.v1"
"io/ioutil"
"github.com/ghodss/yaml"
"github.com/spf13/cobra"
+
)
var testplanCmd = &cobra.Command{
Use: "testplan",
- Short: "Create L7 client emulation test plans from yaml file",
+ Short: "Create jmeter L7 client emulation test plan from yaml file",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
createTestPlan()
- //fmt.Printf("%v\n", cmd.Parent().CommandPath())
},
}
func init() {
createCmd.AddCommand(testplanCmd)
- testplanCmd.Flags().StringVarP(&cloverFile, "file", "f", "", "Input yaml file with test plan params")
+ testplanCmd.Flags().StringVarP(&cloverFile, "file", "f", "",
+ "Input test plan yaml file")
testplanCmd.MarkFlagRequired("file")
}
func createTestPlan() {
+ checkControllerIP()
url := controllerIP + "/jmeter/gen"
in, err := ioutil.ReadFile(cloverFile)
if err != nil {
- fmt.Println("Please specify a valid test plan yaml file")
- return
+ fmt.Println("Please specify a valid yaml file")
+ os.Exit(1)
}
out_json, err := yaml.YAMLToJSON(in)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Invalid yaml: %v\n", err)
+ os.Exit(1)
}
resp, err := resty.R().
SetHeader("Content-Type", "application/json").
SetBody(out_json).
Post(url)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Cannot connect to controller: %v\n", err)
+ os.Exit(1)
}
fmt.Printf("\n%v\n", resp)
- //fmt.Println(string(out_json))
-
}
-
var deleteCmd = &cobra.Command{
Use: "delete",
- Short: "Delete resources including clover-system services",
+ Short: "Delete configurations and clover services",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
- fmt.Println("delete called")
+ fmt.Println("Incomplete command")
},
}
import (
"fmt"
"encoding/json"
-
+ "os"
"gopkg.in/resty.v1"
"github.com/spf13/cobra"
)
var deldockerproviderCmd = &cobra.Command{
Use: "docker-registry",
- Short: "delete one docker registry provider by name from spinnaker",
+ Short: "Delete one docker registry provider by name from spinnaker",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
deldockerProvider()
func init() {
providerdelCmd.AddCommand(deldockerproviderCmd)
- deldockerproviderCmd.Flags().StringVarP(&name, "name", "n", "", "Input docker-registry account name")
+ deldockerproviderCmd.Flags().StringVarP(&name, "name", "n", "",
+ "Input docker-registry account name")
deldockerproviderCmd.MarkFlagRequired("name")
}
func deldockerProvider() {
+ checkControllerIP()
url := controllerIP + "/halyard/delprovider"
var in = map[string]string{"name": name, "provider":"dockerRegistry"}
SetBody(out_json).
Post(url)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Cannot connect to controller: %v\n", err)
+ os.Exit(1)
}
fmt.Printf("\n%v\n", resp)
import (
"fmt"
"encoding/json"
-
+ "os"
"gopkg.in/resty.v1"
"github.com/spf13/cobra"
)
var name string
var delkubeproviderCmd = &cobra.Command{
Use: "kubernetes",
- Short: "delete one kubernete provider by name from spinnaker",
+ Short: "Delete one kubernetes provider by name from spinnaker",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
delProvider()
func init() {
providerdelCmd.AddCommand(delkubeproviderCmd)
- delkubeproviderCmd.Flags().StringVarP(&name, "name", "n", "", "Input kubernetes account name")
+ delkubeproviderCmd.Flags().StringVarP(&name, "name", "n", "",
+ "Input kubernetes account name")
delkubeproviderCmd.MarkFlagRequired("name")
}
func delProvider() {
+ checkControllerIP()
url := controllerIP + "/halyard/delprovider"
var in = map[string]string{"name": name, "provider":"kubernetes"}
SetBody(out_json).
Post(url)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Cannot connect to controller: %v\n", err)
+ os.Exit(1)
}
fmt.Printf("\n%v\n", resp)
var getCmd = &cobra.Command{
Use: "get",
- Short: "Get information about a resource",
+ Short: "Get information about a configuration or deployment",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
- fmt.Println("get called")
+ fmt.Println("Incomplete command")
},
}
"fmt"
"strings"
"encoding/json"
-
+ "os"
"gopkg.in/resty.v1"
"github.com/spf13/cobra"
)
}
func getdocker() {
+ checkControllerIP()
url := controllerIP + "/halyard/account"
var provider = map[string]string{"name": "dockerRegistry"}
SetBody(out_json).
Get(url)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Cannot connect to controller: %v\n", err)
+ os.Exit(1)
}
if resp.StatusCode() != 200 {
fmt.Printf("\n%v\n", resp)
"fmt"
"strings"
"encoding/json"
-
+ "os"
"gopkg.in/resty.v1"
"github.com/spf13/cobra"
)
}
func getkube() {
+ checkControllerIP()
url := controllerIP + "/halyard/account"
var provider = map[string]string{"name": "kubernetes"}
SetBody(out_json).
Get(url)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Cannot connect to controller: %v\n", err)
+ os.Exit(1)
}
if resp.StatusCode() != 200 {
fmt.Printf("\n%v\n", resp)
var servicesCmd = &cobra.Command{
Use: "services",
- Short: "Get info on Kubernetes services",
+ Short: "Get listing of Kubernetes services",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
cloverkube.GetServices()
import (
"fmt"
+ "os"
"gopkg.in/resty.v1"
"github.com/spf13/cobra"
)
-var JmeterResult string
-
var testresultCmd = &cobra.Command{
Use: "testresult",
- Short: "Get test results from L7 client emulation",
+ Short: "Get test results from jmeter L7 client emulation",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
- getResult()
+ getResult("log")
},
}
-func init() {
- getCmd.AddCommand(testresultCmd)
- testresultCmd.Flags().StringVarP(&JmeterResult, "r", "r", "", "Result to retrieve - use 'log' or 'results'")
- testresultCmd.MarkFlagRequired("r")
+var log_testresultCmd = &cobra.Command{
+ Use: "log",
+ Short: "Get jmeter summary log results",
+ Long: ``,
+ Run: func(cmd *cobra.Command, args []string) {
+ getResult("log")
+ },
+}
+var detail_testresultCmd = &cobra.Command{
+ Use: "detail",
+ Short: "Get jmeter detailed results",
+ Long: ``,
+ Run: func(cmd *cobra.Command, args []string) {
+ getResult("detail")
+ },
}
+func init() {
+ getCmd.AddCommand(testresultCmd)
+ testresultCmd.AddCommand(log_testresultCmd)
+ testresultCmd.AddCommand(detail_testresultCmd)
+}
-func getResult() {
- switch JmeterResult {
- case "results":
+func getResult(result_type string) {
+ checkControllerIP()
+ switch result_type {
+ case "detail":
url := controllerIP + "/jmeter/results/results"
resp, err := resty.R().
Get(url)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Cannot connect to controller: %v\n", err)
+ os.Exit(1)
}
fmt.Printf("\nResponse Body: %v\n", resp)
case "log":
resp, err := resty.R().
Get(url)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Cannot connect to controller: %v\n", err)
+ os.Exit(1)
}
fmt.Printf("\nResponse Body: %v\n", resp)
default:
- fmt.Println("Unrecoginized jmeter result type - use 'log' or 'results'")
+ msg := "Unrecoginized jmeter result type"
+ fmt.Printf("%s - use 'log' or 'detail'", msg)
}
}
import (
"fmt"
+ "os"
"gopkg.in/resty.v1"
"github.com/spf13/cobra"
)
func init() {
getCmd.AddCommand(visibilitygetCmd)
- visibilitygetCmd.PersistentFlags().StringVarP(&VisibilityStat, "stat", "s", "", "Visibility stats type to get")
- visibilitygetCmd.PersistentFlags().StringVarP(&VisibilityConfig, "conf", "c", "", "Visibility config type to get")
+ visibilitygetCmd.PersistentFlags().StringVarP(&VisibilityStat, "stat", "s",
+ "", "Visibility stats type to get")
+ visibilitygetCmd.PersistentFlags().StringVarP(&VisibilityConfig, "conf",
+ "c", "", "Visibility config type to get")
}
func getVisibility() {
+ checkControllerIP()
url_prefix := "/visibility/get/"
get_data := "all"
response_prefix := "Config"
SetHeader("Accept", "application/json").
Get(url)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Cannot connect to controller: %v\n", err)
+ os.Exit(1)
}
fmt.Printf("\n%s %s: %v\n", response_prefix, get_data, resp)
}
Short: "Initialize visibility schemas",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
- fmt.Println("init called")
+ fmt.Println("Incomplete command")
},
}
import (
"fmt"
+ "os"
"gopkg.in/resty.v1"
"github.com/spf13/cobra"
)
var visibilityinitCmd = &cobra.Command{
Use: "visibility",
- Short: "Init visibility data schemas",
+ Short: "Initialize visibility data schemas in cassandra",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
initCollector()
}
func initCollector() {
+
+ checkControllerIP()
url := controllerIP + "/collector/init"
resp, err := resty.R().
Get(url)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Cannot connect to controller: %v\n", err)
+ os.Exit(1)
}
fmt.Printf("\n%v\n", resp)
}
-
-
Short: "Add spinnaker provider",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
- fmt.Println("provider called")
+ fmt.Println("Incomplete command")
},
}
Short: "Delete spinnaker provider",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
- fmt.Println("provider called")
+ fmt.Println("Incomplete command")
},
}
Short: "Get spinnaker provider",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
- fmt.Println("provider called")
+ fmt.Println("Incomplete command")
},
}
func init() {
import (
"fmt"
"os"
+ "strings"
homedir "github.com/mitchellh/go-homedir"
"github.com/spf13/cobra"
)
var cfgFile string
-
var controllerIP string
var cloverFile string
//},
}
-// Execute adds all child commands to the root command and sets flags appropriately.
-// This is called by main.main(). It only needs to happen once to the rootCmd.
+// Execute adds all child commands to the root command and sets flags
+// appropriately. This is called by main.main(). It only needs to happen
+// once to the rootCmd.
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
// Here you will define your flags and configuration settings.
// Cobra supports persistent flags, which, if defined here,
// will be global for your application.
- rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.cloverctl.yaml)")
+ rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "",
+ "config file (default is $HOME/.cloverctl.yaml)")
// Cobra also supports local flags, which will only run
// when this action is called directly.
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
-
- cPort, cIP := cloverkube.GetServicesPortIP("clover-controller")
- if cIP == "" {
- controllerIP = "http://10.244.0.1:" + fmt.Sprint(cPort)
- } else {
- controllerIP = "http://" + cIP
- }
- fmt.Printf("\nclover-controller: %s %s\n", fmt.Sprint(cPort), cIP)
}
// initConfig reads in config file and ENV variables if set.
os.Exit(1)
}
- // Search config in home directory with name ".cloverctl" (without extension).
+ // Search config in home directory with name ".cloverctl"
viper.AddConfigPath(home)
viper.SetConfigName(".cloverctl")
}
viper.AutomaticEnv() // read in environment variables that match
- // If a config file is found, read it in.
+ cip_file := ""
+ // If a config file is found in home, read it in.
if err := viper.ReadInConfig(); err == nil {
fmt.Println("Using config file:", viper.ConfigFileUsed())
+ cip_file = viper.GetString("ControllerIP")
+ } else {
+ // Check for file in path from cloverctl
+ ep, err := os.Executable()
+ if err == nil {
+ exe_path := strings.Replace(ep, "cloverctl", "", -1)
+ viper.AddConfigPath(exe_path)
+ if err := viper.ReadInConfig(); err == nil {
+ fmt.Println("Using config file:", viper.ConfigFileUsed())
+ cip_file = viper.GetString("ControllerIP")
+ }
+ }
+ }
+
+ cPort, cip_kube := cloverkube.GetServicesPortIP("clover-controller")
+ // If IP in file
+ if cip_file != "" {
+ // Nodeport
+ controllerIP = "http://" + cip_file + ":" + fmt.Sprint(cPort)
+ }
+ // Override IP, if LB IP found
+ if cip_kube != "" {
+ fmt.Printf("IP %v", cip_kube)
+ controllerIP = "http://" + cip_kube
+ }
+}
+
+func checkControllerIP() {
+ // controllerIP exists
+ service := "clover-controller"
+ if controllerIP == "" {
+ fmt.Printf("%s address unspecified or cannot be found\n", service)
+ os.Exit(1)
+ } else {
+ fmt.Printf("%s address: %s\n", service, controllerIP)
}
}
import (
"fmt"
+ "os"
"io/ioutil"
"gopkg.in/resty.v1"
"github.com/spf13/cobra"
func init() {
setCmd.AddCommand(setserverCmd)
- setserverCmd.Flags().StringVarP(&cloverFile, "file", "f", "", "Input yaml file for server config")
+ setserverCmd.Flags().StringVarP(&cloverFile, "file", "f", "",
+ "Input yaml file for server config")
setserverCmd.MarkFlagRequired("file")
setCmd.AddCommand(setlbCmd)
- setlbCmd.Flags().StringVarP(&cloverFile, "file", "f", "", "Input yaml file for lb config")
+ setlbCmd.Flags().StringVarP(&cloverFile, "file", "f", "",
+ "Input yaml file for lb config")
setlbCmd.MarkFlagRequired("file")
-
}
func setNginx(nginx_service string) {
+ checkControllerIP()
url := ""
if nginx_service == "server" {
url = controllerIP + "/nginx/server"
in, err := ioutil.ReadFile(cloverFile)
if err != nil {
fmt.Println("Please specify a valid yaml file")
- return
+ os.Exit(1)
}
out_json, err := yaml.YAMLToJSON(in)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Invalid yaml: %v\n", err)
+ os.Exit(1)
}
resp, err := resty.R().
SetHeader("Content-Type", "application/json").
SetBody(out_json).
Post(url)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Cannot connect to controller: %v\n", err)
+ os.Exit(1)
}
fmt.Printf("\n%v\n", resp)
-
-
}
import (
"fmt"
+ "os"
"io/ioutil"
"gopkg.in/resty.v1"
"github.com/spf13/cobra"
func init() {
setCmd.AddCommand(setvisibilitystatsCmd)
- setvisibilitystatsCmd.Flags().StringVarP(&cloverFile, "file", "f", "", "Input yaml file to set visibility config")
+ setvisibilitystatsCmd.Flags().StringVarP(&cloverFile, "file", "f", "",
+ "Input yaml file to set visibility config")
setvisibilitystatsCmd.MarkFlagRequired("file")
-
}
func setCollector() {
+ checkControllerIP()
url := controllerIP + "/visibility/set"
in, err := ioutil.ReadFile(cloverFile)
if err != nil {
fmt.Println("Please specify a valid yaml file")
- return
+ os.Exit(1)
}
out_json, err := yaml.YAMLToJSON(in)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Invalid yaml: %v\n", err)
+ os.Exit(1)
}
resp, err := resty.R().
SetHeader("Content-Type", "application/json").
SetBody(out_json).
Post(url)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Cannot connect to controller: %v\n", err)
+ os.Exit(1)
}
fmt.Printf("\n%v\n", resp)
-
-
}
var startCmd = &cobra.Command{
Use: "start",
- Short: "Start processes including tests, visibility and ingress services",
+ Short: "Start processes and tests",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
- fmt.Println("start called")
+ fmt.Println("Incomplete command")
},
}
import (
"fmt"
+ "os"
"gopkg.in/resty.v1"
"github.com/spf13/cobra"
)
var startidsCmd = &cobra.Command{
Use: "ids",
- Short: "Start IDS process",
- Long: `Restart IDS process when adding custom rules`,
+ Short: "Start snort IDS process",
+ Long: `Restart snort IDS process when adding custom rules`,
Run: func(cmd *cobra.Command, args []string) {
startIDS()
},
func startIDS() {
+ checkControllerIP()
url := controllerIP + "/snort/start"
resp, err := resty.R().
Get(url)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Cannot connect to controller: %v\n", err)
+ os.Exit(1)
}
fmt.Printf("\n%v\n", resp)
}
-
-
import (
"fmt"
+ "os"
"strings"
"gopkg.in/resty.v1"
"github.com/spf13/cobra"
var testplanstartCmd = &cobra.Command{
Use: "testplan",
- Short: "Start a test for a given test plan",
+ Short: "Start test for configured test plan",
Long: `Specify number of slaves to use with '-s' flag. Default is 0 slaves,
-which runs tests only from jmeter-master.`,
+which runs tests from jmeter-master only.`,
Run: func(cmd *cobra.Command, args []string) {
startTest()
- //fmt.Printf("%v\n", cmd.Parent().CommandPath())
},
}
var num_slaves int
func init() {
startCmd.AddCommand(testplanstartCmd)
- testplanstartCmd.PersistentFlags().StringVarP(&cloverFile, "file", "f", "", "Currently unused")
- testplanstartCmd.PersistentFlags().IntVarP(&num_slaves, "slaves", "s", 0, "Number of slaves to use")
+ testplanstartCmd.PersistentFlags().StringVarP(&cloverFile, "file", "f", "",
+ "Currently unused")
+ testplanstartCmd.PersistentFlags().IntVarP(&num_slaves, "slaves", "s", 0,
+ "Number of slaves to use")
}
func startTest() {
ips := cloverkube.GetPodsIP("clover-jmeter-slave", "default")
fmt.Printf("\njmeter-slaves found: %s\n", ips)
if num_slaves > len(ips) {
- fmt.Printf("Number of slaves specified must be less than found: %d\n", len(ips))
+ fmt.Printf("Number of slaves specified must be less than found: %d\n",
+ len(ips))
return
}
ip_list := strings.Join(ips[0:num_slaves], ",")
+ checkControllerIP()
url := controllerIP + "/jmeter/start"
resp, err := resty.R().
SetHeader("Content-Type", "application/json").
- SetBody(fmt.Sprintf(`{"num_slaves":"%d", "slave_list":"%s"}`, num_slaves, ip_list)).
+ SetBody(fmt.Sprintf(`{"num_slaves":"%d", "slave_list":"%s"}`, num_slaves,
+ ip_list)).
Post(url)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Cannot connect to controller: %v\n", err)
+ os.Exit(1)
}
fmt.Printf("\n%v\n", resp)
-
}
import (
"fmt"
+ "os"
"io/ioutil"
"gopkg.in/resty.v1"
"github.com/ghodss/yaml"
var visibilitystartCmd = &cobra.Command{
Use: "visibility",
- Short: "Start visibility data collection",
+ Short: "Start visibility collector process",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
startCollector()
if cloverFile != "" {
in, err := ioutil.ReadFile(cloverFile)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Cannot read file: %v\n", err)
+ os.Exit(1)
}
out_json, err := yaml.YAMLToJSON(in)
message_body = string(out_json)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Invalid yaml: %v\n", err)
+ os.Exit(1)
}
} else {
message_body = `{"sample_interval":"10", "t_port":"80", "t_host":"jaeger-query.istio-system"}`
}
+ checkControllerIP()
url := controllerIP + "/collector/start"
resp, err := resty.R().
SetHeader("Content-Type", "application/json").
SetBody(message_body).
Post(url)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Cannot connect to controller: %v\n", err)
+ os.Exit(1)
}
fmt.Printf("\n%v\n", resp)
}
var stopCmd = &cobra.Command{
Use: "stop",
- Short: "Stop processes including visibility and ingress services",
+ Short: "Stop processes including visibility and sample services",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
- fmt.Println("stop called")
+ fmt.Println("Incomplete command")
},
}
import (
"fmt"
+ "os"
"gopkg.in/resty.v1"
"github.com/spf13/cobra"
)
var stopidsCmd = &cobra.Command{
Use: "ids",
- Short: "Stop IDS process",
- Long: `Restart IDS process when adding custom rules`,
+ Short: "Stop snort IDS process",
+ Long: `Restart snort IDS process when adding custom rules`,
Run: func(cmd *cobra.Command, args []string) {
stopIDS()
},
func stopIDS() {
+ checkControllerIP()
url := controllerIP + "/snort/stop"
resp, err := resty.R().
Get(url)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Cannot connect to controller: %v\n", err)
+ os.Exit(1)
}
fmt.Printf("\n%v\n", resp)
}
import (
"fmt"
+ "os"
"gopkg.in/resty.v1"
"github.com/spf13/cobra"
)
var visibilitystopCmd = &cobra.Command{
Use: "visibility",
- Short: "Stop visibility data collection",
+ Short: "Stop visibility collector process",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
stopCollector()
func stopCollector() {
+ checkControllerIP()
url := controllerIP + "/collector/stop"
resp, err := resty.R().
Get(url)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Cannot connect to controller: %v\n", err)
+ os.Exit(1)
}
fmt.Printf("\n%v\n", resp)
}