update info of infra/README.md
[ealt-edge.git] / ocd / cli / ealt / cmd / setup / install.go
1 /*
2 Copyright 2020 Huawei Technologies Co., Ltd.
3
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
7
8     http://www.apache.org/licenses/LICENSE-2.0
9
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.
15 */
16 package setup
17
18 import (
19         "fmt"
20 )
21
22 //Function : Commands for all installation components.
23 //Depending on the option respective command will be executed.
24 func EaltInstall(component string) error {
25         var strEaltSetup string
26         switch component {
27         case "all":
28                 strEaltSetup = fmt.Sprintf("ansible-playbook ealt-all.yml -i ealt-inventory.ini --extra-vars \"operation=install\"")
29         case "edge":
30                 strEaltSetup = fmt.Sprintf("ansible-playbook ealt-all.yml -i ealt-inventory.ini --tags \"edge\" --extra-vars \"operation=install\"")
31         default:
32                 fmt.Println("Provide subcommand for ealt init [all|edge]")
33         }
34
35         stdout, err := runCommandAtShell(strEaltSetup)
36         if err != nil {
37                 return err
38         }
39         fmt.Println(stdout)
40         return nil
41 }
42
43 func EaltReset(component string) error {
44         var strEaltReset string
45
46         switch component {
47         case "all":
48                 strEaltReset = fmt.Sprintf("ansible-playbook ealt-all-uninstall.yml -i ealt-inventory.ini --extra-vars \"operation=uninstall\"")
49         case "edge":
50                 strEaltReset = fmt.Sprintf("ansible-playbook ealt-all-uninstall.yml -i ealt-inventory.ini --tags \"edge\" --extra-vars \"operation=uninstall\"")
51         default:
52                 fmt.Println("Provide subcommand for ealt clean [all|edge]")
53         }
54
55         stdout, err := runCommandAtShell(strEaltReset)
56         if err != nil {
57                 return err
58         }
59         fmt.Println(stdout)
60         return nil
61 }