bosh-director 1.2847.0 → 1.2849.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1a7e3fb908b7bf0f3636e71c74e48a297b911a4
4
- data.tar.gz: a73af7de9a6881166a17bfcd20df8d979e52a71c
3
+ metadata.gz: bd013aa7392043f0147806eb7ec6e8ef0d6f9105
4
+ data.tar.gz: 318c2b8c5c85bea4e52169c4eaebd4c02c26c64f
5
5
  SHA512:
6
- metadata.gz: 6e7e0817d2464dea69d69a3dfe6f5c058e76f793886112a3b57fb0d44f8fccc4d08aa8ef3e38d21cb171bb8f4f7f4b83a9a282826ae0436f9789db0800d62637
7
- data.tar.gz: c77184d889e22d63620b36276296aad392e7e8ec78765da37d5bbbe2ac56a944682e5ca0f59b0cd8a296747aa30ca67e8e95c71a659210d102b90055ef38ae50
6
+ metadata.gz: 96ae8e542b92ba5f91ebd354c3a606427078309a3d1e30158fc4ec57592eadaa7d2a25ec1f5bced3664c6978290cf758c7a4c3bb1010d2d2ba3d576d7606b9f7
7
+ data.tar.gz: 3a0dac5c4f27bc9ca43b755b8ee73fec526bbb464c931c613ba3d2ccaa93a503958780f4f2e4a3a102c653775adbb66b6a9bcd913b509f219959e56949e6dd96
@@ -16,61 +16,70 @@ opts.parse!(ARGV.dup)
16
16
  config_file ||= ::File.expand_path('../../config/bosh-director.yml', __FILE__)
17
17
  config = Bosh::Director::Config.load_file(config_file)
18
18
 
19
- Bosh::Director::App.new(config)
19
+ director_app = Bosh::Director::App.new(config)
20
+
21
+ compiled_package_group_manager = Bosh::Director::Api::CompiledPackageGroupManager.new
22
+ resource_manager = Bosh::Director::Api::ResourceManager.new(director_app.blobstores.blobstore)
23
+ # user_management_hash = config.hash['user_management']
24
+ identity_provider = #if user_management_hash && user_management_hash['provider'] == 'uaa'
25
+ # Bosh::Director::Api::UaaIdentityProvider.new
26
+ # else
27
+ Bosh::Director::Api::LocalIdentityProvider.new Bosh::Director::Api::UserManager.new
28
+ # end
20
29
 
21
30
  thin_server = Thin::Server.new('127.0.0.1', config.hash['port'], signals: false) do
22
31
  use Rack::CommonLogger
23
32
 
24
33
  map '/info' do
25
- run Bosh::Director::Api::Controllers::InfoController.new
34
+ run Bosh::Director::Api::Controllers::InfoController.new identity_provider
26
35
  end
27
36
 
28
37
  map '/tasks' do
29
- run Bosh::Director::Api::Controllers::TasksController.new
38
+ run Bosh::Director::Api::Controllers::TasksController.new identity_provider
30
39
  end
31
40
 
32
41
  map '/backups' do
33
- run Bosh::Director::Api::Controllers::BackupsController.new
42
+ run Bosh::Director::Api::Controllers::BackupsController.new identity_provider
34
43
  end
35
44
 
36
45
  map '/deployments' do
37
- run Bosh::Director::Api::Controllers::DeploymentsController.new
46
+ run Bosh::Director::Api::Controllers::DeploymentsController.new identity_provider
38
47
  end
39
48
 
40
49
  map '/packages' do
41
- run Bosh::Director::Api::Controllers::PackagesController.new
50
+ run Bosh::Director::Api::Controllers::PackagesController.new identity_provider
42
51
  end
43
52
 
44
53
  map '/releases' do
45
- run Bosh::Director::Api::Controllers::ReleasesController.new
54
+ run Bosh::Director::Api::Controllers::ReleasesController.new identity_provider
46
55
  end
47
56
 
48
57
  map '/resources' do
49
- run Bosh::Director::Api::Controllers::ResourcesController.new
58
+ run Bosh::Director::Api::Controllers::ResourcesController.new identity_provider, resource_manager
50
59
  end
51
60
 
52
61
  map '/resurrection' do
53
- run Bosh::Director::Api::Controllers::ResurrectionController.new
62
+ run Bosh::Director::Api::Controllers::ResurrectionController.new identity_provider
54
63
  end
55
64
 
56
65
  map '/stemcells' do
57
- run Bosh::Director::Api::Controllers::StemcellsController.new
66
+ run Bosh::Director::Api::Controllers::StemcellsController.new identity_provider
58
67
  end
59
68
 
60
69
  map '/task' do
61
- run Bosh::Director::Api::Controllers::TaskController.new
70
+ run Bosh::Director::Api::Controllers::TaskController.new identity_provider
62
71
  end
63
72
 
64
73
  map '/users' do
65
- run Bosh::Director::Api::Controllers::UsersController.new
74
+ run Bosh::Director::Api::Controllers::UsersController.new identity_provider
66
75
  end
67
76
 
68
77
  map '/compiled_package_groups' do
69
- run Bosh::Director::Api::Controllers::CompiledPackagesController.new
78
+ run Bosh::Director::Api::Controllers::CompiledPackagesController.new identity_provider, compiled_package_group_manager
70
79
  end
71
80
 
72
81
  map '/locks' do
73
- run Bosh::Director::Api::Controllers::LocksController.new
82
+ run Bosh::Director::Api::Controllers::LocksController.new identity_provider
74
83
  end
75
84
  end
76
85
 
@@ -131,6 +131,7 @@ require 'bosh/director/models/helpers/model_helper'
131
131
 
132
132
  require 'bosh/director/db_backup'
133
133
  require 'bosh/director/blobstores'
134
+ require 'bosh/director/api/local_identity_provider'
134
135
  require 'bosh/director/app'
135
136
 
136
137
  module Bosh::Director
@@ -138,7 +139,6 @@ module Bosh::Director
138
139
  end
139
140
 
140
141
  require 'bosh/director/thread_pool'
141
- require 'bosh/director/api/controller_helpers'
142
142
  require 'bosh/director/api/controllers/backups_controller'
143
143
  require 'bosh/director/api/controllers/deployments_controller'
144
144
  require 'bosh/director/api/controllers/packages_controller'
@@ -2,21 +2,19 @@ module Bosh::Director
2
2
  module Api
3
3
  module Controllers
4
4
  class BaseController < Sinatra::Base
5
- PUBLIC_URLS = %w(/info)
6
-
7
5
  include ApiHelper
8
6
  include Http
9
7
  include DnsHelper
10
8
 
11
- def initialize(*_)
12
- super
9
+ def initialize(identity_provider)
10
+ super()
11
+ @identity_provider = identity_provider
13
12
  @deployment_manager = DeploymentManager.new
14
13
  @backup_manager = BackupManager.new
15
14
  @instance_manager = InstanceManager.new
16
15
  @resurrector_manager = ResurrectorManager.new
17
16
  @problem_manager = ProblemManager.new
18
17
  @property_manager = PropertyManager.new
19
- @resource_manager = ResourceManager.new
20
18
  @release_manager = ReleaseManager.new
21
19
  @snapshot_manager = SnapshotManager.new
22
20
  @stemcell_manager = StemcellManager.new
@@ -41,23 +39,23 @@ module Bosh::Director
41
39
  end
42
40
  end
43
41
 
44
- def authenticate(user, password)
45
- if @user_manager.authenticate(user, password)
46
- @user = user
47
- true
48
- else
49
- false
50
- end
42
+ def always_authenticated?
43
+ true
51
44
  end
52
45
 
53
- helpers ControllerHelpers
54
-
55
46
  before do
56
47
  auth_provided = %w(HTTP_AUTHORIZATION X-HTTP_AUTHORIZATION X_HTTP_AUTHORIZATION).detect do |key|
57
48
  request.env.has_key?(key)
58
49
  end
59
50
 
60
- protected! if auth_provided || !PUBLIC_URLS.include?(request.path)
51
+ if auth_provided || always_authenticated?
52
+ begin
53
+ @user = @identity_provider.corroborate_user(request.env)
54
+ rescue AuthenticationError => e
55
+ response['WWW-Authenticate'] = 'Basic realm="BOSH Director"'
56
+ throw(:halt, [401, "Not authorized\n"])
57
+ end
58
+ end
61
59
  end
62
60
 
63
61
  after { headers('Date' => Time.now.rfc822) } # As thin doesn't inject date
@@ -11,9 +11,9 @@ require 'bosh/director/jobs/import_compiled_packages'
11
11
  module Bosh::Director
12
12
  module Api::Controllers
13
13
  class CompiledPackagesController < BaseController
14
- def initialize(*args)
15
- super
16
- @compiled_package_group_manager = Api::CompiledPackageGroupManager.new
14
+ def initialize(identity_provider, compiled_package_group_manager)
15
+ super(identity_provider)
16
+ @compiled_package_group_manager = compiled_package_group_manager
17
17
  end
18
18
 
19
19
  post '/export', consumes: :json do
@@ -238,7 +238,6 @@ module Bosh::Director
238
238
  json_encode(problems)
239
239
  end
240
240
 
241
- # Try to resolve a set of problems
242
241
  put '/:deployment/problems', :consumes => [:json] do
243
242
  payload = json_decode(request.body)
244
243
  start_task { @problem_manager.apply_resolutions(@user, params[:deployment], payload['resolutions']) }
@@ -246,7 +245,6 @@ module Bosh::Director
246
245
 
247
246
  put '/:deployment/scan_and_fix', :consumes => :json do
248
247
  jobs_json = json_decode(request.body)['jobs']
249
- # payload: [['j1', 'i1'], ['j1', 'i2'], ['j2', 'i1'], ...]
250
248
  payload = convert_job_instance_hash(jobs_json)
251
249
 
252
250
  start_task { @problem_manager.scan_and_fix(@user, params[:deployment], payload) }
@@ -289,6 +287,14 @@ module Bosh::Director
289
287
 
290
288
  json_encode(errand_data)
291
289
  end
290
+
291
+ private
292
+ def convert_job_instance_hash(hash)
293
+ hash.reduce([]) do |jobs, kv|
294
+ job, indicies = kv
295
+ jobs + indicies.map { |index| [job, index] }
296
+ end
297
+ end
292
298
  end
293
299
  end
294
300
  end
@@ -3,6 +3,10 @@ require 'bosh/director/api/controllers/base_controller'
3
3
  module Bosh::Director
4
4
  module Api::Controllers
5
5
  class InfoController < BaseController
6
+ def always_authenticated?
7
+ false
8
+ end
9
+
6
10
  get '/' do
7
11
  status = {
8
12
  'name' => Config.name,
@@ -3,6 +3,12 @@ require 'bosh/director/api/controllers/base_controller'
3
3
  module Bosh::Director
4
4
  module Api::Controllers
5
5
  class ResourcesController < BaseController
6
+
7
+ def initialize(identity_provider, resource_manager)
8
+ super(identity_provider)
9
+ @resource_manager = resource_manager
10
+ end
11
+
6
12
  get '/:id' do
7
13
  tmp_file = @resource_manager.get_resource_path(params[:id])
8
14
  send_disposable_file(tmp_file, :type => 'application/x-gzip')
@@ -75,6 +75,20 @@ module Bosh::Director
75
75
  status(204)
76
76
  end
77
77
  end
78
+
79
+ private
80
+
81
+ def task_timeout?(task)
82
+ # Some of the old task entries might not have the checkpoint_time
83
+ unless task.checkpoint_time
84
+ task.checkpoint_time = Time.now
85
+ task.save
86
+ end
87
+
88
+ # If no checkpoint update in 3 cycles --> timeout
89
+ (task.state == 'processing' || task.state == 'cancelling') &&
90
+ (Time.now - task.checkpoint_time > Config.task_checkpoint_interval * 3)
91
+ end
78
92
  end
79
93
  end
80
94
  end
@@ -0,0 +1,22 @@
1
+ module Bosh
2
+ module Director
3
+ module Api
4
+ class LocalIdentityProvider
5
+ def initialize(user_manager)
6
+ @user_manager = user_manager
7
+ end
8
+
9
+ def corroborate_user(request_env)
10
+ auth ||= Rack::Auth::Basic::Request.new(request_env)
11
+ raise AuthenticationError unless auth.provided? && auth.basic? && auth.credentials
12
+
13
+ if @user_manager.authenticate(*auth.credentials)
14
+ auth.credentials.first
15
+ else
16
+ raise AuthenticationError
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -29,7 +29,5 @@ module Bosh::Director
29
29
 
30
30
  @blobstores = Blobstores.new(config)
31
31
  end
32
-
33
-
34
32
  end
35
33
  end
@@ -4,6 +4,7 @@ module Bosh::Director
4
4
  include Api::Http
5
5
 
6
6
  class ProblemHandlerError < StandardError; end
7
+ class AuthenticationError < StandardError; end
7
8
 
8
9
  # DirectorError is a generic exception for most of the errors originated
9
10
  # in BOSH Director.
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module Director
3
- VERSION = '1.2847.0'
3
+ VERSION = '1.2849.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh-director
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2847.0
4
+ version: 1.2849.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - VMware
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-13 00:00:00.000000000 Z
11
+ date: 2015-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcrypt-ruby
@@ -30,126 +30,126 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.2847.0
33
+ version: 1.2849.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.2847.0
40
+ version: 1.2849.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bosh-core
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.2847.0
47
+ version: 1.2849.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.2847.0
54
+ version: 1.2849.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bosh-director-core
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.2847.0
61
+ version: 1.2849.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.2847.0
68
+ version: 1.2849.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bosh_common
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.2847.0
75
+ version: 1.2849.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.2847.0
82
+ version: 1.2849.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bosh-template
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 1.2847.0
89
+ version: 1.2849.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 1.2847.0
96
+ version: 1.2849.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: bosh_cpi
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.2847.0
103
+ version: 1.2849.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.2847.0
110
+ version: 1.2849.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: bosh_openstack_cpi
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 1.2847.0
117
+ version: 1.2849.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 1.2847.0
124
+ version: 1.2849.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: bosh_aws_cpi
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 1.2847.0
131
+ version: 1.2849.0
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 1.2847.0
138
+ version: 1.2849.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: bosh_vsphere_cpi
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 1.2847.0
145
+ version: 1.2849.0
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 1.2847.0
152
+ version: 1.2849.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: bosh_vcloud_cpi
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -446,7 +446,7 @@ dependencies:
446
446
  version: '0'
447
447
  description: |-
448
448
  BOSH Director
449
- 139553
449
+ 4f117d
450
450
  email: support@cloudfoundry.com
451
451
  executables:
452
452
  - bosh-director
@@ -505,7 +505,6 @@ files:
505
505
  - lib/bosh/director/api/api_helper.rb
506
506
  - lib/bosh/director/api/backup_manager.rb
507
507
  - lib/bosh/director/api/compiled_package_group_manager.rb
508
- - lib/bosh/director/api/controller_helpers.rb
509
508
  - lib/bosh/director/api/controllers/backups_controller.rb
510
509
  - lib/bosh/director/api/controllers/base_controller.rb
511
510
  - lib/bosh/director/api/controllers/compiled_packages_controller.rb
@@ -525,6 +524,7 @@ files:
525
524
  - lib/bosh/director/api/http_constants.rb
526
525
  - lib/bosh/director/api/instance_lookup.rb
527
526
  - lib/bosh/director/api/instance_manager.rb
527
+ - lib/bosh/director/api/local_identity_provider.rb
528
528
  - lib/bosh/director/api/problem_manager.rb
529
529
  - lib/bosh/director/api/property_manager.rb
530
530
  - lib/bosh/director/api/release_manager.rb
@@ -1,34 +0,0 @@
1
- module Bosh::Director
2
- module Api::ControllerHelpers
3
- def task_timeout?(task)
4
- # Some of the old task entries might not have the checkpoint_time
5
- unless task.checkpoint_time
6
- task.checkpoint_time = Time.now
7
- task.save
8
- end
9
-
10
- # If no checkpoint update in 3 cycles --> timeout
11
- (task.state == 'processing' || task.state == 'cancelling') &&
12
- (Time.now - task.checkpoint_time > Config.task_checkpoint_interval * 3)
13
- end
14
-
15
- def protected!
16
- unless authorized?
17
- response['WWW-Authenticate'] = 'Basic realm="BOSH Director"'
18
- throw(:halt, [401, "Not authorized\n"])
19
- end
20
- end
21
-
22
- def authorized?
23
- @auth ||= Rack::Auth::Basic::Request.new(request.env)
24
- @auth.provided? && @auth.basic? && @auth.credentials && authenticate(*@auth.credentials)
25
- end
26
-
27
- def convert_job_instance_hash(hash)
28
- hash.reduce([]) do |jobs, kv|
29
- job, indicies = kv
30
- jobs + indicies.map { |index| [job, index] }
31
- end
32
- end
33
- end
34
- end