deltacloud-core 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -2
- data/config/drivers/aruba.yaml +3 -3
- data/deltacloud-core.gemspec +2 -2
- data/lib/cimi/collections/address_templates.rb +1 -2
- data/lib/cimi/collections/addresses.rb +1 -2
- data/lib/cimi/collections/base.rb +1 -1
- data/lib/cimi/collections/credentials.rb +2 -3
- data/lib/cimi/collections/forwarding_group_templates.rb +1 -2
- data/lib/cimi/collections/forwarding_groups.rb +1 -2
- data/lib/cimi/collections/machine_configurations.rb +1 -2
- data/lib/cimi/collections/machine_images.rb +1 -2
- data/lib/cimi/collections/machines.rb +9 -9
- data/lib/cimi/collections/network_configurations.rb +1 -2
- data/lib/cimi/collections/network_port_configurations.rb +1 -2
- data/lib/cimi/collections/network_port_templates.rb +1 -2
- data/lib/cimi/collections/network_ports.rb +1 -2
- data/lib/cimi/collections/network_templates.rb +1 -2
- data/lib/cimi/collections/networks.rb +2 -3
- data/lib/cimi/collections/volume_configurations.rb +1 -2
- data/lib/cimi/collections/volume_images.rb +1 -2
- data/lib/cimi/collections/volumes.rb +3 -4
- data/lib/cimi/helpers/cimi_helper.rb +7 -2
- data/lib/cimi/models.rb +6 -10
- data/lib/cimi/models/base.rb +48 -35
- data/lib/cimi/models/cloud_entry_point.rb +22 -1
- data/lib/cimi/models/collection.rb +42 -5
- data/lib/cimi/models/credential.rb +1 -1
- data/lib/cimi/models/disk.rb +39 -10
- data/lib/cimi/models/machine.rb +39 -22
- data/lib/cimi/models/machine_configuration.rb +4 -5
- data/lib/cimi/models/machine_image.rb +1 -1
- data/lib/cimi/models/machine_volume.rb +1 -1
- data/lib/cimi/models/network.rb +6 -3
- data/lib/cimi/models/network_port.rb +13 -2
- data/lib/cimi/models/schema.rb +66 -5
- data/lib/cimi/models/volume.rb +17 -16
- data/lib/cimi/models/volume_configuration.rb +7 -10
- data/lib/cimi/models/volume_image.rb +1 -1
- data/lib/deltacloud/collections/base.rb +1 -1
- data/lib/deltacloud/collections/firewalls.rb +2 -2
- data/lib/deltacloud/collections/load_balancers.rb +8 -2
- data/lib/deltacloud/core_ext.rb +1 -0
- data/lib/deltacloud/core_ext/base.rb +30 -0
- data/lib/deltacloud/drivers.rb +1 -1
- data/lib/deltacloud/drivers/base_driver.rb +1 -1
- data/lib/deltacloud/drivers/condor/condor_driver.rb +1 -1
- data/lib/deltacloud/drivers/exceptions.rb +24 -14
- data/lib/deltacloud/drivers/features.rb +3 -3
- data/lib/deltacloud/drivers/fgcp/fgcp_driver.rb +163 -92
- data/lib/deltacloud/drivers/mock/data/images/img1.yml +1 -0
- data/lib/deltacloud/drivers/mock/data/images/img2.yml +1 -0
- data/lib/deltacloud/drivers/mock/data/images/img3.yml +1 -0
- data/lib/deltacloud/drivers/mock/mock_client.rb +4 -4
- data/lib/deltacloud/drivers/mock/mock_driver.rb +16 -16
- data/lib/deltacloud/drivers/openstack/openstack_driver.rb +25 -9
- data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +2 -1
- data/lib/deltacloud/drivers/terremark/terremark_driver.rb +1 -1
- data/lib/deltacloud/drivers/vsphere/vsphere_driver.rb +2 -0
- data/lib/deltacloud/helpers/deltacloud_helper.rb +29 -8
- data/lib/deltacloud/models/image.rb +1 -0
- data/lib/deltacloud/models/instance_profile.rb +4 -0
- data/lib/deltacloud/version.rb +1 -1
- data/lib/ec2/query_parser.rb +1 -1
- data/lib/sinatra/rack_accept.rb +5 -1
- data/lib/sinatra/rack_logger.rb +9 -2
- data/tests/cimi/collections/machine_images_test.rb +23 -6
- data/tests/cimi/collections/machines_test.rb +39 -0
- data/tests/cimi/model/collection_spec.rb +109 -0
- data/tests/cimi/{spec/cimi/model → model}/credential_spec.rb +1 -1
- data/tests/cimi/{spec/cimi/model → model}/machine_configuration_spec.rb +1 -1
- data/tests/cimi/{spec/cimi/model → model}/machine_image_spec.rb +1 -1
- data/tests/cimi/{spec/cimi/model → model}/machine_spec.rb +1 -1
- data/tests/cimi/{spec/cimi/model → model}/machine_template_spec.rb +1 -1
- data/tests/cimi/{spec/cimi/model → model}/schema_spec.rb +1 -1
- data/tests/cimi/{spec/cimi/model → model}/volume_configuration_spec.rb +1 -1
- data/tests/cimi/{spec/cimi/model → model}/volume_image_spec.rb +1 -1
- data/tests/cimi/{spec/cimi/model → model}/volume_spec.rb +1 -1
- data/tests/cimi/{spec/cimi/model → model}/volume_template_spec.rb +1 -1
- data/tests/cimi/{spec/spec_helper.rb → spec_helper.rb} +7 -4
- data/tests/drivers/base/exceptions_test.rb +8 -8
- data/tests/drivers/ec2/buckets_test.rb +1 -1
- data/tests/drivers/ec2/images_test.rb +1 -1
- data/tests/drivers/ec2/instance_test.rb +1 -1
- data/tests/drivers/ec2/keys_test.rb +2 -2
- data/tests/drivers/ec2/realms_test.rb +1 -1
- data/tests/drivers/ec2/storage_snapshots_test.rb +1 -1
- data/tests/drivers/gogrid/hardware_profiles_test.rb +1 -1
- data/tests/drivers/gogrid/images_test.rb +1 -1
- data/tests/drivers/gogrid/instances_test.rb +1 -1
- data/tests/drivers/gogrid/realms_test.rb +1 -1
- data/tests/drivers/mock/images_test.rb +7 -2
- data/tests/drivers/mock/instances_test.rb +1 -1
- data/tests/drivers/mock/keys_test.rb +2 -2
- data/tests/drivers/mock/realms_test.rb +1 -1
- data/tests/drivers/mock/storage_snapshots_test.rb +1 -1
- data/tests/drivers/mock/storage_volumes_test.rb +1 -1
- data/tests/drivers/openstack/hardware_profiles_test.rb +3 -3
- data/tests/drivers/openstack/images_test.rb +1 -1
- data/tests/drivers/openstack/instances_test.rb +1 -1
- data/tests/drivers/openstack/keys_test.rb +2 -2
- data/tests/drivers/openstack/realms_test.rb +1 -1
- data/tests/drivers/rhevm/common.rb +3 -3
- data/tests/drivers/rhevm/images_test.rb +13 -13
- data/tests/drivers/rhevm/instance_test.rb +22 -22
- data/tests/drivers/rhevm/provider_test.rb +3 -3
- data/tests/drivers/rhevm/realms_test.rb +7 -7
- data/tests/test_helper.rb +0 -5
- data/views/api/show.xml.haml +6 -3
- data/views/errors/401.html.haml +0 -16
- data/views/errors/404.html.haml +2 -3
- data/views/errors/500.html.haml +6 -5
- data/views/images/show.html.haml +5 -1
- data/views/images/show.xml.haml +8 -3
- data/views/instances/new.html.haml +1 -1
- data/views/instances/show.xml.haml +1 -1
- data/views/load_balancers/show.html.haml +1 -1
- metadata +761 -778
- data/lib/cimi/models/disk_collection.rb +0 -37
- data/lib/cimi/models/machine_volume_collection.rb +0 -34
- data/lib/cimi/models/network_port_collection.rb +0 -51
- data/lib/cimi/models/network_port_configuration_collection.rb +0 -35
- data/lib/cimi/models/network_port_template_collection.rb +0 -37
@@ -56,10 +56,10 @@ module Deltacloud::Drivers::Mock
|
|
56
56
|
files(collection).map { |f| File::basename(f, ".yml") }
|
57
57
|
end
|
58
58
|
|
59
|
-
def
|
59
|
+
def load_collection(collection, id)
|
60
60
|
fname = file(collection, id)
|
61
61
|
begin
|
62
|
-
YAML.
|
62
|
+
YAML.load_file(fname)
|
63
63
|
rescue Errno::ENOENT
|
64
64
|
nil
|
65
65
|
end
|
@@ -73,12 +73,12 @@ module Deltacloud::Drivers::Mock
|
|
73
73
|
# Return the object with id +id+ of class +klass+ from the collection
|
74
74
|
# derived from the classes name
|
75
75
|
def build(klass, id)
|
76
|
-
klass.new(
|
76
|
+
klass.new(load_collection(collection_name(klass), id))
|
77
77
|
end
|
78
78
|
|
79
79
|
# Return an array of hashes of all the resources in the collection
|
80
80
|
def load_all(collection)
|
81
|
-
members(collection).map { |id|
|
81
|
+
members(collection).map { |id| load_collection(collection, id) }
|
82
82
|
end
|
83
83
|
|
84
84
|
# Return an array of model objects of the resources in the collection
|
@@ -158,7 +158,7 @@ module Deltacloud::Drivers::Mock
|
|
158
158
|
|
159
159
|
def instance(credentials, opts={})
|
160
160
|
check_credentials( credentials )
|
161
|
-
if instance = @client.
|
161
|
+
if instance = @client.load_collection(:instances, opts[:id])
|
162
162
|
Instance.new(instance)
|
163
163
|
end
|
164
164
|
end
|
@@ -217,7 +217,7 @@ module Deltacloud::Drivers::Mock
|
|
217
217
|
end
|
218
218
|
|
219
219
|
def update_instance_state(credentials, id, state)
|
220
|
-
instance = @client.
|
220
|
+
instance = @client.load_collection(:instances, id)
|
221
221
|
instance[:state] = state
|
222
222
|
instance[:actions] = instance_actions_for( instance[:state] )
|
223
223
|
@client.store(:instances, instance)
|
@@ -325,7 +325,7 @@ module Deltacloud::Drivers::Mock
|
|
325
325
|
:pem_rsa_key => Key::generate_mock_pem
|
326
326
|
}
|
327
327
|
safely do
|
328
|
-
raise "KeyExist" if @client.
|
328
|
+
raise "KeyExist" if @client.load_collection(:keys, key_hash[:id])
|
329
329
|
@client.store(:keys, key_hash)
|
330
330
|
end
|
331
331
|
return Key.new(key_hash)
|
@@ -351,16 +351,16 @@ module Deltacloud::Drivers::Mock
|
|
351
351
|
|
352
352
|
def destroy_address(credentials, opts={})
|
353
353
|
check_credentials(credentials)
|
354
|
-
address = @client.
|
354
|
+
address = @client.load_collection(:addresses, opts[:id])
|
355
355
|
raise "AddressInUse" unless address[:instance_id].nil?
|
356
356
|
@client.destroy(:addresses, opts[:id])
|
357
357
|
end
|
358
358
|
|
359
359
|
def associate_address(credentials, opts={})
|
360
360
|
check_credentials(credentials)
|
361
|
-
address = @client.
|
361
|
+
address = @client.load_collection(:addresses, opts[:id])
|
362
362
|
raise "AddressInUse" unless address[:instance_id].nil?
|
363
|
-
instance = @client.
|
363
|
+
instance = @client.load_collection(:instances, opts[:instance_id])
|
364
364
|
address[:instance_id] = instance[:id]
|
365
365
|
instance[:public_addresses] = [InstanceAddress.new(address[:id])]
|
366
366
|
@client.store(:addresses, address)
|
@@ -369,9 +369,9 @@ module Deltacloud::Drivers::Mock
|
|
369
369
|
|
370
370
|
def disassociate_address(credentials, opts={})
|
371
371
|
check_credentials(credentials)
|
372
|
-
address = @client.
|
372
|
+
address = @client.load_collection(:addresses, opts[:id])
|
373
373
|
raise "AddressNotInUse" unless address[:instance_id]
|
374
|
-
instance = @client.
|
374
|
+
instance = @client.load_collection(:instances, address[:instance_id])
|
375
375
|
address[:instance_id] = nil
|
376
376
|
instance[:public_addresses] = [InstanceAddress.new("#{instance[:image_id]}.#{instance[:id]}.public.com", :type => :hostname)]
|
377
377
|
@client.store(:addresses, address)
|
@@ -434,7 +434,7 @@ module Deltacloud::Drivers::Mock
|
|
434
434
|
#--
|
435
435
|
def blob_data(credentials, bucket_id, blob_id, opts = {})
|
436
436
|
check_credentials(credentials)
|
437
|
-
if blob = @client.
|
437
|
+
if blob = @client.load_collection(:blobs, blob_id)
|
438
438
|
#give event machine a chance
|
439
439
|
sleep 1
|
440
440
|
blob[:content].split('').each {|part| yield part}
|
@@ -478,7 +478,7 @@ module Deltacloud::Drivers::Mock
|
|
478
478
|
def delete_blob(credentials, bucket_id, blob_id, opts={})
|
479
479
|
check_credentials(credentials)
|
480
480
|
safely do
|
481
|
-
raise "NotExistentBlob" unless @client.
|
481
|
+
raise "NotExistentBlob" unless @client.load_collection(:blobs, blob_id)
|
482
482
|
@client.destroy(:blobs, blob_id)
|
483
483
|
end
|
484
484
|
end
|
@@ -488,7 +488,7 @@ module Deltacloud::Drivers::Mock
|
|
488
488
|
#--
|
489
489
|
def blob_metadata(credentials, opts={})
|
490
490
|
check_credentials(credentials)
|
491
|
-
if blob = @client.
|
491
|
+
if blob = @client.load_collection(:blobs, opts[:id])
|
492
492
|
blob[:user_metadata]
|
493
493
|
else
|
494
494
|
nil
|
@@ -501,7 +501,7 @@ module Deltacloud::Drivers::Mock
|
|
501
501
|
def update_blob_metadata(credentials, opts={})
|
502
502
|
check_credentials(credentials)
|
503
503
|
safely do
|
504
|
-
blob = @client.
|
504
|
+
blob = @client.load_collection(:blobs, opts[:id])
|
505
505
|
return false unless blob
|
506
506
|
blob[:user_metadata] = BlobHelper::rename_metadata_headers(opts['meta_hash'], '')
|
507
507
|
@client.store(:blobs, blob)
|
@@ -587,8 +587,8 @@ module Deltacloud::Drivers::Mock
|
|
587
587
|
end
|
588
588
|
|
589
589
|
def attach_volume_instance(volume_id, device, instance_id)
|
590
|
-
volume = @client.
|
591
|
-
instance = @client.
|
590
|
+
volume = @client.load_collection(:storage_volumes, volume_id)
|
591
|
+
instance = @client.load_collection(:instances, instance_id)
|
592
592
|
volume[:instance_id] = instance_id
|
593
593
|
volume[:device] = device
|
594
594
|
volume[:state] = "IN-USE"
|
@@ -600,8 +600,8 @@ module Deltacloud::Drivers::Mock
|
|
600
600
|
end
|
601
601
|
|
602
602
|
def detach_volume_instance(volume_id, instance_id)
|
603
|
-
volume = @client.
|
604
|
-
instance = @client.
|
603
|
+
volume = @client.load_collection(:storage_volumes, volume_id)
|
604
|
+
instance = @client.load_collection(:instances, instance_id)
|
605
605
|
volume[:instance_id] = nil
|
606
606
|
device = volume[:device]
|
607
607
|
volume[:device] = nil
|
@@ -16,6 +16,7 @@
|
|
16
16
|
|
17
17
|
require 'openstack'
|
18
18
|
require 'tempfile'
|
19
|
+
require 'base64'
|
19
20
|
|
20
21
|
module Deltacloud
|
21
22
|
module Drivers
|
@@ -26,6 +27,7 @@ module Deltacloud
|
|
26
27
|
feature :instances, :authentication_key
|
27
28
|
feature :instances, :authentication_password
|
28
29
|
feature :instances, :user_files
|
30
|
+
feature :instances, :user_data
|
29
31
|
feature :images, :user_name
|
30
32
|
feature :keys, :import_key
|
31
33
|
|
@@ -44,8 +46,8 @@ module Deltacloud
|
|
44
46
|
#get the collections as defined by 'capability' and 'respond_to?' blocks
|
45
47
|
super_collections = super
|
46
48
|
begin
|
47
|
-
|
48
|
-
rescue Deltacloud::
|
49
|
+
new_client(credentials, :buckets)
|
50
|
+
rescue Deltacloud::Exceptions::NotImplemented #OpenStack::Exception::NotImplemented...
|
49
51
|
return super_collections - [Sinatra::Rabbit::BucketsCollection]
|
50
52
|
end
|
51
53
|
super_collections
|
@@ -110,8 +112,8 @@ module Deltacloud
|
|
110
112
|
begin
|
111
113
|
image = os.get_image(image_id)
|
112
114
|
image.delete!
|
113
|
-
rescue
|
114
|
-
raise Deltacloud::
|
115
|
+
rescue
|
116
|
+
raise Deltacloud::Exceptions.exception_from_status(500, "Cannot delete image with id #{image_id}")
|
115
117
|
end
|
116
118
|
end
|
117
119
|
|
@@ -165,13 +167,16 @@ module Deltacloud
|
|
165
167
|
params[:name] = (opts[:name] && opts[:name].length>0)? opts[:name] : "server#{Time.now.to_s}"
|
166
168
|
params[:imageRef] = image_id
|
167
169
|
params[:flavorRef] = (opts[:hwp_id] && opts[:hwp_id].length>0) ?
|
168
|
-
opts[:hwp_id] : hardware_profiles(credentials).first.
|
170
|
+
opts[:hwp_id] : hardware_profiles(credentials).first.id
|
169
171
|
if opts[:password] && opts[:password].length > 0
|
170
172
|
params[:adminPass]=opts[:password]
|
171
173
|
end
|
172
174
|
if opts[:keyname] && opts[:keyname].length > 0
|
173
175
|
params[:key_name]=opts[:keyname]
|
174
|
-
|
176
|
+
end
|
177
|
+
if opts[:user_data] && opts[:user_data].length > 0
|
178
|
+
params[:user_data]=Base64.encode64(opts[:user_data])
|
179
|
+
end
|
175
180
|
safely do
|
176
181
|
server = os.create_server(params)
|
177
182
|
result = convert_from_server(server, os.connection.authuser)
|
@@ -190,11 +195,19 @@ module Deltacloud
|
|
190
195
|
|
191
196
|
def destroy_instance(credentials, instance_id)
|
192
197
|
os = new_client(credentials)
|
198
|
+
server = instance = nil
|
193
199
|
safely do
|
194
200
|
server = os.get_server(instance_id)
|
195
201
|
server.delete!
|
196
|
-
convert_from_server(server, os.connection.authuser)
|
197
202
|
end
|
203
|
+
begin
|
204
|
+
server.populate
|
205
|
+
instance = convert_from_server(server, os.connection.authuser)
|
206
|
+
rescue OpenStack::Exception::ItemNotFound
|
207
|
+
instance = convert_from_server(server, os.connection.authuser)
|
208
|
+
instance.state = "STOPPED"
|
209
|
+
end
|
210
|
+
instance
|
198
211
|
end
|
199
212
|
|
200
213
|
alias_method :stop_instance, :destroy_instance
|
@@ -371,12 +384,14 @@ private
|
|
371
384
|
|
372
385
|
def convert_from_flavor(flavor)
|
373
386
|
op = (flavor.class == Hash)? :fetch : :send
|
374
|
-
HardwareProfile.new(flavor.send(op, :id).to_s) do
|
387
|
+
hwp = HardwareProfile.new(flavor.send(op, :id).to_s) do
|
375
388
|
architecture 'x86_64'
|
376
389
|
memory flavor.send(op, :ram).to_i
|
377
390
|
storage flavor.send(op, :disk).to_i
|
378
391
|
cpu flavor.send(op, :vcpus).to_i
|
379
392
|
end
|
393
|
+
hwp.name = flavor.send(op, :name)
|
394
|
+
return hwp
|
380
395
|
end
|
381
396
|
|
382
397
|
def convert_from_image(image, owner)
|
@@ -387,7 +402,8 @@ private
|
|
387
402
|
:description => image.send(op, :name),
|
388
403
|
:owner_id => owner,
|
389
404
|
:state => image.send(op, :status),
|
390
|
-
:architecture => 'x86_64'
|
405
|
+
:architecture => 'x86_64',
|
406
|
+
:creation_time => image.send(op, :created)
|
391
407
|
})
|
392
408
|
end
|
393
409
|
|
@@ -309,7 +309,8 @@ class RhevmDriver < Deltacloud::BaseDriver
|
|
309
309
|
:owner_id => client.credentials[:username],
|
310
310
|
:architecture => 'x86_64', # All RHEV-M VMs are x86_64
|
311
311
|
:hardware_profiles => hardware_profiles(nil),
|
312
|
-
:state => img.status.strip.upcase
|
312
|
+
:state => img.status.gsub('\\', '').strip.upcase,
|
313
|
+
:creation_time => img.creation_time
|
313
314
|
)
|
314
315
|
end
|
315
316
|
|
@@ -139,7 +139,7 @@ VAPP_STATE_MAP = { "0" => "PENDING", "1" => "PENDING", "2" => "STOPPED", "4"
|
|
139
139
|
end
|
140
140
|
unless ( (terremark_hwp.include?(:cpu, opts[:hwp_cpu].to_i)) &&
|
141
141
|
(terremark_hwp.include?(:memory, opts[:hwp_memory].to_i)) ) then
|
142
|
-
raise Deltacloud::
|
142
|
+
raise Deltacloud::Exceptions::ValidationFailure.new(
|
143
143
|
StandardError.new("Error with cpu and/or memory values. you said cpu->#{opts[:hwp_cpu]} and mem->#{opts[:hwp_memory]}")
|
144
144
|
)
|
145
145
|
end
|
@@ -104,6 +104,7 @@ module Deltacloud::Drivers::Vsphere
|
|
104
104
|
:owner_id => credentials.user,
|
105
105
|
:description => properties[:full_name],
|
106
106
|
:state => image_state,
|
107
|
+
:creation_time => image.storage[:timestamp],
|
107
108
|
:hardware_profiles => profiles
|
108
109
|
)
|
109
110
|
end
|
@@ -194,6 +195,7 @@ module Deltacloud::Drivers::Vsphere
|
|
194
195
|
:private_addresses => [],
|
195
196
|
:instance_profile => instance_profile,
|
196
197
|
:actions => instance_actions_for( instance_state ),
|
198
|
+
:launch_time => vm.runtime.props[:bootTime],
|
197
199
|
:create_image => true
|
198
200
|
)
|
199
201
|
end
|
@@ -18,6 +18,10 @@ module Deltacloud::Helpers
|
|
18
18
|
|
19
19
|
require 'benchmark'
|
20
20
|
|
21
|
+
def request_headers
|
22
|
+
env.inject({}){|acc, (k,v)| acc[$1.downcase] = v if k =~ /^http_(.*)/i; acc}
|
23
|
+
end
|
24
|
+
|
21
25
|
def auth_feature_name
|
22
26
|
return 'key' if driver.class.has_feature?(:instances, :authentication_key)
|
23
27
|
return 'password' if driver.class.has_feature?(:instances, :authentication_password)
|
@@ -77,15 +81,32 @@ module Deltacloud::Helpers
|
|
77
81
|
end
|
78
82
|
end
|
79
83
|
|
84
|
+
# Log errors to the same logger as we use for logging requests
|
85
|
+
def log
|
86
|
+
Deltacloud::Exceptions.logger(Deltacloud.default_frontend.logger)
|
87
|
+
end
|
88
|
+
|
80
89
|
def report_error(code=nil)
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
90
|
+
|
91
|
+
if !code.nil?
|
92
|
+
@error = Deltacloud::Exceptions.exception_from_status(code, translate_error_code(code)[:message])
|
93
|
+
@code = code
|
94
|
+
message = @error.message
|
95
|
+
else
|
96
|
+
@error = request.env['sinatra.error'] || @exception
|
97
|
+
@code = @error.respond_to?(:code) ? @error.code : 500
|
98
|
+
message = @error.respond_to?(:message) ? @error.message : translate_error_code(code)[:message]
|
99
|
+
end
|
100
|
+
|
101
|
+
response.status = @code
|
102
|
+
|
86
103
|
backtrace = (@error.respond_to?(:backtrace) and !@error.backtrace.nil?) ?
|
87
104
|
"\n\n#{@error.backtrace[0..10].join("\n")}\n\n" : ''
|
88
|
-
|
105
|
+
|
106
|
+
if @code.to_s =~ /5(\d+)/
|
107
|
+
log.error(@code.to_s) { "[#{@error.class.to_s}] #{message}#{backtrace}" }
|
108
|
+
end
|
109
|
+
|
89
110
|
respond_to do |format|
|
90
111
|
format.xml { haml :"errors/#{@code || @error.code}", :layout => false }
|
91
112
|
format.json { xml_to_json("errors/#{@code || @error.code}") }
|
@@ -307,11 +328,11 @@ module Deltacloud::Helpers
|
|
307
328
|
end
|
308
329
|
|
309
330
|
def bt(trace)
|
331
|
+
return [] unless trace
|
310
332
|
return trace.join("\n") if params['fulltrace']
|
311
333
|
app_path = File::expand_path("../../..", __FILE__)
|
312
334
|
dots = false
|
313
|
-
|
314
|
-
trace = trace.map { |t| t.match(%r{^#{app_path}(.*)$}) ? "$app#{$1}" : "..." }.select do |t|
|
335
|
+
trace = trace.map { |t| t.match(%r{^#{app_path}(.*)$}) ? "$app#{$1}" : "..." }.select do |t|
|
315
336
|
if t == "..."
|
316
337
|
keep = ! dots
|
317
338
|
dots = true
|
data/lib/deltacloud/version.rb
CHANGED
data/lib/ec2/query_parser.rb
CHANGED
@@ -24,7 +24,7 @@ module Deltacloud::EC2
|
|
24
24
|
:describe_key_pairs => { :method => :keys, :params => {} },
|
25
25
|
:create_key_pair => { :method => :create_key, :params => { 'KeyName' => :key_name }},
|
26
26
|
:delete_key_pair => { :method => :destroy_key, :params => { 'KeyName' => :id }},
|
27
|
-
:run_instances => { :method => :create_instance, :params => { 'ImageId' => :image_id, 'InstanceType' => :hwp_id, 'Placement.AvailabilityZone' => :realm_id }},
|
27
|
+
:run_instances => { :method => :create_instance, :params => { 'ImageId' => :image_id, 'InstanceType' => :hwp_id, 'Placement.AvailabilityZone' => :realm_id, 'UserData' => :user_data }},
|
28
28
|
:stop_instances => { :method => :stop_instance, :params => { 'InstanceId.1' => :id }},
|
29
29
|
:start_instances => { :method => :start_instance, :params => { 'InstanceId.1' => :id }},
|
30
30
|
:reboot_instances => { :method => :reboot_instance, :params => { 'InstanceId.1' => :id }},
|
data/lib/sinatra/rack_accept.rb
CHANGED
@@ -79,7 +79,11 @@ module Rack
|
|
79
79
|
end
|
80
80
|
yield wants
|
81
81
|
|
82
|
-
if Deltacloud.default_frontend.name == :cimi
|
82
|
+
if request.env["SCRIPT_NAME"].include?("cimi") || Deltacloud.default_frontend.name == :cimi
|
83
|
+
#when cimi and neither json or xml defined... default to _something_ - json?
|
84
|
+
if ([:json, :xml] & accepting_formats.keys).empty?
|
85
|
+
request.env['rack-accept.formats'] = {:json=>0}
|
86
|
+
end
|
83
87
|
@media_type = (accepting_formats.has_key?(:xml) ? [:xml, accepting_formats[:xml]] : nil)
|
84
88
|
end if Deltacloud.respond_to? :default_frontend
|
85
89
|
|
data/lib/sinatra/rack_logger.rb
CHANGED
@@ -50,6 +50,11 @@ module Rack
|
|
50
50
|
self
|
51
51
|
end
|
52
52
|
|
53
|
+
def self.error(code, &block)
|
54
|
+
@logger ||= ::Logger.new(log_path || $stdout)
|
55
|
+
@logger.error(code, &block)
|
56
|
+
end
|
57
|
+
|
53
58
|
# Common Log Format: http://httpd.apache.org/docs/1.3/logs.html#common
|
54
59
|
# lilith.local - - [07/Aug/2006 23:58:02] "GET / HTTP/1.1" 500 -
|
55
60
|
# %{%s - %s [%s] "%s %s%s %s" %d %s\n} %
|
@@ -84,7 +89,8 @@ module Rack
|
|
84
89
|
params = env['rack.request.form_hash'].nil? ? '' : ' '+env['rack.request.form_hash'].to_json
|
85
90
|
|
86
91
|
logger = @logger || env['rack.errors']
|
87
|
-
logger
|
92
|
+
logger_method = logger.respond_to?(:info) ? :info : :puts
|
93
|
+
logger.send logger_method, VERBOSE_FORMAT % [
|
88
94
|
env['HTTP_X_FORWARDED_FOR'] || env["REMOTE_ADDR"] || "-",
|
89
95
|
env["REMOTE_USER"] || "-",
|
90
96
|
now.strftime("%d/%b/%Y %H:%M:%S"),
|
@@ -105,7 +111,8 @@ module Rack
|
|
105
111
|
length = extract_content_length(header)
|
106
112
|
|
107
113
|
logger = @logger || env['rack.errors']
|
108
|
-
logger
|
114
|
+
logger_method = logger.respond_to?(:info) ? :info : :puts
|
115
|
+
logger.send logger_method, FORMAT % [
|
109
116
|
env['HTTP_X_FORWARDED_FOR'] || env["REMOTE_ADDR"] || "-",
|
110
117
|
env["REMOTE_USER"] || "-",
|
111
118
|
now.strftime("%d/%b/%Y %H:%M:%S"),
|
@@ -33,12 +33,29 @@ describe CIMI::Collections::MachineImages do
|
|
33
33
|
xml.root.name.must_equal 'MachineImage'
|
34
34
|
end
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
describe "filtering with $select" do
|
37
|
+
def machines(*select)
|
38
|
+
url = "/machine_images"
|
39
|
+
url += "?$select=#{select.join(",")}" unless select.empty?
|
40
|
+
get root_url url
|
41
|
+
status.must_equal 200
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should filter collection members' do
|
45
|
+
machines :description
|
46
|
+
(xml/'id').wont_be_empty
|
47
|
+
nimages = (xml/'MachineImage').size
|
48
|
+
(xml/'MachineImage/description').size.must_equal nimages
|
49
|
+
(xml/'MachineImage/id').must_be_empty
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should filter by multiple attributes' do
|
53
|
+
machines :description, :id
|
54
|
+
(xml/'id').wont_be_empty
|
55
|
+
nimages = (xml/'MachineImage').size
|
56
|
+
(xml/'MachineImage/description').size.must_equal nimages
|
57
|
+
(xml/'MachineImage/id').size.must_equal nimages
|
58
|
+
end
|
42
59
|
end
|
43
60
|
|
44
61
|
end
|