bosh-director 1.2311.0 → 1.2334.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/bosh/director/deployment_plan/idle_vm.rb +5 -0
- data/lib/bosh/director/deployment_plan/resource_pool.rb +7 -0
- data/lib/bosh/director/errand/job_manager.rb +13 -0
- data/lib/bosh/director/event_log.rb +1 -1
- data/lib/bosh/director/resource_pool_updater.rb +1 -2
- data/lib/bosh/director/version.rb +1 -1
- data/lib/cloud/dummy.rb +41 -14
- metadata +20 -20
@@ -121,6 +121,13 @@ module Bosh::Director
|
|
121
121
|
allocated_vm
|
122
122
|
end
|
123
123
|
|
124
|
+
def deallocate_vm(idle_vm_cid)
|
125
|
+
deallocated_vm = @allocated_vms.find { |idle_vm| idle_vm.vm.cid == idle_vm_cid }
|
126
|
+
@allocated_vms.delete(deallocated_vm)
|
127
|
+
@idle_vms << deallocated_vm
|
128
|
+
deallocated_vm
|
129
|
+
end
|
130
|
+
|
124
131
|
# "Active" VM is a VM that is currently running a job
|
125
132
|
# @return [void]
|
126
133
|
def mark_active_vm
|
@@ -36,6 +36,19 @@ module Bosh::Director
|
|
36
36
|
instance_deleter = InstanceDeleter.new(@deployment)
|
37
37
|
instance_deleter.delete_instances(
|
38
38
|
@job.instances.map(&:model), event_log_stage)
|
39
|
+
|
40
|
+
deallocate_vms
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def deallocate_vms
|
46
|
+
instance_cids = @job.instances.map { |i| i.model.vm.cid }
|
47
|
+
|
48
|
+
instance_cids.each do |cid|
|
49
|
+
idle_vm = @job.resource_pool.deallocate_vm(cid)
|
50
|
+
idle_vm.clean_vm
|
51
|
+
end
|
39
52
|
end
|
40
53
|
end
|
41
54
|
end
|
data/lib/cloud/dummy.rb
CHANGED
@@ -8,12 +8,19 @@ module Bosh
|
|
8
8
|
class NotImplemented < StandardError; end
|
9
9
|
|
10
10
|
def initialize(options)
|
11
|
-
if options['dir'].nil?
|
12
|
-
raise ArgumentError, 'please provide base directory for dummy cloud'
|
13
|
-
end
|
14
|
-
|
15
11
|
@options = options
|
12
|
+
|
16
13
|
@base_dir = options['dir']
|
14
|
+
if @base_dir.nil?
|
15
|
+
raise ArgumentError, 'Must specify dir'
|
16
|
+
end
|
17
|
+
|
18
|
+
@agent_type = options['agent']['type']
|
19
|
+
unless %w(ruby go).include?(@agent_type)
|
20
|
+
raise ArgumentError, 'Unknown agent type provided'
|
21
|
+
end
|
22
|
+
|
23
|
+
@running_vms_dir = File.join(@base_dir, 'running_vms')
|
17
24
|
|
18
25
|
FileUtils.mkdir_p(@base_dir)
|
19
26
|
rescue Errno::EACCES
|
@@ -45,12 +52,12 @@ module Bosh
|
|
45
52
|
mbus: @options['nats'],
|
46
53
|
})
|
47
54
|
|
48
|
-
agent_cmd = agent_cmd(agent_id, root_dir
|
49
|
-
agent_log = "#{@
|
55
|
+
agent_cmd = agent_cmd(agent_id, root_dir)
|
56
|
+
agent_log = "#{@base_dir}/agent.#{agent_id}.log"
|
50
57
|
agent_pid = Process.spawn(*agent_cmd, chdir: agent_base_dir(agent_id), out: agent_log, err: agent_log)
|
51
58
|
Process.detach(agent_pid)
|
52
59
|
|
53
|
-
FileUtils.mkdir_p(
|
60
|
+
FileUtils.mkdir_p(@running_vms_dir)
|
54
61
|
File.write(vm_file(agent_pid), agent_id)
|
55
62
|
|
56
63
|
agent_pid.to_s
|
@@ -126,6 +133,23 @@ module Bosh
|
|
126
133
|
raise NotImplemented, 'Dummy CPI does not implement validate_deployment'
|
127
134
|
end
|
128
135
|
|
136
|
+
# Additional Dummy test helpers
|
137
|
+
|
138
|
+
def vm_cids
|
139
|
+
Dir.glob(File.join(@running_vms_dir, '*')).map { |vm| File.basename(vm) }
|
140
|
+
end
|
141
|
+
|
142
|
+
def kill_agents
|
143
|
+
vm_cids.each do |agent_pid|
|
144
|
+
begin
|
145
|
+
Process.kill('INT', agent_pid.to_i)
|
146
|
+
# rubocop:disable HandleExceptions
|
147
|
+
rescue Errno::ESRCH
|
148
|
+
# rubocop:enable HandleExceptions
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
129
153
|
private
|
130
154
|
|
131
155
|
def agent_id_for_vm_id(vm_id)
|
@@ -133,11 +157,14 @@ module Bosh
|
|
133
157
|
end
|
134
158
|
|
135
159
|
def agent_settings_file(agent_id)
|
136
|
-
|
160
|
+
# Even though dummy CPI has complete access to agent execution file system
|
161
|
+
# it should never write directly to settings.json because
|
162
|
+
# the agent is responsible for retrieving the settings from the CPI.
|
163
|
+
File.join(agent_base_dir(agent_id), 'bosh', 'dummy-cpi-agent-env.json')
|
137
164
|
end
|
138
165
|
|
139
166
|
def agent_base_dir(agent_id)
|
140
|
-
"#{@
|
167
|
+
"#{@base_dir}/agent-base-dir-#{agent_id}"
|
141
168
|
end
|
142
169
|
|
143
170
|
def write_agent_settings(agent_id, settings)
|
@@ -145,12 +172,12 @@ module Bosh
|
|
145
172
|
File.write(agent_settings_file(agent_id), JSON.generate(settings))
|
146
173
|
end
|
147
174
|
|
148
|
-
def agent_cmd(agent_id, root_dir
|
175
|
+
def agent_cmd(agent_id, root_dir)
|
149
176
|
go_agent_exe = File.absolute_path('bosh/go_agent/out/bosh-agent')
|
150
177
|
{
|
151
|
-
ruby
|
152
|
-
go
|
153
|
-
}[agent_type]
|
178
|
+
'ruby' => %W[bosh_agent -b #{agent_base_dir(agent_id)} -I dummy -r #{root_dir} --no-alerts],
|
179
|
+
'go' => %W[#{go_agent_exe} -b #{agent_base_dir(agent_id)} -I dummy -P dummy -M dummy],
|
180
|
+
}[@agent_type.to_s]
|
154
181
|
end
|
155
182
|
|
156
183
|
def read_agent_settings(agent_id)
|
@@ -162,7 +189,7 @@ module Bosh
|
|
162
189
|
end
|
163
190
|
|
164
191
|
def vm_file(vm_id)
|
165
|
-
File.join(@
|
192
|
+
File.join(@running_vms_dir, vm_id.to_s)
|
166
193
|
end
|
167
194
|
|
168
195
|
def disk_file(disk_id)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bosh-director
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2334.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-04-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bcrypt-ruby
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 1.
|
37
|
+
version: 1.2334.0
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 1.
|
45
|
+
version: 1.2334.0
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: bosh-core
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 1.
|
53
|
+
version: 1.2334.0
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: 1.2334.0
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: bosh-director-core
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
requirements:
|
67
67
|
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 1.
|
69
|
+
version: 1.2334.0
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -74,7 +74,7 @@ dependencies:
|
|
74
74
|
requirements:
|
75
75
|
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: 1.
|
77
|
+
version: 1.2334.0
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: bosh_common
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,7 +82,7 @@ dependencies:
|
|
82
82
|
requirements:
|
83
83
|
- - ~>
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: 1.
|
85
|
+
version: 1.2334.0
|
86
86
|
type: :runtime
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -90,7 +90,7 @@ dependencies:
|
|
90
90
|
requirements:
|
91
91
|
- - ~>
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: 1.
|
93
|
+
version: 1.2334.0
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: bosh_cpi
|
96
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
requirements:
|
99
99
|
- - ~>
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: 1.
|
101
|
+
version: 1.2334.0
|
102
102
|
type: :runtime
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -106,7 +106,7 @@ dependencies:
|
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: 1.
|
109
|
+
version: 1.2334.0
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
111
|
name: bosh_openstack_cpi
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,7 +114,7 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - ~>
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 1.
|
117
|
+
version: 1.2334.0
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -122,7 +122,7 @@ dependencies:
|
|
122
122
|
requirements:
|
123
123
|
- - ~>
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: 1.
|
125
|
+
version: 1.2334.0
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: bosh_aws_cpi
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,7 +130,7 @@ dependencies:
|
|
130
130
|
requirements:
|
131
131
|
- - ~>
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
version: 1.
|
133
|
+
version: 1.2334.0
|
134
134
|
type: :runtime
|
135
135
|
prerelease: false
|
136
136
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -138,7 +138,7 @@ dependencies:
|
|
138
138
|
requirements:
|
139
139
|
- - ~>
|
140
140
|
- !ruby/object:Gem::Version
|
141
|
-
version: 1.
|
141
|
+
version: 1.2334.0
|
142
142
|
- !ruby/object:Gem::Dependency
|
143
143
|
name: bosh_vsphere_cpi
|
144
144
|
requirement: !ruby/object:Gem::Requirement
|
@@ -146,7 +146,7 @@ dependencies:
|
|
146
146
|
requirements:
|
147
147
|
- - ~>
|
148
148
|
- !ruby/object:Gem::Version
|
149
|
-
version: 1.
|
149
|
+
version: 1.2334.0
|
150
150
|
type: :runtime
|
151
151
|
prerelease: false
|
152
152
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -154,7 +154,7 @@ dependencies:
|
|
154
154
|
requirements:
|
155
155
|
- - ~>
|
156
156
|
- !ruby/object:Gem::Version
|
157
|
-
version: 1.
|
157
|
+
version: 1.2334.0
|
158
158
|
- !ruby/object:Gem::Dependency
|
159
159
|
name: bosh_vcloud_cpi
|
160
160
|
requirement: !ruby/object:Gem::Requirement
|
@@ -493,7 +493,7 @@ dependencies:
|
|
493
493
|
version: '1.0'
|
494
494
|
description: ! 'BOSH Director
|
495
495
|
|
496
|
-
|
496
|
+
839055'
|
497
497
|
email: support@cloudfoundry.com
|
498
498
|
executables:
|
499
499
|
- bosh-director
|
@@ -748,7 +748,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
748
748
|
version: '0'
|
749
749
|
segments:
|
750
750
|
- 0
|
751
|
-
hash: -
|
751
|
+
hash: -1978715679933352968
|
752
752
|
requirements: []
|
753
753
|
rubyforge_project:
|
754
754
|
rubygems_version: 1.8.23
|