2 // Copyright © 2019 NAME HERE <EMAIL ADDRESS>
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
22 "github.com/spf13/cobra"
28 elcliSetupCmdDescription =
30 ELIOT init command is for setting up the ELIOT Cluster.
31 The command has options to setup the complete setup which includes
32 ELIOT Manager and ELIOT Edge Nodes and to setup only ELIOT Manager
33 or ELIOT Edge Node. The command invokes setup.sh script which handles
36 The Details of ELIOT Edge Nodes must be present in [nodelist] file.
39 // initCmd represents the init command
40 var initCmd = &cobra.Command{
42 Short: "Setup ELIOT Cluster !!",
43 Long: elcliSetupCmdDescription,
44 //It will check if the kubernetes process is already running on the node.
45 //Abort the operation if already running.
46 PreRunE: func(cmd *cobra.Command,args []string) error {
47 isELIOTClusterRunning, err := util.IsK8SClusterRunning()
50 } else if (isELIOTClusterRunning) {
51 return fmt.Errorf("Kubernetes Cluster is running in the Node. Clean up the environment and then setup the Cluster")
55 RunE: func(cmd *cobra.Command, args []string) error{
56 fmt.Println("init called")
57 setupFlag := cmd.Flag("setup")
58 setupflagoption := setupFlag.Value.String()
60 switch setupflagoption {
62 err:= util.EliotSetupAll()
64 fmt.Println("Inside all option for setup flag")
66 fmt.Println("Its eliot setup Master")
67 err:= util.EliotSetupMaster()
70 fmt.Println("Provide option for flag [--setup :- all | master] or [-s :- all | master]")
77 rootCmd.AddCommand(initCmd)
78 initCmd.Flags().StringP("setup","s","all","Eliot Topology setup options")