bosh-director 1.5.0.pre.1148 → 1.5.0.pre.1152

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,12 @@
1
+ require 'bosh/director/api/controllers/base_controller'
2
+
3
+ module Bosh::Director
4
+ module Api::Controllers
5
+ class ResourcesController < BaseController
6
+ get '/resources/:id' do
7
+ tmp_file = @resource_manager.get_resource_path(params[:id])
8
+ send_disposable_file(tmp_file, :type => 'application/x-gzip')
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ require 'bosh/director/api/controllers/base_controller'
2
+
3
+ module Bosh::Director
4
+ module Api::Controllers
5
+ class ResurrectionController < BaseController
6
+ put '/resurrection', consumes: :json do
7
+ payload = json_decode(request.body)
8
+
9
+ @resurrector_manager.set_pause_for_all(payload['resurrection_paused'])
10
+ status(200)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,38 @@
1
+ require 'bosh/director/api/controllers/base_controller'
2
+
3
+ module Bosh::Director
4
+ module Api::Controllers
5
+ class StemcellsController < BaseController
6
+ post '/stemcells', :consumes => :tgz do
7
+ task = @stemcell_manager.create_stemcell(@user, request.body, :remote => false)
8
+ redirect "/tasks/#{task.id}"
9
+ end
10
+
11
+ post '/stemcells', :consumes => :json do
12
+ payload = json_decode(request.body)
13
+ task = @stemcell_manager.create_stemcell(@user, payload['location'], :remote => true)
14
+ redirect "/tasks/#{task.id}"
15
+ end
16
+
17
+ get '/stemcells' do
18
+ stemcells = Models::Stemcell.order_by(:name.asc).map do |stemcell|
19
+ {
20
+ 'name' => stemcell.name,
21
+ 'version' => stemcell.version,
22
+ 'cid' => stemcell.cid
23
+ }
24
+ end
25
+ json_encode(stemcells)
26
+ end
27
+
28
+ delete '/stemcells/:name/:version' do
29
+ name, version = params[:name], params[:version]
30
+ options = {}
31
+ options['force'] = true if params['force'] == 'true'
32
+ stemcell = @stemcell_manager.find_by_name_and_version(name, version)
33
+ task = @stemcell_manager.delete_stemcell(@user, stemcell, options)
34
+ redirect "/tasks/#{task.id}"
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,95 @@
1
+ require 'bosh/director/api/controllers/base_controller'
2
+
3
+ module Bosh::Director
4
+ module Api::Controllers
5
+ class TasksController < BaseController
6
+ get '/tasks' do
7
+ dataset = Models::Task.dataset
8
+ limit = params['limit']
9
+ if limit
10
+ limit = limit.to_i
11
+ limit = 1 if limit < 1
12
+ dataset = dataset.limit(limit)
13
+ end
14
+
15
+ states = params['state'].to_s.split(',')
16
+
17
+ if states.size > 0
18
+ dataset = dataset.filter(:state => states)
19
+ end
20
+
21
+ verbose = params['verbose'] || '1'
22
+ if verbose == '1'
23
+ dataset = dataset.filter(type: %w[
24
+ update_deployment
25
+ delete_deployment
26
+ update_release
27
+ delete_release
28
+ update_stemcell
29
+ delete_stemcell
30
+ create_snapshot
31
+ delete_snapshot
32
+ snapshot_deployment
33
+ ])
34
+ end
35
+
36
+ tasks = dataset.order_by(:timestamp.desc).map do |task|
37
+ if task_timeout?(task)
38
+ task.state = :timeout
39
+ task.save
40
+ end
41
+ @task_manager.task_to_hash(task)
42
+ end
43
+
44
+ content_type(:json)
45
+ json_encode(tasks)
46
+ end
47
+
48
+ get '/tasks/:id' do
49
+ task = @task_manager.find_task(params[:id])
50
+ if task_timeout?(task)
51
+ task.state = :timeout
52
+ task.save
53
+ end
54
+
55
+ content_type(:json)
56
+ json_encode(@task_manager.task_to_hash(task))
57
+ end
58
+
59
+ # Sends back output of given task id and params[:type]
60
+ # Example: `get /tasks/5/output?type=event` will send back the file
61
+ # at /var/vcap/store/director/tasks/5/event
62
+ get '/tasks/:id/output' do
63
+ log_type = params[:type] || 'debug'
64
+ task = @task_manager.find_task(params[:id])
65
+
66
+ if task.output.nil?
67
+ halt(204)
68
+ end
69
+
70
+ log_file = @task_manager.log_file(task, log_type)
71
+
72
+ if File.file?(log_file)
73
+ send_file(log_file, :type => 'text/plain')
74
+ else
75
+ status(204)
76
+ end
77
+ end
78
+
79
+ delete '/task/:id' do
80
+ task_id = params[:id]
81
+ task = @task_manager.find_task(task_id)
82
+
83
+ if task.state != 'processing' && task.state != 'queued'
84
+ status(400)
85
+ body("Cannot cancel task #{task_id}: invalid state (#{task.state})")
86
+ else
87
+ task.state = :cancelling
88
+ task.save
89
+ status(204)
90
+ body("Cancelling task #{task_id}")
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,30 @@
1
+ require 'bosh/director/api/controllers/base_controller'
2
+
3
+ module Bosh::Director
4
+ module Api::Controllers
5
+ class UsersController < BaseController
6
+ post '/users', :consumes => [:json] do
7
+ user = @user_manager.get_user_from_request(request)
8
+ @user_manager.create_user(user)
9
+ status(204)
10
+ nil
11
+ end
12
+
13
+ put '/users/:username', :consumes => [:json] do
14
+ user = @user_manager.get_user_from_request(request)
15
+ if user.username != params[:username]
16
+ raise UserImmutableUsername, 'The username is immutable'
17
+ end
18
+ @user_manager.update_user(user)
19
+ status(204)
20
+ nil
21
+ end
22
+
23
+ delete '/users/:username' do
24
+ @user_manager.delete_user(params[:username])
25
+ status(204)
26
+ nil
27
+ end
28
+ end
29
+ end
30
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bosh
4
4
  module Director
5
- VERSION = '1.5.0.pre.1148'
5
+ VERSION = '1.5.0.pre.1152'
6
6
  end
7
7
  end
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.5.0.pre.1148
4
+ version: 1.5.0.pre.1152
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 1.5.0.pre.1148
37
+ version: 1.5.0.pre.1152
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.5.0.pre.1148
45
+ version: 1.5.0.pre.1152
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.5.0.pre.1148
53
+ version: 1.5.0.pre.1152
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.5.0.pre.1148
61
+ version: 1.5.0.pre.1152
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: bosh_common
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.5.0.pre.1148
69
+ version: 1.5.0.pre.1152
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.5.0.pre.1148
77
+ version: 1.5.0.pre.1152
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: bosh_cpi
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.5.0.pre.1148
85
+ version: 1.5.0.pre.1152
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.5.0.pre.1148
93
+ version: 1.5.0.pre.1152
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: bosh_openstack_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.5.0.pre.1148
101
+ version: 1.5.0.pre.1152
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.5.0.pre.1148
109
+ version: 1.5.0.pre.1152
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: bosh_aws_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.5.0.pre.1148
117
+ version: 1.5.0.pre.1152
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.5.0.pre.1148
125
+ version: 1.5.0.pre.1152
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: bosh_vsphere_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.5.0.pre.1148
133
+ version: 1.5.0.pre.1152
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.5.0.pre.1148
141
+ version: 1.5.0.pre.1152
142
142
  - !ruby/object:Gem::Dependency
143
143
  name: eventmachine
144
144
  requirement: !ruby/object:Gem::Requirement
@@ -445,7 +445,7 @@ dependencies:
445
445
  version: '1.0'
446
446
  description: ! 'BOSH Director
447
447
 
448
- 715d8f'
448
+ c6bcb9'
449
449
  email: support@cloudfoundry.com
450
450
  executables:
451
451
  - bosh-director
@@ -491,6 +491,17 @@ files:
491
491
  - lib/bosh/director/api/backup_manager.rb
492
492
  - lib/bosh/director/api/controller.rb
493
493
  - lib/bosh/director/api/controller_helpers.rb
494
+ - lib/bosh/director/api/controllers/backups_controller.rb
495
+ - lib/bosh/director/api/controllers/base_controller.rb
496
+ - lib/bosh/director/api/controllers/deployments_controller.rb
497
+ - lib/bosh/director/api/controllers/info_controller.rb
498
+ - lib/bosh/director/api/controllers/packages_controller.rb
499
+ - lib/bosh/director/api/controllers/releases_controller.rb
500
+ - lib/bosh/director/api/controllers/resources_controller.rb
501
+ - lib/bosh/director/api/controllers/resurrection_controller.rb
502
+ - lib/bosh/director/api/controllers/stemcells_controller.rb
503
+ - lib/bosh/director/api/controllers/tasks_controller.rb
504
+ - lib/bosh/director/api/controllers/users_controller.rb
494
505
  - lib/bosh/director/api/deployment_lookup.rb
495
506
  - lib/bosh/director/api/deployment_manager.rb
496
507
  - lib/bosh/director/api/http_constants.rb