bosh-director 1.2682.1.0 → 1.2685.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/bin/bosh-director +55 -2
  3. data/lib/bosh/director.rb +15 -2
  4. data/lib/bosh/director/api/controllers/backups_controller.rb +2 -2
  5. data/lib/bosh/director/api/controllers/base_controller.rb +1 -1
  6. data/lib/bosh/director/api/controllers/compiled_packages_controller.rb +2 -2
  7. data/lib/bosh/director/api/controllers/deployments_controller.rb +40 -26
  8. data/lib/bosh/director/api/controllers/info_controller.rb +1 -1
  9. data/lib/bosh/director/api/controllers/locks_controller.rb +1 -1
  10. data/lib/bosh/director/api/controllers/packages_controller.rb +1 -1
  11. data/lib/bosh/director/api/controllers/releases_controller.rb +5 -5
  12. data/lib/bosh/director/api/controllers/resources_controller.rb +1 -1
  13. data/lib/bosh/director/api/controllers/resurrection_controller.rb +1 -1
  14. data/lib/bosh/director/api/controllers/stemcells_controller.rb +4 -4
  15. data/lib/bosh/director/api/controllers/task_controller.rb +20 -0
  16. data/lib/bosh/director/api/controllers/tasks_controller.rb +3 -18
  17. data/lib/bosh/director/api/controllers/users_controller.rb +3 -3
  18. data/lib/bosh/director/api/deployment_lookup.rb +1 -1
  19. data/lib/bosh/director/api/resource_manager.rb +1 -1
  20. data/lib/bosh/director/instance_updater/vm_updater.rb +2 -1
  21. data/lib/bosh/director/jobs/cloud_check/scan.rb +1 -1
  22. data/lib/bosh/director/jobs/cloud_check/scan_and_fix.rb +1 -1
  23. data/lib/bosh/director/problem_handlers/missing_disk.rb +74 -0
  24. data/lib/bosh/director/problem_scanner/disk_scan_stage.rb +80 -0
  25. data/lib/bosh/director/problem_scanner/problem_register.rb +55 -0
  26. data/lib/bosh/director/problem_scanner/scanner.rb +86 -0
  27. data/lib/bosh/director/problem_scanner/vm_scan_stage.rb +134 -0
  28. data/lib/bosh/director/version.rb +1 -1
  29. data/lib/cloud/dummy.rb +9 -0
  30. metadata +29 -26
  31. data/lib/bosh/director/api/controller.rb +0 -33
  32. data/lib/bosh/director/api/controllers/errands_controller.rb +0 -26
  33. data/lib/bosh/director/problem_scanner.rb +0 -268
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e101a621d65e85af0e74b19c104bb96588ea22e7
4
- data.tar.gz: 6ed3e1fabcdb47774c4d4ece30d75b70b359a1c9
3
+ metadata.gz: 98b2d92521f2e7c1f4b858e42e743b4c6f870725
4
+ data.tar.gz: fc2d3f58d4ba28091df63f69c73d274f367b3052
5
5
  SHA512:
6
- metadata.gz: c5fbe0b46fe75031887dc83a30591d2b3add1340fbfee930261e8901461ca0512995f8608dea61324ff253ad11ae5835c55eeda04f9b9afea368c2ed6c0fd166
7
- data.tar.gz: 67d12e46cc08bb6662551c0a1cf24116cabb63e7a527265e7c7561d1ec0fb59a10b6221d0562b5be60337a76d14ea072727701453608345f8e1450bccd16e673
6
+ metadata.gz: 520bc0f8c7bb6079be71da973cfefdad7af0d5331feee3fcabcbe3d5b495b5a39baaded8c47d98cdf6cdeb631729ac6fc511d53466ce87730c0e2a25f760da6c
7
+ data.tar.gz: a76f8db3e2e866081be3e5203dc945685de2feec2cc7c8abd82dc5f4489684c87eeedddeaf4d5fedc7f08eb3b7f67f92e04f2a8a376396cd55138f6854fece8b
data/bin/bosh-director CHANGED
@@ -20,8 +20,61 @@ Bosh::Director::App.new(config)
20
20
 
21
21
  thin_server = Thin::Server.new('127.0.0.1', config.hash['port'], signals: false) do
22
22
  use Rack::CommonLogger
23
- map '/' do
24
- run Bosh::Director::Api::Controller.new
23
+
24
+ map '/info' do
25
+ run Bosh::Director::Api::Controllers::InfoController.new
26
+ end
27
+
28
+ map '/tasks' do
29
+ run Bosh::Director::Api::Controllers::TasksController.new
30
+ end
31
+
32
+ map '/backups' do
33
+ run Bosh::Director::Api::Controllers::BackupsController.new
34
+ end
35
+
36
+ map '/deployments' do
37
+ run Bosh::Director::Api::Controllers::DeploymentsController.new
38
+ end
39
+
40
+ map '/packages' do
41
+ run Bosh::Director::Api::Controllers::PackagesController.new
42
+ end
43
+
44
+ map '/releases' do
45
+ run Bosh::Director::Api::Controllers::ReleasesController.new
46
+ end
47
+
48
+ map '/resources' do
49
+ run Bosh::Director::Api::Controllers::ResourcesController.new
50
+ end
51
+
52
+ map '/resurrection' do
53
+ run Bosh::Director::Api::Controllers::ResurrectionController.new
54
+ end
55
+
56
+ map '/stemcells' do
57
+ run Bosh::Director::Api::Controllers::StemcellsController.new
58
+ end
59
+
60
+ map '/tasks' do
61
+ run Bosh::Director::Api::Controllers::TasksController.new
62
+ end
63
+
64
+ map '/task' do
65
+ run Bosh::Director::Api::Controllers::TaskController.new
66
+ end
67
+
68
+ map '/users' do
69
+ run Bosh::Director::Api::Controllers::UsersController.new
70
+ end
71
+
72
+ map '/compiled_package_groups' do
73
+ run Bosh::Director::Api::Controllers::CompiledPackagesController.new
74
+ end
75
+
76
+ map '/locks' do
77
+ run Bosh::Director::Api::Controllers::LocksController.new
25
78
  end
26
79
  end
27
80
 
data/lib/bosh/director.rb CHANGED
@@ -84,7 +84,7 @@ require 'bosh/director/lock'
84
84
  require 'bosh/director/nats_rpc'
85
85
  require 'bosh/director/network_reservation'
86
86
  require 'bosh/director/package_compiler'
87
- require 'bosh/director/problem_scanner'
87
+ require 'bosh/director/problem_scanner/scanner'
88
88
  require 'bosh/director/problem_resolver'
89
89
  require 'bosh/director/resource_pool_updater'
90
90
  require 'bosh/director/sequel'
@@ -97,6 +97,7 @@ require 'bosh/director/cloudcheck_helper'
97
97
  require 'bosh/director/problem_handlers/base'
98
98
  require 'bosh/director/problem_handlers/invalid_problem'
99
99
  require 'bosh/director/problem_handlers/inactive_disk'
100
+ require 'bosh/director/problem_handlers/missing_disk'
100
101
  require 'bosh/director/problem_handlers/out_of_sync_vm'
101
102
  require 'bosh/director/problem_handlers/unresponsive_agent'
102
103
  require 'bosh/director/problem_handlers/unbound_instance_vm'
@@ -138,4 +139,16 @@ end
138
139
 
139
140
  require 'bosh/director/thread_pool'
140
141
  require 'bosh/director/api/controller_helpers'
141
- require 'bosh/director/api/controller'
142
+ require 'bosh/director/api/controllers/backups_controller'
143
+ require 'bosh/director/api/controllers/deployments_controller'
144
+ require 'bosh/director/api/controllers/packages_controller'
145
+ require 'bosh/director/api/controllers/info_controller'
146
+ require 'bosh/director/api/controllers/releases_controller'
147
+ require 'bosh/director/api/controllers/resources_controller'
148
+ require 'bosh/director/api/controllers/resurrection_controller'
149
+ require 'bosh/director/api/controllers/stemcells_controller'
150
+ require 'bosh/director/api/controllers/tasks_controller'
151
+ require 'bosh/director/api/controllers/task_controller'
152
+ require 'bosh/director/api/controllers/users_controller'
153
+ require 'bosh/director/api/controllers/compiled_packages_controller'
154
+ require 'bosh/director/api/controllers/locks_controller'
@@ -3,11 +3,11 @@ require 'bosh/director/api/controllers/base_controller'
3
3
  module Bosh::Director
4
4
  module Api::Controllers
5
5
  class BackupsController < BaseController
6
- post '/backups' do
6
+ post '/' do
7
7
  start_task { @backup_manager.create_backup(@user) }
8
8
  end
9
9
 
10
- get '/backups' do
10
+ get '/' do
11
11
  send_file(@backup_manager.destination_path)
12
12
  end
13
13
  end
@@ -57,7 +57,7 @@ module Bosh::Director
57
57
  request.env.has_key?(key)
58
58
  end
59
59
 
60
- protected! if auth_provided || !PUBLIC_URLS.include?(request.path_info)
60
+ protected! if auth_provided || !PUBLIC_URLS.include?(request.path)
61
61
  end
62
62
 
63
63
  after { headers('Date' => Time.now.rfc822) } # As thin doesn't inject date
@@ -16,7 +16,7 @@ module Bosh::Director
16
16
  @compiled_package_group_manager = Api::CompiledPackageGroupManager.new
17
17
  end
18
18
 
19
- post '/compiled_package_groups/export', consumes: :json do
19
+ post '/export', consumes: :json do
20
20
  stemcell = find_stemcell_by_name_and_version
21
21
  release_version = find_release_version_by_name_and_version
22
22
 
@@ -36,7 +36,7 @@ module Bosh::Director
36
36
  send_file(output_path, type: :tgz)
37
37
  end
38
38
 
39
- post '/compiled_package_groups/import', consumes: :multipart do
39
+ post '/import', consumes: :multipart do
40
40
  task = @compiled_package_group_manager.create_from_file_path(@user, params[:nginx_upload_path])
41
41
  redirect "/tasks/#{task.id}"
42
42
  end
@@ -3,7 +3,7 @@ require 'bosh/director/api/controllers/base_controller'
3
3
  module Bosh::Director
4
4
  module Api::Controllers
5
5
  class DeploymentsController < BaseController
6
- get '/deployments/:deployment/jobs/:job/:index' do
6
+ get '/:deployment/jobs/:job/:index' do
7
7
  instance = @instance_manager.find_by_name(params[:deployment], params[:job], params[:index])
8
8
 
9
9
  response = {
@@ -18,7 +18,7 @@ module Bosh::Director
18
18
  end
19
19
 
20
20
  # PUT /deployments/foo/jobs/dea?new_name=dea_new
21
- put '/deployments/:deployment/jobs/:job', :consumes => :yaml do
21
+ put '/:deployment/jobs/:job', :consumes => :yaml do
22
22
  if params['state']
23
23
  options = {
24
24
  'job_states' => {
@@ -48,7 +48,7 @@ module Bosh::Director
48
48
  end
49
49
 
50
50
  # PUT /deployments/foo/jobs/dea/2?state={started,stopped,detached,restart,recreate}
51
- put '/deployments/:deployment/jobs/:job/:index', :consumes => :yaml do
51
+ put '/:deployment/jobs/:job/:index', :consumes => :yaml do
52
52
  begin
53
53
  index = Integer(params[:index])
54
54
  rescue ArgumentError
@@ -72,7 +72,7 @@ module Bosh::Director
72
72
  end
73
73
 
74
74
  # GET /deployments/foo/jobs/dea/2/logs
75
- get '/deployments/:deployment/jobs/:job/:index/logs' do
75
+ get '/:deployment/jobs/:job/:index/logs' do
76
76
  deployment = params[:deployment]
77
77
  job = params[:job]
78
78
  index = params[:index]
@@ -86,17 +86,17 @@ module Bosh::Director
86
86
  redirect "/tasks/#{task.id}"
87
87
  end
88
88
 
89
- get '/deployments/:deployment/snapshots' do
89
+ get '/:deployment/snapshots' do
90
90
  deployment = @deployment_manager.find_by_name(params[:deployment])
91
91
  json_encode(@snapshot_manager.snapshots(deployment))
92
92
  end
93
93
 
94
- get '/deployments/:deployment/jobs/:job/:index/snapshots' do
94
+ get '/:deployment/jobs/:job/:index/snapshots' do
95
95
  deployment = @deployment_manager.find_by_name(params[:deployment])
96
96
  json_encode(@snapshot_manager.snapshots(deployment, params[:job], params[:index]))
97
97
  end
98
98
 
99
- post '/deployments/:deployment/snapshots' do
99
+ post '/:deployment/snapshots' do
100
100
  deployment = @deployment_manager.find_by_name(params[:deployment])
101
101
  # until we can tell the agent to flush and wait, all snapshots are considered dirty
102
102
  options = {clean: false}
@@ -105,13 +105,13 @@ module Bosh::Director
105
105
  redirect "/tasks/#{task.id}"
106
106
  end
107
107
 
108
- put '/deployments/:deployment/jobs/:job/:index/resurrection', consumes: :json do
108
+ put '/:deployment/jobs/:job/:index/resurrection', consumes: :json do
109
109
  payload = json_decode(request.body)
110
110
 
111
111
  @resurrector_manager.set_pause_for_instance(params[:deployment], params[:job], params[:index], payload['resurrection_paused'])
112
112
  end
113
113
 
114
- post '/deployments/:deployment/jobs/:job/:index/snapshots' do
114
+ post '/:deployment/jobs/:job/:index/snapshots' do
115
115
  instance = @instance_manager.find_by_name(params[:deployment], params[:job], params[:index])
116
116
  # until we can tell the agent to flush and wait, all snapshots are considered dirty
117
117
  options = {clean: false}
@@ -120,14 +120,14 @@ module Bosh::Director
120
120
  redirect "/tasks/#{task.id}"
121
121
  end
122
122
 
123
- delete '/deployments/:deployment/snapshots' do
123
+ delete '/:deployment/snapshots' do
124
124
  deployment = @deployment_manager.find_by_name(params[:deployment])
125
125
 
126
126
  task = @snapshot_manager.delete_deployment_snapshots_task(@user, deployment)
127
127
  redirect "/tasks/#{task.id}"
128
128
  end
129
129
 
130
- delete '/deployments/:deployment/snapshots/:cid' do
130
+ delete '/:deployment/snapshots/:cid' do
131
131
  deployment = @deployment_manager.find_by_name(params[:deployment])
132
132
  snapshot = @snapshot_manager.find_by_cid(deployment, params[:cid])
133
133
 
@@ -135,7 +135,7 @@ module Bosh::Director
135
135
  redirect "/tasks/#{task.id}"
136
136
  end
137
137
 
138
- get '/deployments' do
138
+ get '/' do
139
139
  deployments = Models::Deployment.order_by(:name.asc).map { |deployment|
140
140
  name = deployment.name
141
141
 
@@ -153,12 +153,12 @@ module Bosh::Director
153
153
  json_encode(deployments)
154
154
  end
155
155
 
156
- get '/deployments/:name' do
156
+ get '/:name' do
157
157
  deployment = @deployment_manager.find_by_name(params[:name])
158
158
  @deployment_manager.deployment_to_json(deployment)
159
159
  end
160
160
 
161
- get '/deployments/:name/vms' do
161
+ get '/:name/vms' do
162
162
  deployment = @deployment_manager.find_by_name(params[:name])
163
163
 
164
164
  format = params[:format]
@@ -170,7 +170,7 @@ module Bosh::Director
170
170
  end
171
171
  end
172
172
 
173
- delete '/deployments/:name' do
173
+ delete '/:name' do
174
174
  deployment = @deployment_manager.find_by_name(params[:name])
175
175
 
176
176
  options = {}
@@ -181,37 +181,37 @@ module Bosh::Director
181
181
  end
182
182
 
183
183
  # Property management
184
- get '/deployments/:deployment/properties' do
184
+ get '/:deployment/properties' do
185
185
  properties = @property_manager.get_properties(params[:deployment]).map do |property|
186
186
  { 'name' => property.name, 'value' => property.value }
187
187
  end
188
188
  json_encode(properties)
189
189
  end
190
190
 
191
- get '/deployments/:deployment/properties/:property' do
191
+ get '/:deployment/properties/:property' do
192
192
  property = @property_manager.get_property(params[:deployment], params[:property])
193
193
  json_encode('value' => property.value)
194
194
  end
195
195
 
196
- post '/deployments/:deployment/properties', :consumes => [:json] do
196
+ post '/:deployment/properties', :consumes => [:json] do
197
197
  payload = json_decode(request.body)
198
198
  @property_manager.create_property(params[:deployment], payload['name'], payload['value'])
199
199
  status(204)
200
200
  end
201
201
 
202
- post '/deployments/:deployment/ssh', :consumes => [:json] do
202
+ post '/:deployment/ssh', :consumes => [:json] do
203
203
  payload = json_decode(request.body)
204
204
  task = @instance_manager.ssh(@user, payload)
205
205
  redirect "/tasks/#{task.id}"
206
206
  end
207
207
 
208
- put '/deployments/:deployment/properties/:property', :consumes => [:json] do
208
+ put '/:deployment/properties/:property', :consumes => [:json] do
209
209
  payload = json_decode(request.body)
210
210
  @property_manager.update_property(params[:deployment], params[:property], payload['value'])
211
211
  status(204)
212
212
  end
213
213
 
214
- delete '/deployments/:deployment/properties/:property' do
214
+ delete '/:deployment/properties/:property' do
215
215
  @property_manager.delete_property(params[:deployment], params[:property])
216
216
  status(204)
217
217
  end
@@ -219,12 +219,12 @@ module Bosh::Director
219
219
  # Cloud check
220
220
 
221
221
  # Initiate deployment scan
222
- post '/deployments/:deployment/scans' do
222
+ post '/:deployment/scans' do
223
223
  start_task { @problem_manager.perform_scan(@user, params[:deployment]) }
224
224
  end
225
225
 
226
226
  # Get the list of problems for a particular deployment
227
- get '/deployments/:deployment/problems' do
227
+ get '/:deployment/problems' do
228
228
  problems = @problem_manager.get_problems(params[:deployment]).map do |problem|
229
229
  {
230
230
  'id' => problem.id,
@@ -239,12 +239,12 @@ module Bosh::Director
239
239
  end
240
240
 
241
241
  # Try to resolve a set of problems
242
- put '/deployments/:deployment/problems', :consumes => [:json] do
242
+ put '/:deployment/problems', :consumes => [:json] do
243
243
  payload = json_decode(request.body)
244
244
  start_task { @problem_manager.apply_resolutions(@user, params[:deployment], payload['resolutions']) }
245
245
  end
246
246
 
247
- put '/deployments/:deployment/scan_and_fix', :consumes => :json do
247
+ put '/:deployment/scan_and_fix', :consumes => :json do
248
248
  jobs_json = json_decode(request.body)['jobs']
249
249
  # payload: [['j1', 'i1'], ['j1', 'i2'], ['j2', 'i1'], ...]
250
250
  payload = convert_job_instance_hash(jobs_json)
@@ -252,13 +252,27 @@ module Bosh::Director
252
252
  start_task { @problem_manager.scan_and_fix(@user, params[:deployment], payload) }
253
253
  end
254
254
 
255
- post '/deployments', :consumes => :yaml do
255
+ post '/', :consumes => :yaml do
256
256
  options = {}
257
257
  options['recreate'] = true if params['recreate'] == 'true'
258
258
 
259
259
  task = @deployment_manager.create_deployment(@user, request.body, options)
260
260
  redirect "/tasks/#{task.id}"
261
261
  end
262
+
263
+ post '/:deployment_name/errands/:errand_name/runs' do
264
+ deployment_name = params[:deployment_name]
265
+ errand_name = params[:errand_name]
266
+
267
+ task = JobQueue.new.enqueue(
268
+ @user,
269
+ Jobs::RunErrand,
270
+ "run errand #{errand_name} from deployment #{deployment_name}",
271
+ [deployment_name, errand_name],
272
+ )
273
+
274
+ redirect "/tasks/#{task.id}"
275
+ end
262
276
  end
263
277
  end
264
278
  end
@@ -3,7 +3,7 @@ require 'bosh/director/api/controllers/base_controller'
3
3
  module Bosh::Director
4
4
  module Api::Controllers
5
5
  class InfoController < BaseController
6
- get '/info' do
6
+ get '/' do
7
7
  status = {
8
8
  'name' => Config.name,
9
9
  'uuid' => Config.uuid,
@@ -1,7 +1,7 @@
1
1
  module Bosh::Director
2
2
  module Api::Controllers
3
3
  class LocksController < BaseController
4
- get '/locks' do
4
+ get '/' do
5
5
  redis = Config.redis
6
6
 
7
7
  locks = []
@@ -3,7 +3,7 @@ require 'bosh/director/api/controllers/base_controller'
3
3
  module Bosh::Director
4
4
  module Api::Controllers
5
5
  class PackagesController < BaseController
6
- post '/packages/matches', :consumes => :yaml do
6
+ post '/matches', :consumes => :yaml do
7
7
  manifest = Psych.load(request.body)
8
8
 
9
9
  unless manifest.is_a?(Hash) && manifest['packages'].is_a?(Array)
@@ -3,20 +3,20 @@ require 'bosh/director/api/controllers/base_controller'
3
3
  module Bosh::Director
4
4
  module Api::Controllers
5
5
  class ReleasesController < BaseController
6
- post '/releases', :consumes => :json do
6
+ post '/', :consumes => :json do
7
7
  payload = json_decode(request.body)
8
8
  rebase = params['rebase'] == 'true'
9
9
  task = @release_manager.create_release_from_url(@user, payload['location'], rebase)
10
10
  redirect "/tasks/#{task.id}"
11
11
  end
12
12
 
13
- post '/releases', :consumes => :multipart do
13
+ post '/', :consumes => :multipart do
14
14
  rebase = params['rebase'] == 'true'
15
15
  task = @release_manager.create_release_from_file_path(@user, params[:nginx_upload_path], rebase)
16
16
  redirect "/tasks/#{task.id}"
17
17
  end
18
18
 
19
- get '/releases' do
19
+ get '/' do
20
20
  releases = Models::Release.order_by(:name.asc).map do |release|
21
21
  release_versions = release.versions_dataset.order_by(:version.asc).map do |rv|
22
22
  {
@@ -37,7 +37,7 @@ module Bosh::Director
37
37
  json_encode(releases)
38
38
  end
39
39
 
40
- get '/releases/:name' do
40
+ get '/:name' do
41
41
  name = params[:name].to_s.strip
42
42
  release = @release_manager.find_by_name(name)
43
43
 
@@ -69,7 +69,7 @@ module Bosh::Director
69
69
  json_encode(result)
70
70
  end
71
71
 
72
- delete '/releases/:name' do
72
+ delete '/:name' do
73
73
  release = @release_manager.find_by_name(params[:name])
74
74
 
75
75
  options = {}