vagrant-bosh 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +3 -6
- data/{lib/vagrant-bosh → bosh-provisioner}/assets/agent/agent-log +0 -0
- data/{lib/vagrant-bosh → bosh-provisioner}/assets/agent/agent-run +0 -0
- data/{lib/vagrant-bosh → bosh-provisioner}/assets/agent/agent.cert +0 -0
- data/{lib/vagrant-bosh → bosh-provisioner}/assets/agent/agent.json +0 -0
- data/{lib/vagrant-bosh → bosh-provisioner}/assets/agent/agent.key +0 -0
- data/{lib/vagrant-bosh → bosh-provisioner}/assets/agent/bosh-agent +0 -0
- data/{lib/vagrant-bosh → bosh-provisioner}/assets/agent/bosh-agent-rc +0 -0
- data/{lib/vagrant-bosh → bosh-provisioner}/assets/agent/bosh-blobstore-dav +0 -0
- data/bosh-provisioner/assets/bosh-provisioner +0 -0
- data/{lib/vagrant-bosh → bosh-provisioner}/assets/monit/monit +0 -0
- data/{lib/vagrant-bosh → bosh-provisioner}/assets/monit/monit-log +0 -0
- data/{lib/vagrant-bosh → bosh-provisioner}/assets/monit/monit-run +0 -0
- data/{lib/vagrant-bosh → bosh-provisioner}/assets/monit/monitrc +0 -0
- data/dev/Vagrantfile +1 -1
- data/dev/example-bosh-manifest.yml +12 -12
- data/lib/vagrant-bosh/bootstrapper.rb +6 -2
- data/lib/vagrant-bosh/config.rb +1 -1
- data/lib/vagrant-bosh/provisioner.rb +1 -1
- data/lib/vagrant-bosh/version.rb +1 -1
- data/vagrant-bosh.gemspec +3 -1
- metadata +20 -139
- data/go/.gitignore +0 -11
- data/go/bin/build +0 -10
- data/go/bin/build-linux-amd64 +0 -9
- data/go/bin/env +0 -13
- data/go/bin/go +0 -5
- data/go/bin/golint +0 -19
- data/go/bin/test +0 -37
- data/go/src/boshprovisioner/agent/client/client_interface.go +0 -73
- data/go/src/boshprovisioner/agent/client/fakes/fake_client.go +0 -81
- data/go/src/boshprovisioner/agent/client/http_client.go +0 -299
- data/go/src/boshprovisioner/agent/client/http_client_envelope.go +0 -107
- data/go/src/boshprovisioner/deployment/deployment.go +0 -221
- data/go/src/boshprovisioner/deployment/instance.go +0 -54
- data/go/src/boshprovisioner/deployment/manifest/deployment.go +0 -84
- data/go/src/boshprovisioner/deployment/manifest/ips.go +0 -23
- data/go/src/boshprovisioner/deployment/manifest/manifest.go +0 -143
- data/go/src/boshprovisioner/deployment/manifest/manifest_suite_test.go +0 -13
- data/go/src/boshprovisioner/deployment/manifest/manifest_test.go +0 -86
- data/go/src/boshprovisioner/deployment/manifest/syntax_validator.go +0 -186
- data/go/src/boshprovisioner/deployment/manifest/watch_time.go +0 -43
- data/go/src/boshprovisioner/deployment/manifest_reader.go +0 -46
- data/go/src/boshprovisioner/deployment/reader_factory.go +0 -25
- data/go/src/boshprovisioner/deployment/semantic_validator.go +0 -111
- data/go/src/boshprovisioner/downloader/blobstore_downloader.go +0 -55
- data/go/src/boshprovisioner/downloader/default_mux_downloader.go +0 -22
- data/go/src/boshprovisioner/downloader/downloader_interface.go +0 -6
- data/go/src/boshprovisioner/downloader/http_downloader.go +0 -53
- data/go/src/boshprovisioner/downloader/local_fs_downloader.go +0 -48
- data/go/src/boshprovisioner/downloader/mux_downloader.go +0 -69
- data/go/src/boshprovisioner/eventlog/log.go +0 -72
- data/go/src/boshprovisioner/eventlog/stage.go +0 -39
- data/go/src/boshprovisioner/eventlog/task.go +0 -58
- data/go/src/boshprovisioner/index/file_index.go +0 -289
- data/go/src/boshprovisioner/index/file_index_test.go +0 -296
- data/go/src/boshprovisioner/index/index_interface.go +0 -18
- data/go/src/boshprovisioner/index/index_suite_test.go +0 -13
- data/go/src/boshprovisioner/instance/instance.go +0 -43
- data/go/src/boshprovisioner/instance/instance_provisioner.go +0 -48
- data/go/src/boshprovisioner/instance/templatescompiler/concrete_templates_compiler.go +0 -284
- data/go/src/boshprovisioner/instance/templatescompiler/erbrenderer/erb_renderer.go +0 -117
- data/go/src/boshprovisioner/instance/templatescompiler/erbrenderer/erbrenderer_suite_test.go +0 -13
- data/go/src/boshprovisioner/instance/templatescompiler/erbrenderer/render_properties.go +0 -77
- data/go/src/boshprovisioner/instance/templatescompiler/erbrenderer/render_properties_test.go +0 -193
- data/go/src/boshprovisioner/instance/templatescompiler/erbrenderer/template_evaluation_context.go +0 -85
- data/go/src/boshprovisioner/instance/templatescompiler/erbrenderer/template_evaluation_context_rb.go +0 -155
- data/go/src/boshprovisioner/instance/templatescompiler/jobsrepo/concrete_jobs_repository.go +0 -86
- data/go/src/boshprovisioner/instance/templatescompiler/jobsrepo/concrete_runtime_packages_repository.go +0 -113
- data/go/src/boshprovisioner/instance/templatescompiler/jobsrepo/concrete_template_to_job_repository.go +0 -86
- data/go/src/boshprovisioner/instance/templatescompiler/jobsrepo/jobs_repository_interface.go +0 -49
- data/go/src/boshprovisioner/instance/templatescompiler/rendered_archives_compiler.go +0 -81
- data/go/src/boshprovisioner/instance/templatescompiler/templates_compiler_interface.go +0 -20
- data/go/src/boshprovisioner/instance/templatescompiler/templatesrepo/ct_repository.go +0 -54
- data/go/src/boshprovisioner/instance/templatescompiler/templatesrepo/templates_repository_interface.go +0 -16
- data/go/src/boshprovisioner/instance/updater/applier/applier.go +0 -93
- data/go/src/boshprovisioner/instance/updater/applier/empty_state.go +0 -66
- data/go/src/boshprovisioner/instance/updater/applier/job_state.go +0 -178
- data/go/src/boshprovisioner/instance/updater/drainer.go +0 -72
- data/go/src/boshprovisioner/instance/updater/starter.go +0 -36
- data/go/src/boshprovisioner/instance/updater/stopper.go +0 -36
- data/go/src/boshprovisioner/instance/updater/updater.go +0 -97
- data/go/src/boshprovisioner/instance/updater/updater_factory.go +0 -80
- data/go/src/boshprovisioner/instance/updater/updater_suite_test.go +0 -13
- data/go/src/boshprovisioner/instance/updater/waiter.go +0 -77
- data/go/src/boshprovisioner/instance/updater/waiter_test.go +0 -147
- data/go/src/boshprovisioner/main/config.go +0 -95
- data/go/src/boshprovisioner/main/config_test.go +0 -67
- data/go/src/boshprovisioner/main/main.go +0 -185
- data/go/src/boshprovisioner/main/main_suite_test.go +0 -13
- data/go/src/boshprovisioner/main/repos_factory.go +0 -86
- data/go/src/boshprovisioner/packagescompiler/compiledpackagesrepo/compiled_packages_repository_interface.go +0 -17
- data/go/src/boshprovisioner/packagescompiler/compiledpackagesrepo/concrete_compiled_packages_repository.go +0 -61
- data/go/src/boshprovisioner/packagescompiler/concrete_packages_compiler.go +0 -179
- data/go/src/boshprovisioner/packagescompiler/concrete_packages_compiler_factory.go +0 -48
- data/go/src/boshprovisioner/packagescompiler/packages_compiler_interface.go +0 -20
- data/go/src/boshprovisioner/packagescompiler/packagesrepo/concrete_packages_repository.go +0 -65
- data/go/src/boshprovisioner/packagescompiler/packagesrepo/packages_repository_interface.go +0 -16
- data/go/src/boshprovisioner/provisioner/blobstore_config.go +0 -65
- data/go/src/boshprovisioner/provisioner/blobstore_provisioner.go +0 -38
- data/go/src/boshprovisioner/provisioner/deployment_provisioner_interface.go +0 -10
- data/go/src/boshprovisioner/provisioner/release_compiler.go +0 -95
- data/go/src/boshprovisioner/provisioner/single_configured_vm_provisioner.go +0 -124
- data/go/src/boshprovisioner/provisioner/single_non_configured_vm_provisioner.go +0 -40
- data/go/src/boshprovisioner/provisioner/single_vm_provisioner_factory.go +0 -68
- data/go/src/boshprovisioner/release/dir_reader.go +0 -146
- data/go/src/boshprovisioner/release/job/job.go +0 -86
- data/go/src/boshprovisioner/release/job/manifest/manifest.go +0 -79
- data/go/src/boshprovisioner/release/job/manifest/manifest_suite_test.go +0 -13
- data/go/src/boshprovisioner/release/job/manifest/manifest_test.go +0 -59
- data/go/src/boshprovisioner/release/job/manifest/syntax_validator.go +0 -43
- data/go/src/boshprovisioner/release/job/reader_factory.go +0 -34
- data/go/src/boshprovisioner/release/job/tar_reader.go +0 -133
- data/go/src/boshprovisioner/release/manifest/manifest.go +0 -120
- data/go/src/boshprovisioner/release/manifest/manifest_suite_test.go +0 -13
- data/go/src/boshprovisioner/release/manifest/manifest_test.go +0 -126
- data/go/src/boshprovisioner/release/manifest/syntax_validator.go +0 -134
- data/go/src/boshprovisioner/release/reader_factory.go +0 -45
- data/go/src/boshprovisioner/release/reader_interface.go +0 -6
- data/go/src/boshprovisioner/release/release.go +0 -144
- data/go/src/boshprovisioner/release/release_suite_test.go +0 -13
- data/go/src/boshprovisioner/release/release_test.go +0 -129
- data/go/src/boshprovisioner/release/tar_reader.go +0 -141
- data/go/src/boshprovisioner/tar/cmd_compressor.go +0 -68
- data/go/src/boshprovisioner/tar/cmd_extractor.go +0 -47
- data/go/src/boshprovisioner/tar/compressor_interface.go +0 -6
- data/go/src/boshprovisioner/tar/extractor_interface.go +0 -6
- data/go/src/boshprovisioner/util/possible_base64.go +0 -21
- data/go/src/boshprovisioner/util/string_keyed.go +0 -70
- data/go/src/boshprovisioner/vm/vagrant/agent_provisioner.go +0 -296
- data/go/src/boshprovisioner/vm/vagrant/asset_manager.go +0 -61
- data/go/src/boshprovisioner/vm/vagrant/configured_vm.go +0 -29
- data/go/src/boshprovisioner/vm/vagrant/deps_provisioner.go +0 -214
- data/go/src/boshprovisioner/vm/vagrant/monit_provisioner.go +0 -85
- data/go/src/boshprovisioner/vm/vagrant/non_configured_vm.go +0 -26
- data/go/src/boshprovisioner/vm/vagrant/runit_provisioner.go +0 -229
- data/go/src/boshprovisioner/vm/vagrant/simple_cmds.go +0 -54
- data/go/src/boshprovisioner/vm/vagrant/vcap_user_provisioner.go +0 -167
- data/go/src/boshprovisioner/vm/vagrant/vm_provisioner.go +0 -119
- data/go/src/boshprovisioner/vm/vagrant/vm_provisioner_factory.go +0 -101
- data/go/src/boshprovisioner/vm/vm_interface.go +0 -45
- data/lib/vagrant-bosh/assets/provisioner +0 -0
@@ -1,47 +0,0 @@
|
|
1
|
-
package tar
|
2
|
-
|
3
|
-
import (
|
4
|
-
bosherr "bosh/errors"
|
5
|
-
boshlog "bosh/logger"
|
6
|
-
boshsys "bosh/system"
|
7
|
-
)
|
8
|
-
|
9
|
-
const cmdExtractorLogTag = "CmdExtractor"
|
10
|
-
|
11
|
-
type CmdExtractor struct {
|
12
|
-
runner boshsys.CmdRunner
|
13
|
-
fs boshsys.FileSystem
|
14
|
-
logger boshlog.Logger
|
15
|
-
}
|
16
|
-
|
17
|
-
func NewCmdExtractor(
|
18
|
-
runner boshsys.CmdRunner,
|
19
|
-
fs boshsys.FileSystem,
|
20
|
-
logger boshlog.Logger,
|
21
|
-
) CmdExtractor {
|
22
|
-
return CmdExtractor{
|
23
|
-
runner: runner,
|
24
|
-
fs: fs,
|
25
|
-
logger: logger,
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
29
|
-
func (e CmdExtractor) Extract(path string) (string, error) {
|
30
|
-
extractPath, err := e.fs.TempDir("tar-CmdExtractor")
|
31
|
-
if err != nil {
|
32
|
-
return "", bosherr.WrapError(err, "Creating extract destination")
|
33
|
-
}
|
34
|
-
|
35
|
-
e.logger.Debug(cmdExtractorLogTag, "Extract tar %s to %s", path, extractPath)
|
36
|
-
|
37
|
-
_, _, _, err = e.runner.RunCommand("tar", "-C", extractPath, "-xzf", path)
|
38
|
-
if err != nil {
|
39
|
-
return "", bosherr.WrapError(err, "Running tar")
|
40
|
-
}
|
41
|
-
|
42
|
-
return extractPath, nil
|
43
|
-
}
|
44
|
-
|
45
|
-
func (e CmdExtractor) CleanUp(path string) error {
|
46
|
-
return e.fs.RemoveAll(path)
|
47
|
-
}
|
@@ -1,21 +0,0 @@
|
|
1
|
-
package util
|
2
|
-
|
3
|
-
import (
|
4
|
-
"encoding/base64"
|
5
|
-
|
6
|
-
bosherr "bosh/errors"
|
7
|
-
)
|
8
|
-
|
9
|
-
func DecodePossibleBase64Str(str string) (string, error) {
|
10
|
-
// Cheating until yaml library provides proper support for !!binary
|
11
|
-
if str[len(str)-1:] == "=" {
|
12
|
-
bytes, err := base64.StdEncoding.DecodeString(str)
|
13
|
-
if err != nil {
|
14
|
-
return "", bosherr.WrapError(err, "Decoding base64 encoded str '%s'", str)
|
15
|
-
}
|
16
|
-
|
17
|
-
return string(bytes), nil
|
18
|
-
}
|
19
|
-
|
20
|
-
return str, nil
|
21
|
-
}
|
@@ -1,70 +0,0 @@
|
|
1
|
-
package util
|
2
|
-
|
3
|
-
import (
|
4
|
-
"reflect"
|
5
|
-
|
6
|
-
bosherr "bosh/errors"
|
7
|
-
)
|
8
|
-
|
9
|
-
type stringKeyed struct{}
|
10
|
-
|
11
|
-
func NewStringKeyed() stringKeyed { return stringKeyed{} }
|
12
|
-
|
13
|
-
// convertMapToStringKeyMap converts map to string keyed map.
|
14
|
-
func (sk stringKeyed) ConvertMap(m map[interface{}]interface{}) (map[string]interface{}, error) {
|
15
|
-
result := map[string]interface{}{}
|
16
|
-
|
17
|
-
for name, val := range m {
|
18
|
-
nameStr, ok := name.(string)
|
19
|
-
if !ok {
|
20
|
-
return result, bosherr.New("Map contains non-string key %v", name)
|
21
|
-
}
|
22
|
-
|
23
|
-
convertedVal, err := sk.ConvertInterface(val)
|
24
|
-
if err != nil {
|
25
|
-
return result, err
|
26
|
-
}
|
27
|
-
|
28
|
-
result[nameStr] = convertedVal
|
29
|
-
}
|
30
|
-
|
31
|
-
return result, nil
|
32
|
-
}
|
33
|
-
|
34
|
-
func (sk stringKeyed) ConvertInterface(val interface{}) (interface{}, error) {
|
35
|
-
if val == nil {
|
36
|
-
return nil, nil
|
37
|
-
}
|
38
|
-
|
39
|
-
switch reflect.TypeOf(val).Kind() {
|
40
|
-
case reflect.Map:
|
41
|
-
valMap, ok := val.(map[interface{}]interface{})
|
42
|
-
if !ok {
|
43
|
-
return nil, bosherr.New("Converting map %v", val)
|
44
|
-
}
|
45
|
-
|
46
|
-
return sk.ConvertMap(valMap)
|
47
|
-
|
48
|
-
case reflect.Slice:
|
49
|
-
valSlice, ok := val.([]interface{})
|
50
|
-
if !ok {
|
51
|
-
return nil, bosherr.New("Converting slice %v", val)
|
52
|
-
}
|
53
|
-
|
54
|
-
slice := make([]interface{}, len(valSlice))
|
55
|
-
|
56
|
-
for i, v := range valSlice {
|
57
|
-
convertedVal, err := sk.ConvertInterface(v)
|
58
|
-
if err != nil {
|
59
|
-
return nil, err
|
60
|
-
}
|
61
|
-
|
62
|
-
slice[i] = convertedVal
|
63
|
-
}
|
64
|
-
|
65
|
-
return slice, nil
|
66
|
-
|
67
|
-
default:
|
68
|
-
return val, nil
|
69
|
-
}
|
70
|
-
}
|
@@ -1,296 +0,0 @@
|
|
1
|
-
package vagrant
|
2
|
-
|
3
|
-
import (
|
4
|
-
"encoding/json"
|
5
|
-
"fmt"
|
6
|
-
"path/filepath"
|
7
|
-
"time"
|
8
|
-
|
9
|
-
bosherr "bosh/errors"
|
10
|
-
boshlog "bosh/logger"
|
11
|
-
boshsys "bosh/system"
|
12
|
-
|
13
|
-
bpagclient "boshprovisioner/agent/client"
|
14
|
-
bpdep "boshprovisioner/deployment"
|
15
|
-
bpeventlog "boshprovisioner/eventlog"
|
16
|
-
bpvm "boshprovisioner/vm"
|
17
|
-
)
|
18
|
-
|
19
|
-
const agentProvisionerLogTag = "AgentProvisioner"
|
20
|
-
|
21
|
-
// AgentProvisioner places BOSH Agent and Monit onto machine
|
22
|
-
// installing needed dependencies beforehand.
|
23
|
-
type AgentProvisioner struct {
|
24
|
-
fs boshsys.FileSystem
|
25
|
-
cmds SimpleCmds
|
26
|
-
assetManager AssetManager
|
27
|
-
|
28
|
-
runitProvisioner RunitProvisioner
|
29
|
-
monitProvisioner MonitProvisioner
|
30
|
-
|
31
|
-
blobstoreConfig map[string]interface{}
|
32
|
-
agentProvisionerConfig bpvm.AgentProvisionerConfig
|
33
|
-
|
34
|
-
eventLog bpeventlog.Log
|
35
|
-
logger boshlog.Logger
|
36
|
-
}
|
37
|
-
|
38
|
-
func NewAgentProvisioner(
|
39
|
-
fs boshsys.FileSystem,
|
40
|
-
cmds SimpleCmds,
|
41
|
-
assetManager AssetManager,
|
42
|
-
runitProvisioner RunitProvisioner,
|
43
|
-
monitProvisioner MonitProvisioner,
|
44
|
-
blobstoreConfig map[string]interface{},
|
45
|
-
agentProvisionerConfig bpvm.AgentProvisionerConfig,
|
46
|
-
eventLog bpeventlog.Log,
|
47
|
-
logger boshlog.Logger,
|
48
|
-
) AgentProvisioner {
|
49
|
-
return AgentProvisioner{
|
50
|
-
fs: fs,
|
51
|
-
cmds: cmds,
|
52
|
-
assetManager: assetManager,
|
53
|
-
|
54
|
-
runitProvisioner: runitProvisioner,
|
55
|
-
monitProvisioner: monitProvisioner,
|
56
|
-
|
57
|
-
blobstoreConfig: blobstoreConfig,
|
58
|
-
agentProvisionerConfig: agentProvisionerConfig,
|
59
|
-
|
60
|
-
eventLog: eventLog,
|
61
|
-
logger: logger,
|
62
|
-
}
|
63
|
-
}
|
64
|
-
|
65
|
-
func (p AgentProvisioner) Provision() error {
|
66
|
-
stage := p.eventLog.BeginStage("Updating BOSH agent", 4)
|
67
|
-
|
68
|
-
task := stage.BeginTask("Placing binaries")
|
69
|
-
|
70
|
-
err := task.End(p.placeBinaries())
|
71
|
-
if err != nil {
|
72
|
-
return bosherr.WrapError(err, "Placing agent binaries")
|
73
|
-
}
|
74
|
-
|
75
|
-
task = stage.BeginTask("Placing configuration files")
|
76
|
-
|
77
|
-
err = task.End(p.placeConfFiles())
|
78
|
-
if err != nil {
|
79
|
-
return bosherr.WrapError(err, "Configuring settings")
|
80
|
-
}
|
81
|
-
|
82
|
-
task = stage.BeginTask("Registering monit service")
|
83
|
-
|
84
|
-
err = task.End(p.monitProvisioner.Provision())
|
85
|
-
if err != nil {
|
86
|
-
return bosherr.WrapError(err, "Provisioning monit")
|
87
|
-
}
|
88
|
-
|
89
|
-
task = stage.BeginTask("Registering agent service")
|
90
|
-
|
91
|
-
err = task.End(p.runitProvisioner.Provision("agent", 10*time.Second))
|
92
|
-
if err != nil {
|
93
|
-
return bosherr.WrapError(err, "Provisioning agent with runit")
|
94
|
-
}
|
95
|
-
|
96
|
-
return nil
|
97
|
-
}
|
98
|
-
|
99
|
-
func (p AgentProvisioner) Configure(instance bpdep.Instance) (bpagclient.Client, error) {
|
100
|
-
stage := p.eventLog.BeginStage("Configuring BOSH agent", 1)
|
101
|
-
|
102
|
-
err := p.placeInfSettings(instance)
|
103
|
-
if err != nil {
|
104
|
-
return nil, bosherr.WrapError(err, "Placing infrastructure settings")
|
105
|
-
}
|
106
|
-
|
107
|
-
task := stage.BeginTask("Configuring infrastructure settings")
|
108
|
-
|
109
|
-
agentClient, err := p.buildAgentClient()
|
110
|
-
if task.End(err) != nil {
|
111
|
-
return nil, bosherr.WrapError(err, "Building agent client")
|
112
|
-
}
|
113
|
-
|
114
|
-
return agentClient, nil
|
115
|
-
}
|
116
|
-
|
117
|
-
// placeBinaries places agent/monit binaries into /var/vcap/bosh/bin
|
118
|
-
func (p AgentProvisioner) placeBinaries() error {
|
119
|
-
binPath := "/var/vcap/bosh/bin"
|
120
|
-
|
121
|
-
// Implicitly creates /var/vcap/bosh
|
122
|
-
err := p.cmds.MkdirP(binPath)
|
123
|
-
if err != nil {
|
124
|
-
return err
|
125
|
-
}
|
126
|
-
|
127
|
-
binNames := map[string]string{
|
128
|
-
"agent/bosh-agent": "bosh-agent",
|
129
|
-
"agent/bosh-agent-rc": "bosh-agent-rc",
|
130
|
-
"agent/bosh-blobstore-dav": "bosh-blobstore-dav",
|
131
|
-
"monit/monit": "monit",
|
132
|
-
}
|
133
|
-
|
134
|
-
for assetName, binName := range binNames {
|
135
|
-
err = p.placeBinary(assetName, filepath.Join(binPath, binName))
|
136
|
-
if err != nil {
|
137
|
-
return err
|
138
|
-
}
|
139
|
-
}
|
140
|
-
|
141
|
-
return nil
|
142
|
-
}
|
143
|
-
|
144
|
-
func (p AgentProvisioner) placeBinary(name, path string) error {
|
145
|
-
err := p.assetManager.Place(name, path)
|
146
|
-
if err != nil {
|
147
|
-
return bosherr.WrapError(err, "Placing %s binary", name)
|
148
|
-
}
|
149
|
-
|
150
|
-
err = p.cmds.ChmodX(path)
|
151
|
-
if err != nil {
|
152
|
-
return err
|
153
|
-
}
|
154
|
-
|
155
|
-
return nil
|
156
|
-
}
|
157
|
-
|
158
|
-
func (p AgentProvisioner) placeConfFiles() error {
|
159
|
-
err := p.setUpDataDir()
|
160
|
-
if err != nil {
|
161
|
-
return bosherr.WrapError(err, "Setting up data dir")
|
162
|
-
}
|
163
|
-
|
164
|
-
fileNames := map[string]string{
|
165
|
-
"agent/agent.cert": "agent.cert", // Needed by agent HTTP handler
|
166
|
-
"agent/agent.key": "agent.key",
|
167
|
-
}
|
168
|
-
|
169
|
-
for assetName, fileName := range fileNames {
|
170
|
-
err := p.assetManager.Place(assetName, filepath.Join("/var/vcap/bosh/", fileName))
|
171
|
-
if err != nil {
|
172
|
-
return bosherr.WrapError(err, "Placing %s", fileName)
|
173
|
-
}
|
174
|
-
}
|
175
|
-
|
176
|
-
err = p.placeAgentConf()
|
177
|
-
if err != nil {
|
178
|
-
return bosherr.WrapError(err, "Placing agent configuration")
|
179
|
-
}
|
180
|
-
|
181
|
-
return nil
|
182
|
-
}
|
183
|
-
|
184
|
-
func (p AgentProvisioner) placeAgentConf() error {
|
185
|
-
// etc/infrastructure and etc/plaform is loaded by BOSH Agent runit script
|
186
|
-
err := p.fs.WriteFileString("/var/vcap/bosh/etc/infrastructure", p.agentProvisionerConfig.Infrastructure)
|
187
|
-
if err != nil {
|
188
|
-
return bosherr.WrapError(err, "Writing agent infrastructure")
|
189
|
-
}
|
190
|
-
|
191
|
-
err = p.fs.WriteFileString("/var/vcap/bosh/etc/platform", p.agentProvisionerConfig.Platform)
|
192
|
-
if err != nil {
|
193
|
-
return bosherr.WrapError(err, "Writing agent platform")
|
194
|
-
}
|
195
|
-
|
196
|
-
// Go Agent will can unmarshal 'null' into an empty config
|
197
|
-
bytes, err := json.Marshal(p.agentProvisionerConfig.Configuration)
|
198
|
-
if err != nil {
|
199
|
-
return bosherr.WrapError(err, "Marshalling agent configuration")
|
200
|
-
}
|
201
|
-
|
202
|
-
err = p.fs.WriteFile("/var/vcap/bosh/agent.json", bytes)
|
203
|
-
if err != nil {
|
204
|
-
return bosherr.WrapError(err, "Writing agent configuration")
|
205
|
-
}
|
206
|
-
|
207
|
-
return nil
|
208
|
-
}
|
209
|
-
|
210
|
-
func (p AgentProvisioner) setUpDataDir() error {
|
211
|
-
err := p.cmds.Bash("ln -nsf data/sys /var/vcap/sys")
|
212
|
-
if err != nil {
|
213
|
-
return err
|
214
|
-
}
|
215
|
-
|
216
|
-
// todo hacky data dir
|
217
|
-
err = p.cmds.MkdirP("/var/vcap/data")
|
218
|
-
if err != nil {
|
219
|
-
return err
|
220
|
-
}
|
221
|
-
|
222
|
-
err = p.cmds.Chmod("777", "/var/vcap/data")
|
223
|
-
if err != nil {
|
224
|
-
return err
|
225
|
-
}
|
226
|
-
|
227
|
-
return nil
|
228
|
-
}
|
229
|
-
|
230
|
-
func (p AgentProvisioner) placeInfSettings(instance bpdep.Instance) error {
|
231
|
-
type h map[string]interface{}
|
232
|
-
|
233
|
-
netSettings := map[string]h{}
|
234
|
-
|
235
|
-
for _, netAssoc := range instance.NetworkAssociations {
|
236
|
-
netConfig := instance.NetworkConfigurationForNetworkAssociation(netAssoc)
|
237
|
-
|
238
|
-
netSettings[netAssoc.Network.Name] = h{
|
239
|
-
"type": netAssoc.Network.Type,
|
240
|
-
"ip": netConfig.IP,
|
241
|
-
"netmask": netConfig.Netmask,
|
242
|
-
"gateway": netConfig.Gateway,
|
243
|
-
|
244
|
-
"dns_record_name": instance.DNDRecordName(netAssoc),
|
245
|
-
"cloud_properties": h{},
|
246
|
-
}
|
247
|
-
}
|
248
|
-
|
249
|
-
settings := h{
|
250
|
-
"agent_id": fmt.Sprintf("agent-id-%s-%d", instance.JobName, instance.Index),
|
251
|
-
|
252
|
-
"vm": h{
|
253
|
-
"name": fmt.Sprintf("vm-name-%s-%d", instance.JobName, instance.Index),
|
254
|
-
"id": fmt.Sprintf("vm-id-%s-%d", instance.JobName, instance.Index),
|
255
|
-
},
|
256
|
-
|
257
|
-
"networks": netSettings,
|
258
|
-
"disks": h{"persistent": h{}},
|
259
|
-
|
260
|
-
"blobstore": p.blobstoreConfig,
|
261
|
-
"mbus": p.agentProvisionerConfig.Mbus, // todo port can conflict with jobs
|
262
|
-
|
263
|
-
"env": h{},
|
264
|
-
"ntp": []string{},
|
265
|
-
}
|
266
|
-
|
267
|
-
settingsJSON, err := json.Marshal(settings)
|
268
|
-
if err != nil {
|
269
|
-
return bosherr.WrapError(err, "Marshalling agent infrastructure settings")
|
270
|
-
}
|
271
|
-
|
272
|
-
err = p.fs.WriteFile("/var/vcap/bosh/warden-cpi-agent-env.json", settingsJSON)
|
273
|
-
if err != nil {
|
274
|
-
return bosherr.WrapError(err, "Writing agent infrastructure settings")
|
275
|
-
}
|
276
|
-
|
277
|
-
return nil
|
278
|
-
}
|
279
|
-
|
280
|
-
func (p AgentProvisioner) buildAgentClient() (bpagclient.Client, error) {
|
281
|
-
agentClient, err := bpagclient.NewInsecureHTTPClientWithURI(p.agentProvisionerConfig.Mbus, p.logger)
|
282
|
-
if err != nil {
|
283
|
-
return nil, bosherr.WrapError(err, "Building agent client")
|
284
|
-
}
|
285
|
-
|
286
|
-
for i := 0; i < 10; i++ {
|
287
|
-
_, err = agentClient.Ping()
|
288
|
-
if err == nil {
|
289
|
-
return agentClient, nil
|
290
|
-
}
|
291
|
-
|
292
|
-
time.Sleep(1 * time.Second)
|
293
|
-
}
|
294
|
-
|
295
|
-
return nil, err
|
296
|
-
}
|