func init() {
cleanCmd.AddCommand(cleancmds.NewAllCommand())
- //ealt init infra
- cleanCmd.AddCommand(cleancmds.NewInfraCommand())
- //ealt init manager
- cleanCmd.AddCommand(cleancmds.NewMecmCommand())
+
//ealt init edge
cleanCmd.AddCommand(cleancmds.NewEdgeCommand())
- //ealt init k8s
- cleanCmd.AddCommand(cleancmds.NewK8SCommand())
- //ealt init k3s
- cleanCmd.AddCommand(cleancmds.NewK3SCommand())
//Add init subcommand to root command.
rootCmd.AddCommand(cleanCmd)
+++ /dev/null
-/*
-Copyright 2020 Huawei Technologies Co., Ltd.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-package init
-
-import (
- setup "ealt/cmd/setup"
-
- "github.com/spf13/cobra"
-)
-
-func NewInfraCommand() *cobra.Command {
- var cmd = &cobra.Command{
- Use: "infra",
- Short: "Uninstall only infrastructure components on MECM and Edge Node",
- Long: `Command to Uninstall only infrastructure components on MECM and Edge Node For Example : ealt clean infra`,
- RunE: func(cmd *cobra.Command, args []string) error {
- err := setup.EaltReset("infra")
- if err != nil {
- return err
- }
- return nil
- },
- }
- return cmd
-}
+++ /dev/null
-/*
-Copyright 2020 Huawei Technologies Co., Ltd.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-package init
-
-import (
- setup "ealt/cmd/setup"
-
- "github.com/spf13/cobra"
-)
-
-// allCmd represents the all command
-func NewK3SCommand() *cobra.Command {
- var cmd = &cobra.Command{
- Use: "k3s",
- Short: "Command to uninstall K3S cluster on Edge Node",
- Long: `Command to uninstall K3S cluster on Edge Node`,
- RunE: func(cmd *cobra.Command, args []string) error {
- err := setup.EaltReset("k3s")
- if err != nil {
- return err
- }
- return nil
- },
- }
- return cmd
-}
+++ /dev/null
-/*
-Copyright 2020 Huawei Technologies Co., Ltd.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-package init
-
-import (
- "ealt/cmd/setup"
-
- "github.com/spf13/cobra"
-)
-
-// allCmd represents the all command
-func NewK8SCommand() *cobra.Command {
- var cmd = &cobra.Command{
- Use: "k8s",
- Short: "Command to uninstall K8S cluster on MECM Node",
- Long: `Command to uninstall K8S cluster on MECM Node`,
- RunE: func(cmd *cobra.Command, args []string) error {
- err := setup.EaltReset("k8s")
- if err != nil {
- return err
- }
- return nil
- },
- }
- return cmd
-}
+++ /dev/null
-/*
-Copyright 2020 Huawei Technologies Co., Ltd.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-package init
-
-import (
- setup "ealt/cmd/setup"
-
- "github.com/spf13/cobra"
-)
-
-// allCmd represents the all command
-func NewMecmCommand() *cobra.Command {
- var cmd = &cobra.Command{
- Use: "manager",
- Short: "Command to install MECM Controller",
- Long: `Command to Install MECM Controller Node`,
- RunE: func(cmd *cobra.Command, args []string) error {
- err := setup.EaltReset("manager")
- if err != nil {
- return err
- }
- return nil
- },
- }
- return cmd
-}
//Adding the various sub-commands of init command
//Adding all subcommand to init
initCmd.AddCommand(initCmds.NewAllCommand())
- //ealt init infra
- initCmd.AddCommand(initCmds.NewInfraCommand())
- //ealt init manager
- initCmd.AddCommand(initCmds.NewMecmCommand())
+
//ealt init edge
initCmd.AddCommand(initCmds.NewEdgeCommand())
- //ealt init k8s
- initCmd.AddCommand(initCmds.NewK8SCommand())
- //ealt init k3s
- initCmd.AddCommand(initCmds.NewK3SCommand())
//Add init subcommand to root command.
rootCmd.AddCommand(initCmd)
import (
setup "ealt/cmd/setup"
- "strings"
"github.com/spf13/cobra"
)
Short: "Install Complete EALT Deployment Environment",
Long: `Install Complete EALT Deployment Environment`,
RunE: func(cmd *cobra.Command, args []string) error {
- setupModeFlag := strings.ToLower(cmd.Flag("mode").Value.String())
var err error
- if setupModeFlag == "dev" {
- err = setup.EaltInstall("all")
- } else if setupModeFlag == "prod" {
- err = setup.EaltInstall("secure")
- }
+ err = setup.EaltInstall("all")
if err != nil {
return err
}
import (
"fmt"
- "strings"
setup "ealt/cmd/setup"
Long: `Command to Install Edge Node only For Example : ealt init edge`,
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println("Installation of Edge components")
- setupModeFlag := strings.ToLower(cmd.Flag("mode").Value.String())
var err error
- if setupModeFlag == "dev" {
- err = setup.EaltInstall("edge")
- } else if setupModeFlag == "prod" {
- err = setup.EaltInstall("ssledge")
- }
+ err = setup.EaltInstall("edge")
if err != nil {
return err
}
+++ /dev/null
-/*
-Copyright 2020 Huawei Technologies Co., Ltd.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-package init
-
-import (
- setup "ealt/cmd/setup"
-
- "github.com/spf13/cobra"
-)
-
-func NewInfraCommand() *cobra.Command {
- var cmd = &cobra.Command{
- Use: "infra",
- Short: "Install only infrastructure components on MECM and Edge Node",
- Long: `Command to install only infrastructure components on MECM and Edge Node For Example : ealt init infra`,
- RunE: func(cmd *cobra.Command, args []string) error {
- err := setup.EaltInstall("infra")
- if err != nil {
- return err
- }
- return nil
- },
- }
- return cmd
-}
+++ /dev/null
-/*
-Copyright 2020 Huawei Technologies Co., Ltd.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-package init
-
-import (
- "ealt/cmd/setup"
-
- "github.com/spf13/cobra"
-)
-
-// allCmd represents the all command
-func NewK3SCommand() *cobra.Command {
- var cmd = &cobra.Command{
- Use: "k3s",
- Short: "Command to install K3S cluster on Edge Node",
- Long: `Command to install K3S cluster on Edge Node`,
- RunE: func(cmd *cobra.Command, args []string) error {
- err := setup.EaltInstall("k3s")
- if err != nil {
- return err
- }
- return nil
- },
- }
- return cmd
-}
+++ /dev/null
-/*
-Copyright 2020 Huawei Technologies Co., Ltd.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-package init
-
-import (
- "ealt/cmd/setup"
-
- "github.com/spf13/cobra"
-)
-
-// allCmd represents the all command
-func NewK8SCommand() *cobra.Command {
- var cmd = &cobra.Command{
- Use: "k8s",
- Short: "Command to install K8S cluster on MECM Node",
- Long: `Command to install K8S cluster on MECM Node`,
- RunE: func(cmd *cobra.Command, args []string) error {
- err := setup.EaltInstall("k8s")
- if err != nil {
- return err
- }
- return nil
- },
- }
- return cmd
-}
+++ /dev/null
-/*
-Copyright 2020 Huawei Technologies Co., Ltd.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-package init
-
-import (
- "ealt/cmd/setup"
- "strings"
-
- "github.com/spf13/cobra"
-)
-
-// allCmd represents the all command
-func NewMecmCommand() *cobra.Command {
- var cmd = &cobra.Command{
- Use: "manager",
- Short: "Command to install MECM Controller",
- Long: `Command to Install MECM Controller Node`,
- RunE: func(cmd *cobra.Command, args []string) error {
- setupModeFlag := strings.ToLower(cmd.Flag("mode").Value.String())
- var err error
- if setupModeFlag == "dev" {
- err = setup.EaltInstall("mecm")
- } else if setupModeFlag == "prod" {
- err = setup.EaltInstall("sslmecm")
- }
- if err != nil {
- return err
- }
- return nil
- },
- }
- cmd.Flags().StringP("mode", "m", "dev", "Deployment Mode")
- return cmd
-}
var strEaltSetup string
switch component {
case "all":
- strEaltSetup = fmt.Sprintf("ansible-playbook ealt-all.yml -i ealt-inventory.ini --extra-vars \"operation=install mode=dev\"")
- // Production Mode : SSL Mode Installation Command.
- case "sslall":
- strEaltSetup = fmt.Sprintf("ansible-playbook ealt-all.yml -i ealt-inventory.ini --extra-vars \"operation=install mode=prod\"")
- case "infra":
- strEaltSetup = fmt.Sprintf("ansible-playbook ealt-all.yml -i ealt-inventory.ini --tags \"infra\" --extra-vars \"operation=install\"")
- case "mecm":
- strEaltSetup = fmt.Sprintf("ansible-playbook ealt-all.yml -i ealt-inventory.ini --tags \"mecm\" --extra-vars \"operation=install mode=dev\"")
- case "sslmecm":
- strEaltSetup = fmt.Sprintf("ansible-playbook ealt-all.yml -i ealt-inventory.ini --tags \"mecm\" --extra-vars \"operation=install mode=prod\"")
+ strEaltSetup = fmt.Sprintf("ansible-playbook ealt-all.yml -i ealt-inventory.ini --extra-vars \"operation=install\"")
case "edge":
- strEaltSetup = fmt.Sprintf("ansible-playbook ealt-all.yml -i ealt-inventory.ini --tags \"mep\" --extra-vars \"operation=install mode=dev\"")
- case "ssledge":
- strEaltSetup = fmt.Sprintf("ansible-playbook ealt-all.yml -i ealt-inventory.ini --tags \"mep\" --extra-vars \"operation=install mode=prod\"")
- case "k8s":
- strEaltSetup = fmt.Sprintf("ansible-playbook ealt-all.yml -i ealt-inventory.ini --tags \"k8s\" --extra-vars \"operation=install\"")
- case "k3s":
- strEaltSetup = fmt.Sprintf("ansible-playbook ealt-all.yml -i ealt-inventory.ini --tags \"k3s\" --extra-vars \"operation=install\"")
+ strEaltSetup = fmt.Sprintf("ansible-playbook ealt-all.yml -i ealt-inventory.ini --tags \"edge\" --extra-vars \"operation=install\"")
default:
- fmt.Println("Provide subcommand for ealt init [all|infra|manager|edge|k8s|k3s]")
+ fmt.Println("Provide subcommand for ealt init [all|edge]")
}
stdout, err := runCommandAtShell(strEaltSetup)
switch component {
case "all":
strEaltReset = fmt.Sprintf("ansible-playbook ealt-all-uninstall.yml -i ealt-inventory.ini --extra-vars \"operation=uninstall\"")
- case "infra":
- strEaltReset = fmt.Sprintf("ansible-playbook ealt-all-uninstall.yml -i ealt-inventory.ini --tags \"infra\" --extra-vars \"operation=uninstall\"")
- case "manager":
- strEaltReset = fmt.Sprintf("ansible-playbook ealt-all-uninstall.yml -i ealt-inventory.ini --tags \"mecm\" --extra-vars \"operation=uninstall\"")
case "edge":
- strEaltReset = fmt.Sprintf("ansible-playbook ealt-all-uninstall.yml -i ealt-inventory.ini --tags \"mep\" --extra-vars \"operation=uninstall\"")
- case "k8s":
- strEaltReset = fmt.Sprintf("cd ~/kubespray && yes | ansible-playbook -i inventory/mycluster/hosts.yaml --user root reset.yml")
- case "k3s":
- strEaltReset = fmt.Sprintf("ansible-playbook ealt-all-uninstall.yml -i ealt-inventory.ini --tags \"k3s\" --extra-vars \"operation=uninstall\"")
+ strEaltReset = fmt.Sprintf("ansible-playbook ealt-all-uninstall.yml -i ealt-inventory.ini --tags \"edge\" --extra-vars \"operation=uninstall\"")
default:
- fmt.Println("Provide subcommand for ealt clean [all|infra|manager|edge|k8s|k3s]")
+ fmt.Println("Provide subcommand for ealt clean [all|edge]")
}
stdout, err := runCommandAtShell(strEaltReset)