summaryrefslogtreecommitdiffstats
path: root/clover/cloverctl/src/cloverctl/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'clover/cloverctl/src/cloverctl/cmd')
-rw-r--r--clover/cloverctl/src/cloverctl/cmd/clear.go26
-rw-r--r--clover/cloverctl/src/cloverctl/cmd/clear_visibility.go41
-rw-r--r--clover/cloverctl/src/cloverctl/cmd/create.go26
-rw-r--r--clover/cloverctl/src/cloverctl/cmd/create_idsrules.go56
-rw-r--r--clover/cloverctl/src/cloverctl/cmd/create_system.go37
-rw-r--r--clover/cloverctl/src/cloverctl/cmd/create_testplan.go57
-rw-r--r--clover/cloverctl/src/cloverctl/cmd/delete.go26
-rw-r--r--clover/cloverctl/src/cloverctl/cmd/delete_system.go33
-rw-r--r--clover/cloverctl/src/cloverctl/cmd/get.go26
-rw-r--r--clover/cloverctl/src/cloverctl/cmd/get_services.go26
-rw-r--r--clover/cloverctl/src/cloverctl/cmd/get_testresult.go56
-rw-r--r--clover/cloverctl/src/cloverctl/cmd/get_visibility.go41
-rw-r--r--clover/cloverctl/src/cloverctl/cmd/init.go26
-rw-r--r--clover/cloverctl/src/cloverctl/cmd/init_visibility.go41
-rw-r--r--clover/cloverctl/src/cloverctl/cmd/root.go90
-rw-r--r--clover/cloverctl/src/cloverctl/cmd/start.go26
-rw-r--r--clover/cloverctl/src/cloverctl/cmd/start_ids.go42
-rw-r--r--clover/cloverctl/src/cloverctl/cmd/start_testplan.go59
-rw-r--r--clover/cloverctl/src/cloverctl/cmd/start_visibility.go60
-rw-r--r--clover/cloverctl/src/cloverctl/cmd/stop.go26
-rw-r--r--clover/cloverctl/src/cloverctl/cmd/stop_ids.go42
-rw-r--r--clover/cloverctl/src/cloverctl/cmd/stop_visibility.go42
22 files changed, 905 insertions, 0 deletions
diff --git a/clover/cloverctl/src/cloverctl/cmd/clear.go b/clover/cloverctl/src/cloverctl/cmd/clear.go
new file mode 100644
index 0000000..309df70
--- /dev/null
+++ b/clover/cloverctl/src/cloverctl/cmd/clear.go
@@ -0,0 +1,26 @@
+// Copyright (c) Authors of Clover
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Apache License, Version 2.0
+// which accompanies this distribution, and is available at
+// http://www.apache.org/licenses/LICENSE-2.0
+
+package cmd
+
+import (
+ "fmt"
+ "github.com/spf13/cobra"
+)
+
+var clearCmd = &cobra.Command{
+ Use: "clear",
+ Short: "Truncate visibility tables",
+ Long: ``,
+ Run: func(cmd *cobra.Command, args []string) {
+ fmt.Println("clear called")
+ },
+}
+
+func init() {
+ rootCmd.AddCommand(clearCmd)
+}
diff --git a/clover/cloverctl/src/cloverctl/cmd/clear_visibility.go b/clover/cloverctl/src/cloverctl/cmd/clear_visibility.go
new file mode 100644
index 0000000..9468714
--- /dev/null
+++ b/clover/cloverctl/src/cloverctl/cmd/clear_visibility.go
@@ -0,0 +1,41 @@
+// Copyright (c) Authors of Clover
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Apache License, Version 2.0
+// which accompanies this distribution, and is available at
+// http://www.apache.org/licenses/LICENSE-2.0
+
+package cmd
+
+import (
+ "fmt"
+ "gopkg.in/resty.v1"
+ "github.com/spf13/cobra"
+)
+
+
+var visibilityclearCmd = &cobra.Command{
+ Use: "visibility",
+ Short: "Clear visibility tables",
+ Long: ``,
+ Run: func(cmd *cobra.Command, args []string) {
+ clearCollector()
+ },
+}
+
+func init() {
+ clearCmd.AddCommand(visibilityclearCmd)
+}
+
+func clearCollector() {
+ url := controllerIP + "/collector/truncate"
+
+ resp, err := resty.R().
+ Get(url)
+ if err != nil {
+ panic(err.Error())
+ }
+ fmt.Printf("\n%v\n", resp)
+}
+
+
diff --git a/clover/cloverctl/src/cloverctl/cmd/create.go b/clover/cloverctl/src/cloverctl/cmd/create.go
new file mode 100644
index 0000000..3a09fa4
--- /dev/null
+++ b/clover/cloverctl/src/cloverctl/cmd/create.go
@@ -0,0 +1,26 @@
+// Copyright (c) Authors of Clover
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Apache License, Version 2.0
+// which accompanies this distribution, and is available at
+// http://www.apache.org/licenses/LICENSE-2.0
+
+package cmd
+
+import (
+ "fmt"
+ "github.com/spf13/cobra"
+)
+
+var createCmd = &cobra.Command{
+ Use: "create",
+ Short: "Create resources including IDS rules, L7 testplans, etc.",
+ Long: ``,
+ Run: func(cmd *cobra.Command, args []string) {
+ fmt.Println("create called")
+ },
+}
+
+func init() {
+ rootCmd.AddCommand(createCmd)
+}
diff --git a/clover/cloverctl/src/cloverctl/cmd/create_idsrules.go b/clover/cloverctl/src/cloverctl/cmd/create_idsrules.go
new file mode 100644
index 0000000..bc0d8d5
--- /dev/null
+++ b/clover/cloverctl/src/cloverctl/cmd/create_idsrules.go
@@ -0,0 +1,56 @@
+// Copyright (c) Authors of Clover
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Apache License, Version 2.0
+// which accompanies this distribution, and is available at
+// http://www.apache.org/licenses/LICENSE-2.0
+
+package cmd
+
+import (
+ "fmt"
+ "io/ioutil"
+ "gopkg.in/resty.v1"
+ "github.com/ghodss/yaml"
+ "github.com/spf13/cobra"
+)
+
+
+var idsrulesCmd = &cobra.Command{
+ Use: "idsrules",
+ Short: "Create one or many 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.MarkFlagRequired("file")
+
+}
+
+func createIDSRules() {
+ url := controllerIP + "/snort/addrule"
+ in, err := ioutil.ReadFile(cloverFile)
+ if err != nil {
+ fmt.Println("Please specify a valid rule definition yaml file")
+ return
+ }
+ out_json, err := yaml.YAMLToJSON(in)
+ if err != nil {
+ panic(err.Error())
+ }
+ resp, err := resty.R().
+ SetHeader("Content-Type", "application/json").
+ SetBody(out_json).
+ Post(url)
+ if err != nil {
+ panic(err.Error())
+ }
+ fmt.Printf("\n%v\n", resp)
+ //fmt.Println(string(out_json))
+
+}
diff --git a/clover/cloverctl/src/cloverctl/cmd/create_system.go b/clover/cloverctl/src/cloverctl/cmd/create_system.go
new file mode 100644
index 0000000..68fa5af
--- /dev/null
+++ b/clover/cloverctl/src/cloverctl/cmd/create_system.go
@@ -0,0 +1,37 @@
+// Copyright (c) Authors of Clover
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Apache License, Version 2.0
+// which accompanies this distribution, and is available at
+// http://www.apache.org/licenses/LICENSE-2.0
+
+package cmd
+
+import (
+ "fmt"
+ //"io/ioutil"
+ //"github.com/ghodss/yaml"
+ "github.com/spf13/cobra"
+ "cloverkube"
+)
+
+
+var systemCmd = &cobra.Command{
+ Use: "system",
+ Short: "Deploy clover-system in Kubernetes",
+ Long: ``,
+ Run: func(cmd *cobra.Command, args []string) {
+ createCloverSystem()
+ },
+}
+
+func init() {
+ createCmd.AddCommand(systemCmd)
+ //systemCmd.PersistentFlags().StringVarP(&cloverFile, "f", "f", "", "Input yaml file to create system")
+
+}
+
+func createCloverSystem() {
+ cloverkube.DeployCloverSystem("create", "clover-system")
+ fmt.Println("Deployed clover-system successfully")
+}
diff --git a/clover/cloverctl/src/cloverctl/cmd/create_testplan.go b/clover/cloverctl/src/cloverctl/cmd/create_testplan.go
new file mode 100644
index 0000000..686d5ba
--- /dev/null
+++ b/clover/cloverctl/src/cloverctl/cmd/create_testplan.go
@@ -0,0 +1,57 @@
+// Copyright (c) Authors of Clover
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Apache License, Version 2.0
+// which accompanies this distribution, and is available at
+// http://www.apache.org/licenses/LICENSE-2.0
+
+package cmd
+
+import (
+ "fmt"
+ "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",
+ 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.MarkFlagRequired("file")
+}
+
+func createTestPlan() {
+ url := controllerIP + "/jmeter/gen"
+ in, err := ioutil.ReadFile(cloverFile)
+ if err != nil {
+ fmt.Println("Please specify a valid test plan yaml file")
+ return
+ }
+ out_json, err := yaml.YAMLToJSON(in)
+ if err != nil {
+ panic(err.Error())
+ }
+ resp, err := resty.R().
+ SetHeader("Content-Type", "application/json").
+ SetBody(out_json).
+ Post(url)
+ if err != nil {
+ panic(err.Error())
+ }
+ fmt.Printf("\n%v\n", resp)
+ //fmt.Println(string(out_json))
+
+}
+
diff --git a/clover/cloverctl/src/cloverctl/cmd/delete.go b/clover/cloverctl/src/cloverctl/cmd/delete.go
new file mode 100644
index 0000000..742d769
--- /dev/null
+++ b/clover/cloverctl/src/cloverctl/cmd/delete.go
@@ -0,0 +1,26 @@
+// Copyright (c) Authors of Clover
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Apache License, Version 2.0
+// which accompanies this distribution, and is available at
+// http://www.apache.org/licenses/LICENSE-2.0
+
+package cmd
+
+import (
+ "fmt"
+ "github.com/spf13/cobra"
+)
+
+var deleteCmd = &cobra.Command{
+ Use: "delete",
+ Short: "Delete resources including clover-system services",
+ Long: ``,
+ Run: func(cmd *cobra.Command, args []string) {
+ fmt.Println("delete called")
+ },
+}
+
+func init() {
+ rootCmd.AddCommand(deleteCmd)
+}
diff --git a/clover/cloverctl/src/cloverctl/cmd/delete_system.go b/clover/cloverctl/src/cloverctl/cmd/delete_system.go
new file mode 100644
index 0000000..bc3f22b
--- /dev/null
+++ b/clover/cloverctl/src/cloverctl/cmd/delete_system.go
@@ -0,0 +1,33 @@
+// Copyright (c) Authors of Clover
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Apache License, Version 2.0
+// which accompanies this distribution, and is available at
+// http://www.apache.org/licenses/LICENSE-2.0
+
+package cmd
+
+import (
+ "fmt"
+ "github.com/spf13/cobra"
+ "cloverkube"
+)
+
+
+var delsystemCmd = &cobra.Command{
+ Use: "system",
+ Short: "Delete clover-system in Kubernetes",
+ Long: ``,
+ Run: func(cmd *cobra.Command, args []string) {
+ delCloverSystem()
+ },
+}
+
+func init() {
+ deleteCmd.AddCommand(delsystemCmd)
+}
+
+func delCloverSystem() {
+ cloverkube.DeployCloverSystem("delete", "clover-system")
+ fmt.Println("Deleted clover-system successfully")
+}
diff --git a/clover/cloverctl/src/cloverctl/cmd/get.go b/clover/cloverctl/src/cloverctl/cmd/get.go
new file mode 100644
index 0000000..ae3d98e
--- /dev/null
+++ b/clover/cloverctl/src/cloverctl/cmd/get.go
@@ -0,0 +1,26 @@
+// Copyright (c) Authors of Clover
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Apache License, Version 2.0
+// which accompanies this distribution, and is available at
+// http://www.apache.org/licenses/LICENSE-2.0
+
+package cmd
+
+import (
+ "fmt"
+ "github.com/spf13/cobra"
+)
+
+var getCmd = &cobra.Command{
+ Use: "get",
+ Short: "Get information about a resource",
+ Long: ``,
+ Run: func(cmd *cobra.Command, args []string) {
+ fmt.Println("get called")
+ },
+}
+
+func init() {
+ rootCmd.AddCommand(getCmd)
+}
diff --git a/clover/cloverctl/src/cloverctl/cmd/get_services.go b/clover/cloverctl/src/cloverctl/cmd/get_services.go
new file mode 100644
index 0000000..cfa56bd
--- /dev/null
+++ b/clover/cloverctl/src/cloverctl/cmd/get_services.go
@@ -0,0 +1,26 @@
+// Copyright (c) Authors of Clover
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Apache License, Version 2.0
+// which accompanies this distribution, and is available at
+// http://www.apache.org/licenses/LICENSE-2.0
+
+package cmd
+
+import (
+ "github.com/spf13/cobra"
+ "cloverkube"
+)
+
+var servicesCmd = &cobra.Command{
+ Use: "services",
+ Short: "Get info on Kubernetes services",
+ Long: ``,
+ Run: func(cmd *cobra.Command, args []string) {
+ cloverkube.GetServices()
+ },
+}
+
+func init() {
+ getCmd.AddCommand(servicesCmd)
+}
diff --git a/clover/cloverctl/src/cloverctl/cmd/get_testresult.go b/clover/cloverctl/src/cloverctl/cmd/get_testresult.go
new file mode 100644
index 0000000..12d47c3
--- /dev/null
+++ b/clover/cloverctl/src/cloverctl/cmd/get_testresult.go
@@ -0,0 +1,56 @@
+// Copyright (c) Authors of Clover
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Apache License, Version 2.0
+// which accompanies this distribution, and is available at
+// http://www.apache.org/licenses/LICENSE-2.0
+
+package cmd
+
+import (
+ "fmt"
+ "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",
+ Long: ``,
+ Run: func(cmd *cobra.Command, args []string) {
+ getResult()
+ },
+}
+
+func init() {
+ getCmd.AddCommand(testresultCmd)
+ testresultCmd.Flags().StringVarP(&JmeterResult, "r", "r", "", "Result to retrieve - use 'log' or 'results'")
+ testresultCmd.MarkFlagRequired("r")
+
+}
+
+
+func getResult() {
+ switch JmeterResult {
+ case "results":
+ url := controllerIP + "/jmeter/results/results"
+ resp, err := resty.R().
+ Get(url)
+ if err != nil {
+ panic(err.Error())
+ }
+ fmt.Printf("\nResponse Body: %v\n", resp)
+ case "log":
+ url := controllerIP + "/jmeter/results/log"
+ resp, err := resty.R().
+ Get(url)
+ if err != nil {
+ panic(err.Error())
+ }
+ fmt.Printf("\nResponse Body: %v\n", resp)
+ default:
+ fmt.Println("Unrecoginized jmeter result type - use 'log' or 'results'")
+ }
+}
diff --git a/clover/cloverctl/src/cloverctl/cmd/get_visibility.go b/clover/cloverctl/src/cloverctl/cmd/get_visibility.go
new file mode 100644
index 0000000..d987412
--- /dev/null
+++ b/clover/cloverctl/src/cloverctl/cmd/get_visibility.go
@@ -0,0 +1,41 @@
+// Copyright (c) Authors of Clover
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Apache License, Version 2.0
+// which accompanies this distribution, and is available at
+// http://www.apache.org/licenses/LICENSE-2.0
+
+package cmd
+
+import (
+ "fmt"
+ "gopkg.in/resty.v1"
+ "github.com/spf13/cobra"
+)
+
+
+var visibilitystatsCmd = &cobra.Command{
+ Use: "visibility",
+ Short: "Get toplevel visibility stats",
+ Long: ``,
+ Run: func(cmd *cobra.Command, args []string) {
+ statsCollector()
+ },
+}
+
+func init() {
+ getCmd.AddCommand(visibilitystatsCmd)
+ //visibilitystartCmd.PersistentFlags().StringVarP(&cloverFile, "f", "f", "", "Input yaml file with test plan params")
+}
+
+func statsCollector() {
+ url := controllerIP + "/collector/stats"
+
+ resp, err := resty.R().
+ SetHeader("Accept", "application/json").
+ Get(url)
+ if err != nil {
+ panic(err.Error())
+ }
+ fmt.Printf("\nProxy Response Time: %v\n", resp)
+}
diff --git a/clover/cloverctl/src/cloverctl/cmd/init.go b/clover/cloverctl/src/cloverctl/cmd/init.go
new file mode 100644
index 0000000..613b263
--- /dev/null
+++ b/clover/cloverctl/src/cloverctl/cmd/init.go
@@ -0,0 +1,26 @@
+// Copyright (c) Authors of Clover
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Apache License, Version 2.0
+// which accompanies this distribution, and is available at
+// http://www.apache.org/licenses/LICENSE-2.0
+
+package cmd
+
+import (
+ "fmt"
+ "github.com/spf13/cobra"
+)
+
+var initCmd = &cobra.Command{
+ Use: "init",
+ Short: "Initialize visibility schemas",
+ Long: ``,
+ Run: func(cmd *cobra.Command, args []string) {
+ fmt.Println("init called")
+ },
+}
+
+func init() {
+ rootCmd.AddCommand(initCmd)
+}
diff --git a/clover/cloverctl/src/cloverctl/cmd/init_visibility.go b/clover/cloverctl/src/cloverctl/cmd/init_visibility.go
new file mode 100644
index 0000000..ac9ec5c
--- /dev/null
+++ b/clover/cloverctl/src/cloverctl/cmd/init_visibility.go
@@ -0,0 +1,41 @@
+// Copyright (c) Authors of Clover
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Apache License, Version 2.0
+// which accompanies this distribution, and is available at
+// http://www.apache.org/licenses/LICENSE-2.0
+
+package cmd
+
+import (
+ "fmt"
+ "gopkg.in/resty.v1"
+ "github.com/spf13/cobra"
+)
+
+
+var visibilityinitCmd = &cobra.Command{
+ Use: "visibility",
+ Short: "Init visibility data schemas",
+ Long: ``,
+ Run: func(cmd *cobra.Command, args []string) {
+ initCollector()
+ },
+}
+
+func init() {
+ initCmd.AddCommand(visibilityinitCmd)
+}
+
+func initCollector() {
+ url := controllerIP + "/collector/init"
+
+ resp, err := resty.R().
+ Get(url)
+ if err != nil {
+ panic(err.Error())
+ }
+ fmt.Printf("\n%v\n", resp)
+}
+
+
diff --git a/clover/cloverctl/src/cloverctl/cmd/root.go b/clover/cloverctl/src/cloverctl/cmd/root.go
new file mode 100644
index 0000000..6878077
--- /dev/null
+++ b/clover/cloverctl/src/cloverctl/cmd/root.go
@@ -0,0 +1,90 @@
+// Copyright (c) Authors of Clover
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Apache License, Version 2.0
+// which accompanies this distribution, and is available at
+// http://www.apache.org/licenses/LICENSE-2.0
+
+package cmd
+
+import (
+ "fmt"
+ "os"
+
+ homedir "github.com/mitchellh/go-homedir"
+ "github.com/spf13/cobra"
+ "github.com/spf13/viper"
+ "cloverkube"
+)
+
+var cfgFile string
+
+var controllerIP string
+var cloverFile string
+
+// rootCmd represents the base command when called without any subcommands
+var rootCmd = &cobra.Command{
+ Use: "cloverctl",
+ Short: "Command-Line Interface (CLI) for Clover",
+ Long: ``,
+ // Uncomment the following line if your bare application
+ // has an action associated with it:
+ //Run: func(cmd *cobra.Command, args []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.
+func Execute() {
+ if err := rootCmd.Execute(); err != nil {
+ fmt.Println(err)
+ os.Exit(1)
+ }
+}
+
+func init() {
+ cobra.OnInitialize(initConfig)
+
+ // 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)")
+
+ // 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.
+func initConfig() {
+ if cfgFile != "" {
+ // Use config file from the flag.
+ viper.SetConfigFile(cfgFile)
+ } else {
+ // Find home directory.
+ home, err := homedir.Dir()
+ if err != nil {
+ fmt.Println(err)
+ os.Exit(1)
+ }
+
+ // Search config in home directory with name ".cloverctl" (without extension).
+ viper.AddConfigPath(home)
+ viper.SetConfigName(".cloverctl")
+ }
+
+ viper.AutomaticEnv() // read in environment variables that match
+
+ // If a config file is found, read it in.
+ if err := viper.ReadInConfig(); err == nil {
+ fmt.Println("Using config file:", viper.ConfigFileUsed())
+ }
+}
diff --git a/clover/cloverctl/src/cloverctl/cmd/start.go b/clover/cloverctl/src/cloverctl/cmd/start.go
new file mode 100644
index 0000000..741eacd
--- /dev/null
+++ b/clover/cloverctl/src/cloverctl/cmd/start.go
@@ -0,0 +1,26 @@
+// Copyright (c) Authors of Clover
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Apache License, Version 2.0
+// which accompanies this distribution, and is available at
+// http://www.apache.org/licenses/LICENSE-2.0
+
+package cmd
+
+import (
+ "fmt"
+ "github.com/spf13/cobra"
+)
+
+var startCmd = &cobra.Command{
+ Use: "start",
+ Short: "Start processes including tests, visibility and ingress services",
+ Long: ``,
+ Run: func(cmd *cobra.Command, args []string) {
+ fmt.Println("start called")
+ },
+}
+
+func init() {
+ rootCmd.AddCommand(startCmd)
+}
diff --git a/clover/cloverctl/src/cloverctl/cmd/start_ids.go b/clover/cloverctl/src/cloverctl/cmd/start_ids.go
new file mode 100644
index 0000000..0f495a7
--- /dev/null
+++ b/clover/cloverctl/src/cloverctl/cmd/start_ids.go
@@ -0,0 +1,42 @@
+// Copyright (c) Authors of Clover
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Apache License, Version 2.0
+// which accompanies this distribution, and is available at
+// http://www.apache.org/licenses/LICENSE-2.0
+
+package cmd
+
+import (
+ "fmt"
+ "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`,
+ Run: func(cmd *cobra.Command, args []string) {
+ startIDS()
+ },
+}
+
+func init() {
+ startCmd.AddCommand(startidsCmd)
+}
+
+func startIDS() {
+
+ url := controllerIP + "/snort/start"
+
+ resp, err := resty.R().
+ Get(url)
+ if err != nil {
+ panic(err.Error())
+ }
+ fmt.Printf("\n%v\n", resp)
+}
+
+
diff --git a/clover/cloverctl/src/cloverctl/cmd/start_testplan.go b/clover/cloverctl/src/cloverctl/cmd/start_testplan.go
new file mode 100644
index 0000000..b516ad6
--- /dev/null
+++ b/clover/cloverctl/src/cloverctl/cmd/start_testplan.go
@@ -0,0 +1,59 @@
+// Copyright (c) Authors of Clover
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Apache License, Version 2.0
+// which accompanies this distribution, and is available at
+// http://www.apache.org/licenses/LICENSE-2.0
+
+package cmd
+
+import (
+ "fmt"
+ "strings"
+ "gopkg.in/resty.v1"
+ "github.com/spf13/cobra"
+ "cloverkube"
+)
+
+
+var testplanstartCmd = &cobra.Command{
+ Use: "testplan",
+ Short: "Start a test for a given test plan",
+ Long: `Specify number of slaves to use with '-s' flag. Default is 0 slaves,
+which runs tests only from jmeter-master.`,
+ 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")
+}
+
+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))
+ return
+ }
+ ip_list := strings.Join(ips[0:num_slaves], ",")
+
+ 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)).
+ Post(url)
+ if err != nil {
+ panic(err.Error())
+ }
+ fmt.Printf("\n%v\n", resp)
+
+}
+
+
diff --git a/clover/cloverctl/src/cloverctl/cmd/start_visibility.go b/clover/cloverctl/src/cloverctl/cmd/start_visibility.go
new file mode 100644
index 0000000..18f8aac
--- /dev/null
+++ b/clover/cloverctl/src/cloverctl/cmd/start_visibility.go
@@ -0,0 +1,60 @@
+// Copyright (c) Authors of Clover
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Apache License, Version 2.0
+// which accompanies this distribution, and is available at
+// http://www.apache.org/licenses/LICENSE-2.0
+
+package cmd
+
+import (
+ "fmt"
+ "io/ioutil"
+ "gopkg.in/resty.v1"
+ "github.com/ghodss/yaml"
+ "github.com/spf13/cobra"
+)
+
+
+var visibilitystartCmd = &cobra.Command{
+ Use: "visibility",
+ Short: "Start visibility data collection",
+ Long: ``,
+ Run: func(cmd *cobra.Command, args []string) {
+ startCollector()
+ },
+}
+
+func init() {
+ startCmd.AddCommand(visibilitystartCmd)
+ visibilitystartCmd.PersistentFlags().StringVarP(&cloverFile, "file", "f", "", "Optional yaml file with collector params")
+}
+
+func startCollector() {
+
+ var message_body string
+ if cloverFile != "" {
+ in, err := ioutil.ReadFile(cloverFile)
+ if err != nil {
+ panic(err.Error())
+ }
+ out_json, err := yaml.YAMLToJSON(in)
+ message_body = string(out_json)
+ if err != nil {
+ panic(err.Error())
+ }
+ } else {
+ message_body = `{"sample_interval":"10", "t_port":"80", "t_host":"jaeger-query.istio-system"}`
+ }
+ 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("\n%v\n", resp)
+}
+
+
diff --git a/clover/cloverctl/src/cloverctl/cmd/stop.go b/clover/cloverctl/src/cloverctl/cmd/stop.go
new file mode 100644
index 0000000..cfb7245
--- /dev/null
+++ b/clover/cloverctl/src/cloverctl/cmd/stop.go
@@ -0,0 +1,26 @@
+// Copyright (c) Authors of Clover
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Apache License, Version 2.0
+// which accompanies this distribution, and is available at
+// http://www.apache.org/licenses/LICENSE-2.0
+
+package cmd
+
+import (
+ "fmt"
+ "github.com/spf13/cobra"
+)
+
+var stopCmd = &cobra.Command{
+ Use: "stop",
+ Short: "Stop processes including visibility and ingress services",
+ Long: ``,
+ Run: func(cmd *cobra.Command, args []string) {
+ fmt.Println("stop called")
+ },
+}
+
+func init() {
+ rootCmd.AddCommand(stopCmd)
+}
diff --git a/clover/cloverctl/src/cloverctl/cmd/stop_ids.go b/clover/cloverctl/src/cloverctl/cmd/stop_ids.go
new file mode 100644
index 0000000..b39b1e9
--- /dev/null
+++ b/clover/cloverctl/src/cloverctl/cmd/stop_ids.go
@@ -0,0 +1,42 @@
+// Copyright (c) Authors of Clover
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Apache License, Version 2.0
+// which accompanies this distribution, and is available at
+// http://www.apache.org/licenses/LICENSE-2.0
+
+package cmd
+
+import (
+ "fmt"
+ "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`,
+ Run: func(cmd *cobra.Command, args []string) {
+ stopIDS()
+ },
+}
+
+func init() {
+ stopCmd.AddCommand(stopidsCmd)
+}
+
+func stopIDS() {
+
+ url := controllerIP + "/snort/stop"
+
+ resp, err := resty.R().
+ Get(url)
+ if err != nil {
+ panic(err.Error())
+ }
+ fmt.Printf("\n%v\n", resp)
+}
+
+
diff --git a/clover/cloverctl/src/cloverctl/cmd/stop_visibility.go b/clover/cloverctl/src/cloverctl/cmd/stop_visibility.go
new file mode 100644
index 0000000..4233157
--- /dev/null
+++ b/clover/cloverctl/src/cloverctl/cmd/stop_visibility.go
@@ -0,0 +1,42 @@
+// Copyright (c) Authors of Clover
+//
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Apache License, Version 2.0
+// which accompanies this distribution, and is available at
+// http://www.apache.org/licenses/LICENSE-2.0
+
+package cmd
+
+import (
+ "fmt"
+ "gopkg.in/resty.v1"
+ "github.com/spf13/cobra"
+)
+
+
+var visibilitystopCmd = &cobra.Command{
+ Use: "visibility",
+ Short: "Stop visibility data collection",
+ Long: ``,
+ Run: func(cmd *cobra.Command, args []string) {
+ stopCollector()
+ },
+}
+
+func init() {
+ stopCmd.AddCommand(visibilitystopCmd)
+}
+
+func stopCollector() {
+
+ url := controllerIP + "/collector/stop"
+
+ resp, err := resty.R().
+ Get(url)
+ if err != nil {
+ panic(err.Error())
+ }
+ fmt.Printf("\n%v\n", resp)
+}
+
+