steamcannon-deltacloud-core 0.0.8.1 → 0.1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +3 -9
- data/bin/deltacloudd +17 -15
- data/deltacloud.rb +1 -0
- data/lib/deltacloud/backend_capability.rb +21 -0
- data/lib/deltacloud/base_driver/base_driver.rb +6 -0
- data/lib/deltacloud/base_driver/features.rb +22 -0
- data/lib/deltacloud/base_driver/mock_driver.rb +24 -27
- data/lib/deltacloud/drivers/ec2/ec2_driver.rb +432 -494
- data/lib/deltacloud/drivers/gogrid/gogrid_client.rb +4 -7
- data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +116 -3
- data/lib/deltacloud/drivers/mock/mock_driver.rb +56 -2
- data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +5 -19
- data/lib/deltacloud/helpers/application_helper.rb +26 -3
- data/lib/deltacloud/models/image.rb +2 -1
- data/lib/deltacloud/models/instance.rb +22 -5
- data/lib/deltacloud/models/key.rb +17 -0
- data/lib/deltacloud/models/load_balancer.rb +39 -0
- data/lib/deltacloud/models/storage_volume.rb +2 -0
- data/lib/sinatra/rabbit.rb +4 -7
- data/public/javascripts/application.js +10 -24
- data/public/stylesheets/compiled/application.css +2 -0
- data/server.rb +214 -75
- data/views/blobs/new.html.haml +10 -0
- data/views/blobs/show.html.haml +21 -15
- data/views/buckets/index.html.haml +1 -1
- data/views/buckets/show.html.haml +5 -2
- data/views/errors/backend_capability_failure.html.haml +11 -0
- data/views/errors/backend_capability_failure.xml.haml +4 -0
- data/views/errors/backend_error.html.haml +3 -0
- data/views/errors/not_allowed.html.haml +6 -0
- data/views/errors/not_allowed.xml.haml +2 -0
- data/views/instances/index.html.haml +1 -1
- data/views/instances/new.html.haml +8 -0
- data/views/instances/show.html.haml +1 -1
- data/views/keys/show.xml.haml +2 -0
- data/views/load_balancers/index.html.haml +33 -0
- data/views/load_balancers/index.xml.haml +5 -0
- data/views/load_balancers/new.html.haml +38 -0
- data/views/load_balancers/show.html.haml +37 -0
- data/views/load_balancers/show.xml.haml +21 -0
- data/views/realms/index.html.haml +4 -7
- data/views/storage_snapshots/index.html.haml +3 -0
- data/views/storage_snapshots/index.xml.haml +0 -2
- data/views/storage_snapshots/new.html.haml +9 -0
- data/views/storage_snapshots/show.xml.haml +0 -2
- data/views/storage_volumes/attach.html.haml +20 -0
- data/views/storage_volumes/index.html.haml +16 -1
- data/views/storage_volumes/index.xml.haml +1 -20
- data/views/storage_volumes/new.html.haml +17 -0
- data/views/storage_volumes/show.xml.haml +13 -19
- metadata +53 -99
data/lib/sinatra/rabbit.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'sinatra/base'
|
2
2
|
require 'sinatra/url_for'
|
3
3
|
require 'deltacloud/validation'
|
4
|
+
require 'deltacloud/backend_capability'
|
4
5
|
|
5
6
|
module Sinatra
|
6
7
|
|
@@ -13,6 +14,7 @@ module Sinatra
|
|
13
14
|
class Operation
|
14
15
|
attr_reader :name, :method
|
15
16
|
|
17
|
+
include ::Deltacloud::BackendCapability
|
16
18
|
include ::Deltacloud::Validation
|
17
19
|
|
18
20
|
STANDARD = {
|
@@ -55,15 +57,10 @@ module Sinatra
|
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
58
|
-
def control(
|
60
|
+
def control(&block)
|
59
61
|
op = self
|
60
62
|
@control = Proc.new do
|
61
|
-
|
62
|
-
opts[:with_feature] and
|
63
|
-
!driver.respond_to?(opts[:with_feature])
|
64
|
-
raise Deltacloud::BackendFeatureUnsupported.new('501', nil,
|
65
|
-
"#{opts[:with_feature]} not supported by backend", nil)
|
66
|
-
end
|
63
|
+
op.check_capability(driver)
|
67
64
|
op.validate(params)
|
68
65
|
instance_eval(&block)
|
69
66
|
end
|
@@ -3,30 +3,16 @@
|
|
3
3
|
|
4
4
|
$(document).ready(function() {
|
5
5
|
|
6
|
-
$(
|
7
|
-
|
8
|
-
$.
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
if ($('select#list_instances').length) {
|
7
|
+
$('select#list_instances').html("<option>Loading instances...</option>");
|
8
|
+
$.getJSON("/api/instances?state=RUNNING&format=json",
|
9
|
+
function(data){
|
10
|
+
$('select#list_instances').empty();
|
11
|
+
$.each(data.instances, function(i,item){
|
12
|
+
$('select#list_instances').append('<option value="'+item.id+'">'+item.id+'</option>');
|
13
|
+
});
|
14
14
|
}
|
15
|
-
|
16
|
-
|
17
|
-
})
|
18
|
-
|
19
|
-
$("a.post").click(function(e) {
|
20
|
-
var original_url = $(this).attr('href')
|
21
|
-
$.ajax({
|
22
|
-
url : original_url,
|
23
|
-
type : 'POST',
|
24
|
-
dataType : 'xml',
|
25
|
-
success: function(data) {
|
26
|
-
window.location = original_url.replace(/\/([\w_-]+)$/i, '')
|
27
|
-
}
|
28
|
-
})
|
29
|
-
return false;
|
30
|
-
})
|
15
|
+
);
|
16
|
+
}
|
31
17
|
|
32
18
|
})
|
data/server.rb
CHANGED
@@ -32,6 +32,9 @@ error Deltacloud::Validation::Failure do
|
|
32
32
|
report_error(400, "validation_failure")
|
33
33
|
end
|
34
34
|
|
35
|
+
error Deltacloud::BackendCapability::Failure do
|
36
|
+
report_error(405, "backend_capability_failure")
|
37
|
+
end
|
35
38
|
error Deltacloud::AuthException do
|
36
39
|
report_error(403, "auth_exception")
|
37
40
|
end
|
@@ -82,6 +85,7 @@ END
|
|
82
85
|
Operation will list all available realms. Realms can be filtered using
|
83
86
|
the "architecture" parameter.
|
84
87
|
END
|
88
|
+
with_capability :realms
|
85
89
|
param :id, :string
|
86
90
|
param :architecture, :string, :optional, [ 'i386', 'x86_64' ]
|
87
91
|
control { filter_all(:realms) }
|
@@ -90,6 +94,7 @@ END
|
|
90
94
|
#FIXME: It always shows whole list
|
91
95
|
operation :show do
|
92
96
|
description 'Show an realm identified by "id" parameter.'
|
97
|
+
with_capability :realm
|
93
98
|
param :id, :string, :required
|
94
99
|
control { show(:realm) }
|
95
100
|
end
|
@@ -108,6 +113,7 @@ END
|
|
108
113
|
available to the current use. Images can be filtered using the
|
109
114
|
"owner_id" and "architecture" parameters.
|
110
115
|
END
|
116
|
+
with_capability :images
|
111
117
|
param :id, :string
|
112
118
|
param :architecture, :string, :optional
|
113
119
|
control { filter_all(:images) }
|
@@ -115,6 +121,7 @@ END
|
|
115
121
|
|
116
122
|
operation :show do
|
117
123
|
description 'Show an image identified by "id" parameter.'
|
124
|
+
with_capability :image
|
118
125
|
param :id, :string, :required
|
119
126
|
control { show(:image) }
|
120
127
|
end
|
@@ -168,11 +175,87 @@ get "/api/instances/new" do
|
|
168
175
|
@image = driver.image( credentials, :id => params[:image_id] )
|
169
176
|
@hardware_profiles = driver.hardware_profiles(credentials, :architecture => @image.architecture )
|
170
177
|
@realms = driver.realms(credentials)
|
178
|
+
if driver_has_feature?(:register_to_load_balancer)
|
179
|
+
@load_balancers = driver.load_balancers(credentials)
|
180
|
+
end
|
171
181
|
respond_to do |format|
|
172
182
|
format.html { haml :"instances/new" }
|
173
183
|
end
|
174
184
|
end
|
175
185
|
|
186
|
+
get '/api/load_balancers/new' do
|
187
|
+
@realms = driver.realms(credentials)
|
188
|
+
@instances = driver.instances(credentials) if driver_has_feature?(:register_instance, :load_balancers)
|
189
|
+
respond_to do |format|
|
190
|
+
format.html { haml :"load_balancers/new" }
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
|
195
|
+
collection :load_balancers do
|
196
|
+
description "Load balancers"
|
197
|
+
|
198
|
+
operation :index do
|
199
|
+
description "List of all active load balancers"
|
200
|
+
control do
|
201
|
+
filter_all :load_balancers
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
operation :show do
|
206
|
+
description "Show details about given load balancer"
|
207
|
+
param :id, :string, :required
|
208
|
+
control { show :load_balancer }
|
209
|
+
end
|
210
|
+
|
211
|
+
operation :create do
|
212
|
+
description "Create a new load balancer"
|
213
|
+
param :name, :string, :required
|
214
|
+
param :realm_id, :string, :required
|
215
|
+
param :listener_protocol, :string, :required, ['HTTP', 'TCP']
|
216
|
+
param :listener_balancer_port, :string, :required
|
217
|
+
param :listener_instance_port, :string, :required
|
218
|
+
control do
|
219
|
+
@load_balancer = driver.create_load_balancer(credentials, params)
|
220
|
+
respond_to do |format|
|
221
|
+
format.xml { haml :"load_balancers/show" }
|
222
|
+
format.html { haml :"load_balancers/show" }
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
operation :register, :method => :post, :member => true do
|
228
|
+
description "Add instance to loadbalancer"
|
229
|
+
param :id, :string, :required
|
230
|
+
param :instance_id, :string, :required
|
231
|
+
control do
|
232
|
+
driver.lb_register_instance(credentials, params)
|
233
|
+
redirect(load_balancer_url(params[:id]))
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
operation :unregister, :method => :post, :member => true do
|
238
|
+
description "Remove instance from loadbalancer"
|
239
|
+
param :id, :string, :required
|
240
|
+
param :instance_id, :string, :required
|
241
|
+
control do
|
242
|
+
driver.lb_unregister_instance(credentials, params)
|
243
|
+
redirect(load_balancer_url(params[:id]))
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
operation :destroy do
|
248
|
+
description "Destroy given load balancer"
|
249
|
+
param :id, :string, :required
|
250
|
+
control do
|
251
|
+
driver.destroy_load_balancer(credentials, params[:id])
|
252
|
+
redirect(load_balancers_url)
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
end
|
257
|
+
|
258
|
+
|
176
259
|
collection :instances do
|
177
260
|
description <<END
|
178
261
|
An instance is a concrete machine realized from an image.
|
@@ -181,6 +264,7 @@ END
|
|
181
264
|
|
182
265
|
operation :index do
|
183
266
|
description "List all instances."
|
267
|
+
with_capability :instances
|
184
268
|
param :id, :string, :optional
|
185
269
|
param :state, :string, :optional
|
186
270
|
control { filter_all(:instances) }
|
@@ -188,12 +272,14 @@ END
|
|
188
272
|
|
189
273
|
operation :show do
|
190
274
|
description 'Show an instance identified by "id" parameter.'
|
275
|
+
with_capability :instance
|
191
276
|
param :id, :string, :required
|
192
277
|
control { show(:instance) }
|
193
278
|
end
|
194
279
|
|
195
280
|
operation :create do
|
196
281
|
description "Create a new instance."
|
282
|
+
with_capability :create_instance
|
197
283
|
param :image_id, :string, :required
|
198
284
|
param :realm_id, :string, :optional
|
199
285
|
param :hwp_id, :string, :optional
|
@@ -217,24 +303,28 @@ END
|
|
217
303
|
|
218
304
|
operation :reboot, :method => :post, :member => true do
|
219
305
|
description "Reboot a running instance."
|
306
|
+
with_capability :reboot_instance
|
220
307
|
param :id, :string, :required
|
221
308
|
control { instance_action(:reboot) }
|
222
309
|
end
|
223
310
|
|
224
311
|
operation :start, :method => :post, :member => true do
|
225
312
|
description "Start an instance."
|
313
|
+
with_capability :start_instance
|
226
314
|
param :id, :string, :required
|
227
315
|
control { instance_action(:start) }
|
228
316
|
end
|
229
317
|
|
230
318
|
operation :stop, :method => :post, :member => true do
|
231
319
|
description "Stop a running instance."
|
320
|
+
with_capability :stop_instance
|
232
321
|
param :id, :string, :required
|
233
322
|
control { instance_action(:stop) }
|
234
323
|
end
|
235
324
|
|
236
325
|
operation :destroy do
|
237
326
|
description "Destroy an instance."
|
327
|
+
with_capability :destroy_instance
|
238
328
|
param :id, :string, :required
|
239
329
|
control { instance_action(:destroy) }
|
240
330
|
end
|
@@ -250,6 +340,7 @@ END
|
|
250
340
|
|
251
341
|
operation :index do
|
252
342
|
description "List of available hardware profiles."
|
343
|
+
with_capability :hardware_profiles
|
253
344
|
param :id, :string
|
254
345
|
param :architecture, :string, :optional, [ 'i386', 'x86_64' ]
|
255
346
|
control do
|
@@ -264,6 +355,7 @@ END
|
|
264
355
|
|
265
356
|
operation :show do
|
266
357
|
description "Show specific hardware profile."
|
358
|
+
with_capability :hardware_profile
|
267
359
|
param :id, :string, :required
|
268
360
|
control do
|
269
361
|
@profile = driver.hardware_profile(credentials, params[:id])
|
@@ -281,110 +373,127 @@ END
|
|
281
373
|
|
282
374
|
end
|
283
375
|
|
376
|
+
get '/api/storage_snapshots/new' do
|
377
|
+
respond_to do |format|
|
378
|
+
format.html { haml :"storage_snapshots/new" }
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
284
382
|
collection :storage_snapshots do
|
285
383
|
description "Storage snapshots description here"
|
286
384
|
|
287
385
|
operation :index do
|
288
386
|
description "List of storage snapshots."
|
387
|
+
with_capability :storage_snapshots
|
289
388
|
param :id, :string
|
290
389
|
control { filter_all(:storage_snapshots) }
|
291
390
|
end
|
292
391
|
|
293
392
|
operation :show do
|
294
393
|
description "Show storage snapshot."
|
394
|
+
with_capability :storage_snapshot
|
295
395
|
param :id, :string, :required
|
296
396
|
control { show(:storage_snapshot) }
|
297
397
|
end
|
398
|
+
|
399
|
+
operation :create do
|
400
|
+
description "Create a new snapshot from volume"
|
401
|
+
with_capability :create_storage_snapshot
|
402
|
+
param :volume_id, :string, :required
|
403
|
+
control do
|
404
|
+
@storage_snapshot = driver.create_storage_snapshot(credentials, params)
|
405
|
+
show(:storage_snapshot)
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
operation :destroy do
|
410
|
+
description "Delete storage snapshot"
|
411
|
+
with_capability :destroy_storage_snapshot
|
412
|
+
param :id, :string, :required
|
413
|
+
control do
|
414
|
+
driver.create_storage_snapshot(credentials, params)
|
415
|
+
redirect(storage_snapshot_url(params[:id]))
|
416
|
+
end
|
417
|
+
end
|
418
|
+
|
419
|
+
end
|
420
|
+
|
421
|
+
get '/api/storage_volumes/new' do
|
422
|
+
respond_to do |format|
|
423
|
+
format.html { haml :"storage_volumes/new" }
|
424
|
+
end
|
298
425
|
end
|
299
426
|
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
427
|
+
get '/api/storage_volumes/attach' do
|
428
|
+
respond_to do |format|
|
429
|
+
@instances = driver.instances(credentials)
|
430
|
+
format.html { haml :"storage_volumes/attach" }
|
431
|
+
end
|
432
|
+
end
|
305
433
|
|
306
434
|
collection :storage_volumes do
|
307
435
|
description "Storage volumes description here"
|
308
436
|
|
309
437
|
operation :index do
|
310
438
|
description "List of storage volumes."
|
439
|
+
with_capability :storage_volumes
|
311
440
|
param :id, :string
|
312
441
|
control { filter_all(:storage_volumes) }
|
313
442
|
end
|
314
443
|
|
315
444
|
operation :show do
|
316
445
|
description "Show storage volume."
|
446
|
+
with_capability :storage_volume
|
317
447
|
param :id, :string, :required
|
318
448
|
control { show(:storage_volume) }
|
319
449
|
end
|
320
450
|
|
321
451
|
operation :create do
|
322
|
-
description "Create new storage volume
|
323
|
-
|
324
|
-
param :
|
325
|
-
|
326
|
-
|
452
|
+
description "Create a new storage volume"
|
453
|
+
with_capability :create_storage_volume
|
454
|
+
param :snapshot_id, :string, :optional
|
455
|
+
param :capacity, :string, :optional
|
456
|
+
param :realm_id, :string, :optional
|
457
|
+
control do
|
458
|
+
@storage_volume = driver.create_storage_volume(credentials, params)
|
327
459
|
respond_to do |format|
|
328
|
-
format.
|
329
|
-
|
330
|
-
response['Location'] = storage_volume_url(volume.id)
|
331
|
-
@storage_volume = volume
|
332
|
-
haml :"storage_volumes/show"
|
333
|
-
end
|
334
|
-
format.html do
|
335
|
-
redirect storage_volume_url(volume.id) if volume and volume.id
|
336
|
-
redirect storage_volumes_url
|
337
|
-
end
|
460
|
+
format.html { haml :"storage_volumes/show" }
|
461
|
+
format.xml { haml :"storage_volumes/show" }
|
338
462
|
end
|
339
463
|
end
|
340
464
|
end
|
341
|
-
|
342
|
-
operation :destroy do
|
343
|
-
param :id, :string, :required
|
344
|
-
control :with_feature => :destroy_storage_volume do
|
345
|
-
driver.destroy_storage_volume(credentials, params[:id])
|
346
|
-
redirect(storage_volumes_url)
|
347
|
-
end
|
348
|
-
end
|
349
465
|
|
350
466
|
operation :attach, :method => :post, :member => true do
|
351
|
-
|
352
|
-
|
353
|
-
param :
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
response.status = 200
|
360
|
-
response['Location'] = storage_volume_url(volume.id)
|
361
|
-
@storage_volume = volume
|
362
|
-
haml :"storage_volumes/show"
|
363
|
-
end
|
364
|
-
format.html do
|
365
|
-
redirect storage_volume_url(volume.id)
|
366
|
-
end
|
367
|
-
end
|
467
|
+
description "Attach storage volume to instance"
|
468
|
+
with_capability :attach_storage_volume
|
469
|
+
param :id, :string, :required
|
470
|
+
param :instance_id,:string, :required
|
471
|
+
param :device, :string, :required
|
472
|
+
control do
|
473
|
+
driver.attach_storage_volume(credentials, params)
|
474
|
+
redirect(storage_volume_url(params[:id]))
|
368
475
|
end
|
369
476
|
end
|
370
477
|
|
371
|
-
|
372
478
|
operation :detach, :method => :post, :member => true do
|
373
|
-
|
479
|
+
description "Detach storage volume to instance"
|
480
|
+
with_capability :detach_storage_volume
|
481
|
+
param :id, :string, :required
|
482
|
+
control do
|
483
|
+
volume = driver.storage_volume(credentials, :id => params[:id])
|
484
|
+
driver.detach_storage_volume(credentials, :id => volume.id, :instance_id => volume.instance_id,
|
485
|
+
:device => volume.device)
|
486
|
+
redirect(storage_volume_url(params[:id]))
|
487
|
+
end
|
488
|
+
end
|
374
489
|
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
haml :"storage_volumes/show"
|
383
|
-
end
|
384
|
-
format.html do
|
385
|
-
redirect storage_volume_url(volume.id)
|
386
|
-
end
|
387
|
-
end
|
490
|
+
operation :destroy do
|
491
|
+
description "Destroy storage volume"
|
492
|
+
with_capability :destroy_storage_volume
|
493
|
+
param :id, :string, :optional
|
494
|
+
control do
|
495
|
+
driver.destroy_storage_volume(credentials, params)
|
496
|
+
redirect(storage_volumes_url)
|
388
497
|
end
|
389
498
|
end
|
390
499
|
|
@@ -401,6 +510,7 @@ collection :keys do
|
|
401
510
|
|
402
511
|
operation :index do
|
403
512
|
description "List all available credentials which could be used for instance authentication."
|
513
|
+
with_capability :keys
|
404
514
|
control do
|
405
515
|
filter_all :keys
|
406
516
|
end
|
@@ -408,18 +518,16 @@ collection :keys do
|
|
408
518
|
|
409
519
|
operation :show do
|
410
520
|
description "Show details about given instance credential."
|
521
|
+
with_capability :key
|
411
522
|
param :id, :string, :required
|
412
523
|
control { show :key }
|
413
524
|
end
|
414
525
|
|
415
526
|
operation :create do
|
416
527
|
description "Create a new instance credential if backend supports this."
|
528
|
+
with_capability :create_key
|
417
529
|
param :name, :string, :required
|
418
530
|
control do
|
419
|
-
unless driver.respond_to?(:create_key)
|
420
|
-
raise Deltacloud::BackendFeatureUnsupported.new('501',
|
421
|
-
'Creating instance credentials is not supported in backend')
|
422
|
-
end
|
423
531
|
@key = driver.create_key(credentials, { :key_name => params[:name] })
|
424
532
|
respond_to do |format|
|
425
533
|
format.html { haml :"keys/show" }
|
@@ -430,12 +538,9 @@ collection :keys do
|
|
430
538
|
|
431
539
|
operation :destroy do
|
432
540
|
description "Destroy given instance credential if backend supports this."
|
541
|
+
with_capability :destroy_key
|
433
542
|
param :id, :string, :required
|
434
543
|
control do
|
435
|
-
unless driver.respond_to?(:destroy_key)
|
436
|
-
raise Deltacloud::BackendFeatureUnsupported.new('501',
|
437
|
-
'Creating instance credentials is not supported in backend')
|
438
|
-
end
|
439
544
|
driver.destroy_key(credentials, { :key_name => params[:id]})
|
440
545
|
redirect(keys_url)
|
441
546
|
end
|
@@ -443,6 +548,35 @@ collection :keys do
|
|
443
548
|
|
444
549
|
end
|
445
550
|
|
551
|
+
#get html form for creating a new blob
|
552
|
+
get '/api/buckets/:bucket/new_blob' do
|
553
|
+
@bucket_id = params[:bucket]
|
554
|
+
respond_to do |format|
|
555
|
+
format.html {haml :"blobs/new"}
|
556
|
+
end
|
557
|
+
end
|
558
|
+
|
559
|
+
#create a new blob
|
560
|
+
post '/api/buckets/:bucket' do
|
561
|
+
bucket_id = params[:bucket]
|
562
|
+
blob_id = params['blob_id']
|
563
|
+
blob_data = params['blob_data']
|
564
|
+
@blob = driver.create_blob(credentials, bucket_id, blob_id, blob_data )
|
565
|
+
respond_to do |format|
|
566
|
+
format.html { haml :"blobs/show"}
|
567
|
+
format.xml { haml :"blobs/show" }
|
568
|
+
end
|
569
|
+
end
|
570
|
+
|
571
|
+
#delete a blob
|
572
|
+
delete '/api/buckets/:bucket/:blob' do
|
573
|
+
bucket_id = params[:bucket]
|
574
|
+
blob_id = params[:blob]
|
575
|
+
driver.delete_blob(credentials, bucket_id, blob_id)
|
576
|
+
redirect(bucket_url(bucket_id))
|
577
|
+
end
|
578
|
+
|
579
|
+
#Get a particular blob's particulars (not actual blob data)
|
446
580
|
get '/api/buckets/:bucket/:blob' do
|
447
581
|
@blob = driver.blob(credentials, { :id => params[:blob], 'bucket' => params[:bucket]})
|
448
582
|
if @blob
|
@@ -456,13 +590,7 @@ get '/api/buckets/:bucket/:blob' do
|
|
456
590
|
end
|
457
591
|
end
|
458
592
|
|
459
|
-
get
|
460
|
-
respond_to do |format|
|
461
|
-
format.html { haml :"buckets/new" }
|
462
|
-
end
|
463
|
-
end
|
464
|
-
|
465
|
-
|
593
|
+
#get the content of a particular blob
|
466
594
|
get '/api/buckets/:bucket/:blob/content' do
|
467
595
|
@blob = driver.blob(credentials, { :id => params[:blob], 'bucket' => params[:bucket]})
|
468
596
|
params['content_length'] = @blob.content_length
|
@@ -470,11 +598,19 @@ get '/api/buckets/:bucket/:blob/content' do
|
|
470
598
|
BlobStream.call(env, credentials, params)
|
471
599
|
end
|
472
600
|
|
601
|
+
#Get html form for creating a new bucket
|
602
|
+
get '/api/buckets/new' do
|
603
|
+
respond_to do |format|
|
604
|
+
format.html { haml :"buckets/new" }
|
605
|
+
end
|
606
|
+
end
|
607
|
+
|
473
608
|
collection :buckets do
|
474
609
|
description "Cloud Storage buckets - aka buckets|directories|folders"
|
475
610
|
|
476
611
|
operation :index do
|
477
612
|
description "List buckets associated with this account"
|
613
|
+
with_capability :buckets
|
478
614
|
param :id, :string
|
479
615
|
param :name, :string
|
480
616
|
param :size, :string
|
@@ -483,12 +619,14 @@ collection :buckets do
|
|
483
619
|
|
484
620
|
operation :show do
|
485
621
|
description "Show bucket"
|
622
|
+
with_capability :bucket
|
486
623
|
param :id, :string
|
487
624
|
control { show(:bucket) }
|
488
625
|
end
|
489
626
|
|
490
627
|
operation :create do
|
491
628
|
description "Create a new bucket (POST /api/buckets)"
|
629
|
+
with_capability :create_bucket
|
492
630
|
param :name, :string, :required
|
493
631
|
control do
|
494
632
|
@bucket = driver.create_bucket(credentials, params[:name], params)
|
@@ -508,6 +646,7 @@ collection :buckets do
|
|
508
646
|
|
509
647
|
operation :destroy do
|
510
648
|
description "Delete a bucket by name - bucket must be empty"
|
649
|
+
with_capability :delete_bucket
|
511
650
|
param :id, :string, :required
|
512
651
|
control do
|
513
652
|
driver.delete_bucket(credentials, params[:id], params)
|