-
Notifications
You must be signed in to change notification settings - Fork 15
/
installbydcos.go
95 lines (79 loc) · 2.54 KB
/
installbydcos.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package install
import (
log "github.com/sirupsen/logrus"
"github.com/CS-SI/SafeScale/lib/server/install/enums/Action"
"github.com/CS-SI/SafeScale/lib/server/install/enums/Method"
)
const (
dcosCli = "sudo -u cladm -i dcos"
kubectlCli = "sudo -u cladm -i kubectl"
marathonCli = "sudo -u cladm -i marathon"
)
// dcosInstaller is an installer using script to add and remove a feature
type dcosInstaller struct{}
func (i *dcosInstaller) GetName() string {
return "dcos"
}
// Check checks if the feature is installed
func (i *dcosInstaller) Check(c *Feature, t Target, v Variables, s Settings) (Results, error) {
worker, err := newWorker(c, t, Method.DCOS, Action.Check, nil)
if err != nil {
return nil, err
}
err = worker.CanProceed(s)
if err != nil {
log.Println(err.Error())
return nil, err
}
// Replaces variables in normalized script
//v["DomainName"] = cluster.GetDomainName().DomainName
// v["dcos"] = dcosCli
// v["kubectl"] = kubectlCli
v["options"] = ""
return worker.Proceed(v, s)
}
// Add installs the feature in a DCOS cluster
func (i *dcosInstaller) Add(c *Feature, t Target, v Variables, s Settings) (Results, error) {
worker, err := newWorker(c, t, Method.DCOS, Action.Add, nil)
if err != nil {
return nil, err
}
err = worker.CanProceed(s)
if err != nil {
log.Println(err.Error())
return nil, err
}
// Replaces variables in normalized script
//v["DomainName"] = cluster.GetDomainName().DomainName
//v["dcos"] = dcosCli
//v["kubectl"] = kubectlCli
v["options"] = ""
return worker.Proceed(v, s)
}
// Remove uninstalls the feature using the RemoveScript script
// usage: ok, results, err := i.Remove(c, t)
// - if err != nil, the removal wasn't submitted successfully and err contains why
// - if err == nil and ok ==true, removal wa submitted and succeeded
// - if err == nil and ok == false, removal was submitted successfully but failed, results contain reasons
// of failures on what parts
func (i *dcosInstaller) Remove(c *Feature, t Target, v Variables, s Settings) (Results, error) {
worker, err := newWorker(c, t, Method.DCOS, Action.Remove, nil)
if err != nil {
return nil, err
}
err = worker.CanProceed(s)
if err != nil {
log.Println(err.Error())
return nil, err
}
// Replaces variables in normalized script
//v["DomainName"] = cluster.GetDomainName().DomainName
// v["dcos"] = dcosCli
// v["kubectl"] = kubectlCli
v["options"] = ""
return worker.Proceed(v, s)
}
// NewDcosInstaller creates a new instance of Installer using DCOS
func NewDcosInstaller() Installer {
return &dcosInstaller{}
}