deltacloud-core 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/deltacloud-core.gemspec +4 -7
- data/lib/cimi/collections/address_templates.rb +4 -42
- data/lib/cimi/collections/addresses.rb +5 -43
- data/lib/cimi/collections/base.rb +11 -3
- data/lib/cimi/collections/cloud_entry_point.rb +1 -1
- data/lib/cimi/collections/credentials.rb +4 -43
- data/lib/cimi/collections/forwarding_group_templates.rb +2 -20
- data/lib/cimi/collections/forwarding_groups.rb +2 -21
- data/lib/cimi/collections/machine_configurations.rb +2 -20
- data/lib/cimi/collections/machine_images.rb +4 -42
- data/lib/cimi/collections/machine_templates.rb +4 -42
- data/lib/cimi/collections/machines.rb +14 -64
- data/lib/cimi/collections/network_configurations.rb +2 -20
- data/lib/cimi/collections/network_port_configurations.rb +2 -21
- data/lib/cimi/collections/network_port_templates.rb +2 -23
- data/lib/cimi/collections/network_ports.rb +6 -46
- data/lib/cimi/collections/network_templates.rb +2 -21
- data/lib/cimi/collections/networks.rb +4 -40
- data/lib/cimi/collections/resource_metadata.rb +2 -21
- data/lib/cimi/collections/system_templates.rb +4 -45
- data/lib/cimi/collections/systems.rb +65 -82
- data/lib/cimi/collections/volume_configurations.rb +4 -45
- data/lib/cimi/collections/volume_images.rb +4 -42
- data/lib/cimi/collections/volume_templates.rb +5 -44
- data/lib/cimi/collections/volumes.rb +4 -48
- data/lib/cimi/helpers.rb +1 -0
- data/lib/cimi/helpers/cimi_helper.rb +1 -1
- data/lib/cimi/helpers/cimi_rabbit_helper.rb +113 -0
- data/lib/cimi/helpers/database_helper.rb +1 -2
- data/lib/cimi/models.rb +12 -11
- data/lib/cimi/models/action.rb +0 -4
- data/lib/cimi/models/address.rb +0 -38
- data/lib/cimi/models/address_create.rb +0 -31
- data/lib/cimi/models/address_template.rb +0 -47
- data/lib/cimi/models/address_template_create.rb +0 -16
- data/lib/cimi/models/base.rb +2 -74
- data/lib/cimi/models/cloud_entry_point.rb +2 -30
- data/lib/cimi/models/collection.rb +8 -25
- data/lib/cimi/models/credential.rb +0 -34
- data/lib/cimi/models/credential_create.rb +0 -26
- data/lib/cimi/models/credential_template.rb +0 -2
- data/lib/cimi/models/disk.rb +0 -56
- data/lib/cimi/models/forwarding_group.rb +0 -8
- data/lib/cimi/models/forwarding_group_template.rb +0 -8
- data/lib/cimi/models/machine.rb +4 -129
- data/lib/cimi/models/machine_configuration.rb +0 -31
- data/lib/cimi/models/machine_create.rb +1 -29
- data/lib/cimi/models/machine_image.rb +0 -28
- data/lib/cimi/models/machine_image_create.rb +0 -19
- data/lib/cimi/models/machine_template.rb +5 -39
- data/lib/cimi/models/machine_template_create.rb +0 -12
- data/lib/cimi/models/machine_volume.rb +0 -65
- data/lib/cimi/models/network.rb +0 -32
- data/lib/cimi/models/network_configuration.rb +0 -15
- data/lib/cimi/models/network_create.rb +0 -23
- data/lib/cimi/models/network_port.rb +0 -73
- data/lib/cimi/models/network_port_configuration.rb +0 -8
- data/lib/cimi/models/network_port_template.rb +0 -8
- data/lib/cimi/models/network_template.rb +2 -12
- data/lib/cimi/models/resource.rb +0 -6
- data/lib/cimi/models/resource_metadata.rb +1 -95
- data/lib/cimi/models/schema.rb +28 -32
- data/lib/cimi/models/system.rb +15 -39
- data/lib/cimi/models/system_address.rb +26 -0
- data/lib/cimi/models/system_create.rb +20 -0
- data/lib/cimi/models/system_credential.rb +26 -0
- data/lib/cimi/models/system_forwarding_group.rb +26 -0
- data/lib/cimi/models/system_machine.rb +26 -0
- data/lib/cimi/models/system_network.rb +26 -0
- data/lib/cimi/models/system_network_port.rb +26 -0
- data/lib/cimi/models/system_system.rb +26 -0
- data/lib/cimi/models/system_template.rb +15 -31
- data/lib/cimi/models/system_volume.rb +26 -0
- data/lib/cimi/models/volume.rb +0 -59
- data/lib/cimi/models/volume_configuration.rb +1 -64
- data/lib/cimi/models/volume_configuration_create.rb +22 -0
- data/lib/cimi/models/volume_create.rb +0 -38
- data/lib/cimi/models/volume_image.rb +0 -30
- data/lib/cimi/models/volume_image_create.rb +0 -25
- data/lib/cimi/models/volume_template.rb +2 -43
- data/lib/cimi/models/volume_template_create.rb +0 -12
- data/lib/cimi/service.rb +82 -0
- data/lib/cimi/service/action.rb +21 -0
- data/lib/cimi/service/address.rb +56 -0
- data/lib/cimi/service/address_create.rb +45 -0
- data/lib/cimi/service/address_template.rb +71 -0
- data/lib/cimi/service/address_template_create.rb +34 -0
- data/lib/cimi/service/base.rb +266 -0
- data/lib/cimi/service/cloud_entry_point.rb +53 -0
- data/lib/cimi/service/credential.rb +52 -0
- data/lib/cimi/service/credential_create.rb +38 -0
- data/lib/cimi/service/credential_template.rb +20 -0
- data/lib/cimi/service/disk.rb +75 -0
- data/lib/cimi/service/forwarding_group.rb +26 -0
- data/lib/cimi/service/forwarding_group_template.rb +26 -0
- data/lib/cimi/service/machine.rb +154 -0
- data/lib/cimi/service/machine_configuration.rb +54 -0
- data/lib/cimi/service/machine_create.rb +49 -0
- data/lib/cimi/service/machine_image.rb +47 -0
- data/lib/cimi/service/machine_image_create.rb +35 -0
- data/lib/cimi/service/machine_template.rb +61 -0
- data/lib/cimi/service/machine_template_create.rb +29 -0
- data/lib/cimi/service/machine_volume.rb +74 -0
- data/lib/cimi/service/network.rb +51 -0
- data/lib/cimi/service/network_configuration.rb +36 -0
- data/lib/cimi/service/network_create.rb +39 -0
- data/lib/cimi/service/network_port.rb +97 -0
- data/lib/cimi/service/network_port_configuration.rb +26 -0
- data/lib/cimi/service/network_port_template.rb +26 -0
- data/lib/cimi/service/network_template.rb +28 -0
- data/lib/cimi/service/resource_metadata.rb +44 -0
- data/lib/cimi/service/system.rb +45 -0
- data/lib/cimi/service/system_address.rb +34 -0
- data/lib/cimi/service/system_create.rb +39 -0
- data/lib/cimi/service/system_credential.rb +34 -0
- data/lib/cimi/service/system_forwarding_group.rb +34 -0
- data/lib/cimi/service/system_machine.rb +34 -0
- data/lib/cimi/service/system_network.rb +34 -0
- data/lib/cimi/service/system_network_port.rb +34 -0
- data/lib/cimi/service/system_system.rb +34 -0
- data/lib/cimi/service/system_template.rb +32 -0
- data/lib/cimi/service/system_volume.rb +34 -0
- data/lib/cimi/service/volume.rb +81 -0
- data/lib/cimi/service/volume_configuration.rb +92 -0
- data/lib/cimi/service/volume_configuration_create.rb +29 -0
- data/lib/cimi/service/volume_create.rb +47 -0
- data/lib/cimi/service/volume_image.rb +44 -0
- data/lib/cimi/service/volume_image_create.rb +42 -0
- data/lib/cimi/service/volume_template.rb +61 -0
- data/lib/cimi/service/volume_template_create.rb +29 -0
- data/lib/db/entity.rb +16 -1
- data/lib/deltacloud/collections/addresses.rb +2 -2
- data/lib/deltacloud/collections/buckets.rb +16 -18
- data/lib/deltacloud/collections/drivers.rb +4 -4
- data/lib/deltacloud/collections/firewalls.rb +5 -5
- data/lib/deltacloud/collections/images.rb +3 -3
- data/lib/deltacloud/collections/instance_states.rb +4 -4
- data/lib/deltacloud/collections/instances.rb +22 -13
- data/lib/deltacloud/collections/keys.rb +2 -2
- data/lib/deltacloud/collections/load_balancers.rb +16 -13
- data/lib/deltacloud/collections/storage_snapshots.rb +3 -3
- data/lib/deltacloud/collections/storage_volumes.rb +5 -5
- data/lib/deltacloud/core_ext/ordered_hash.rb +0 -4
- data/lib/deltacloud/drivers/fgcp/fgcp_client.rb +8 -0
- data/lib/deltacloud/drivers/fgcp/fgcp_driver.rb +4 -3
- data/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb +266 -19
- data/lib/deltacloud/drivers/google/google_driver.rb +6 -0
- data/lib/deltacloud/drivers/mock/mock_driver.rb +2 -2
- data/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb +166 -54
- data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +2 -0
- data/lib/deltacloud/helpers/blob_stream_helper.rb +0 -2
- data/lib/deltacloud/helpers/deltacloud_helper.rb +22 -22
- data/lib/deltacloud/helpers/driver_helper.rb +4 -7
- data/lib/deltacloud/helpers/rabbit_helper.rb +5 -0
- data/lib/deltacloud/server.rb +4 -4
- data/lib/deltacloud/version.rb +1 -1
- data/lib/deltacloud_rack.rb +6 -1
- data/lib/ec2/server.rb +6 -1
- data/tests/cimi/collections/common.rb +33 -0
- data/tests/cimi/collections/machines_test.rb +19 -0
- data/tests/cimi/collections/system_templates_test.rb +47 -0
- data/tests/cimi/collections/volumes_test.rb +42 -0
- data/tests/cimi/db/database_helper_test.rb +7 -4
- data/tests/deltacloud/drivers_test.rb +1 -1
- data/tests/drivers/ec2/common.rb +4 -1
- data/tests/drivers/fgcp/common.rb +1 -2
- data/tests/drivers/gogrid/common.rb +1 -2
- data/tests/drivers/google/common.rb +1 -1
- data/tests/drivers/models/address_test.rb +2 -2
- data/tests/drivers/models/base_test.rb +2 -2
- data/tests/drivers/models/blob_test.rb +2 -2
- data/tests/drivers/models/instance_address_test.rb +8 -8
- data/tests/drivers/models/instance_profile_test.rb +2 -2
- data/tests/drivers/models/keys_test.rb +4 -4
- data/tests/drivers/models/metrics_test.rb +3 -3
- data/tests/drivers/openstack/common.rb +1 -2
- data/views/addresses/_address.html.haml +3 -3
- data/views/addresses/associate.html.haml +3 -3
- data/views/addresses/index.html.haml +2 -2
- data/views/addresses/index.xml.haml +2 -2
- data/views/addresses/show.html.haml +7 -7
- data/views/addresses/show.xml.haml +9 -9
- data/views/api/show.html.haml +2 -2
- data/views/api/show.xml.haml +1 -1
- data/views/blobs/new.html.haml +1 -1
- data/views/blobs/show.html.haml +8 -8
- data/views/blobs/show.xml.haml +7 -7
- data/views/buckets/index.html.haml +1 -1
- data/views/buckets/index.xml.haml +2 -2
- data/views/buckets/show.html.haml +7 -7
- data/views/buckets/show.xml.haml +6 -6
- data/views/drivers/index.html.haml +1 -1
- data/views/drivers/index.xml.haml +1 -1
- data/views/drivers/show.html.haml +6 -6
- data/views/drivers/show.xml.haml +5 -5
- data/views/error.html.haml +2 -2
- data/views/errors/backend_capability_failure.xml.haml +3 -3
- data/views/errors/common.html.haml +7 -7
- data/views/errors/common.xml.haml +5 -5
- data/views/firewalls/index.html.haml +1 -1
- data/views/firewalls/index.xml.haml +1 -1
- data/views/firewalls/new_rule.html.haml +1 -1
- data/views/firewalls/show.html.haml +8 -8
- data/views/firewalls/show.xml.haml +9 -9
- data/views/hardware_profiles/index.html.haml +1 -1
- data/views/hardware_profiles/index.xml.haml +2 -2
- data/views/hardware_profiles/show.html.haml +3 -3
- data/views/hardware_profiles/show.xml.haml +4 -4
- data/views/images/index.html.haml +1 -1
- data/views/images/index.xml.haml +2 -2
- data/views/images/new.html.haml +2 -2
- data/views/images/show.html.haml +14 -14
- data/views/images/show.xml.haml +14 -14
- data/views/instance_states/show.html.haml +1 -1
- data/views/instance_states/show.png.erb +2 -2
- data/views/instance_states/show.xml.haml +1 -1
- data/views/instances/index.html.haml +1 -1
- data/views/instances/index.xml.haml +2 -2
- data/views/instances/new.html.haml +22 -14
- data/views/instances/run.html.haml +2 -2
- data/views/instances/run.xml.haml +3 -3
- data/views/instances/run_command.html.haml +4 -4
- data/views/instances/show.html.haml +27 -27
- data/views/instances/show.xml.haml +37 -37
- data/views/keys/index.html.haml +1 -1
- data/views/keys/index.xml.haml +2 -2
- data/views/keys/show.html.haml +10 -10
- data/views/keys/show.xml.haml +12 -12
- data/views/load_balancers/index.html.haml +1 -1
- data/views/load_balancers/index.xml.haml +2 -2
- data/views/load_balancers/new.html.haml +1 -8
- data/views/load_balancers/show.html.haml +10 -10
- data/views/load_balancers/show.xml.haml +9 -9
- data/views/metrics/index.html.haml +1 -1
- data/views/metrics/index.xml.haml +2 -2
- data/views/metrics/show.html.haml +2 -2
- data/views/metrics/show.xml.haml +3 -3
- data/views/realms/index.html.haml +1 -1
- data/views/realms/index.xml.haml +2 -2
- data/views/realms/show.html.haml +6 -6
- data/views/realms/show.xml.haml +5 -5
- data/views/storage_snapshots/index.html.haml +1 -1
- data/views/storage_snapshots/index.xml.haml +2 -2
- data/views/storage_snapshots/show.html.haml +6 -6
- data/views/storage_snapshots/show.xml.haml +4 -4
- data/views/storage_volumes/attach.html.haml +2 -2
- data/views/storage_volumes/index.html.haml +1 -1
- data/views/storage_volumes/index.xml.haml +2 -2
- data/views/storage_volumes/show.html.haml +19 -19
- data/views/storage_volumes/show.xml.haml +21 -21
- metadata +77 -65
- data/views/cimi/cloudEntryPoint/index.html.haml +0 -5
- data/views/cimi/cloudEntryPoint/index.xml.haml +0 -9
- data/views/cimi/collection/index.html.haml +0 -45
- data/views/cimi/collection/response.xml.haml +0 -3
- data/views/cimi/error.html.haml +0 -31
- data/views/cimi/errors/400.xml.haml +0 -3
- data/views/cimi/errors/401.xml.haml +0 -2
- data/views/cimi/errors/403.xml.haml +0 -2
- data/views/cimi/errors/404.xml.haml +0 -2
- data/views/cimi/errors/405.xml.haml +0 -5
- data/views/cimi/errors/500.xml.haml +0 -6
- data/views/cimi/errors/502.xml.haml +0 -7
- data/views/cimi/layout.html.haml +0 -32
- data/views/cimi/machine_configurations/show.html.haml +0 -159
- data/views/cimi/machine_configurations/show.xml.haml +0 -27
- data/views/cimi/machine_images/show.html.haml +0 -79
- data/views/cimi/machine_images/show.xml.haml +0 -17
- data/views/cimi/machines/show.html.haml +0 -177
- data/views/cimi/machines/show.xml.haml +0 -28
- data/views/cimi/volumes/show.html.haml +0 -68
- data/views/cimi/volumes/show.xml.haml +0 -17
- data/views/docs/collection.html.haml +0 -26
- data/views/docs/collection.xml.haml +0 -14
- data/views/docs/index.html.haml +0 -11
- data/views/docs/index.xml.haml +0 -5
- data/views/docs/operation.html.haml +0 -33
- data/views/docs/operation.xml.haml +0 -10
- data/views/root/index.html.haml +0 -4
@@ -23,6 +23,7 @@ module Deltacloud
|
|
23
23
|
class RhevmDriver < Deltacloud::BaseDriver
|
24
24
|
|
25
25
|
feature :instances, :user_data
|
26
|
+
feature :instances, :first_boot_dev
|
26
27
|
feature :instances, :user_name do
|
27
28
|
{ :max_length => 50 }
|
28
29
|
end
|
@@ -192,6 +193,7 @@ class RhevmDriver < Deltacloud::BaseDriver
|
|
192
193
|
params[:cores] = opts[:hwp_cpu] if opts[:hwp_cpu]
|
193
194
|
params[:user_data] = opts[:user_data].gsub(/\n/,'') if opts[:user_data]
|
194
195
|
params[:fileinject_path] = "deltacloud-user-data.txt"
|
196
|
+
params[:first_boot_dev] = opts[:first_boot_dev] if opts[:first_boot_dev]
|
195
197
|
convert_instance(client, client.create_vm(params))
|
196
198
|
end
|
197
199
|
end
|
@@ -75,8 +75,8 @@ module Deltacloud::Helpers
|
|
75
75
|
headers['X-Backend-Runtime'] = @benchmark.real.to_s
|
76
76
|
instance_variable_set(:"@#{model}", @elements)
|
77
77
|
respond_to do |format|
|
78
|
-
format.html { haml :"#{model}/index" }
|
79
|
-
format.xml { haml :"#{model}/index" }
|
78
|
+
format.html { haml :"#{model}/index", :locals => { :elements => @elements } }
|
79
|
+
format.xml { haml :"#{model}/index", :locals => { :elements => @elements } }
|
80
80
|
format.json { JSON::dump({ model => @elements.map { |el| el.to_hash(self) }}) }
|
81
81
|
end
|
82
82
|
else
|
@@ -92,8 +92,8 @@ module Deltacloud::Helpers
|
|
92
92
|
instance_variable_set("@#{model}", @element)
|
93
93
|
if @element
|
94
94
|
respond_to do |format|
|
95
|
-
format.html { haml :"#{model.to_s.pluralize}/show" }
|
96
|
-
format.xml { haml :"#{model.to_s.pluralize}/show" }
|
95
|
+
format.html { haml :"#{model.to_s.pluralize}/show", :locals=>{model=>@element}}
|
96
|
+
format.xml { haml :"#{model.to_s.pluralize}/show" , :locals=>{model=>@element}}
|
97
97
|
format.json { JSON::dump(model => @element.to_hash(self)) }
|
98
98
|
end
|
99
99
|
else
|
@@ -109,30 +109,29 @@ module Deltacloud::Helpers
|
|
109
109
|
def report_error(code=nil, message=nil)
|
110
110
|
|
111
111
|
if !code.nil?
|
112
|
-
|
113
|
-
|
114
|
-
message = @error.message
|
112
|
+
error = Deltacloud::Exceptions.exception_from_status(code, message || translate_error_code(code)[:message])
|
113
|
+
message = error.message
|
115
114
|
else
|
116
|
-
|
117
|
-
|
118
|
-
message =
|
115
|
+
error = request.env['sinatra.error'] || @exception
|
116
|
+
code = error.respond_to?(:code) ? error.code : 500
|
117
|
+
message = error.respond_to?(:message) ? error.message : translate_error_code(code)[:message]
|
119
118
|
end
|
120
119
|
|
121
|
-
response.status =
|
120
|
+
response.status = code
|
122
121
|
|
123
|
-
backtrace = (
|
124
|
-
"\n\n#{
|
122
|
+
backtrace = (error.respond_to?(:backtrace) and !error.backtrace.nil?) ?
|
123
|
+
"\n\n#{error.backtrace[0..20].join("\n")}\n\n" : ''
|
125
124
|
|
126
|
-
if
|
127
|
-
log.error(
|
125
|
+
if code.to_s =~ /5(\d+)/
|
126
|
+
log.error(code.to_s) { "[#{error.class.to_s}] #{message}#{backtrace}" }
|
128
127
|
end
|
129
128
|
|
130
129
|
respond_to do |format|
|
131
|
-
format.xml { haml :"errors/common", :layout => false }
|
132
|
-
format.json { JSON::dump({ :code =>
|
130
|
+
format.xml { haml :"errors/common", :layout => false, :locals => { :err => error } }
|
131
|
+
format.json { JSON::dump({ :code => code || error.code, :message => message, :error => error.class.name }) }
|
133
132
|
format.html {
|
134
133
|
begin
|
135
|
-
haml :"errors/common", :layout => :error
|
134
|
+
haml :"errors/common", :layout => :error, :locals => { :err => error }
|
136
135
|
rescue RuntimeError
|
137
136
|
# If the HTML representation of error is missing, then try to report
|
138
137
|
# it through XML
|
@@ -167,12 +166,12 @@ module Deltacloud::Helpers
|
|
167
166
|
halt 204, response
|
168
167
|
end
|
169
168
|
|
170
|
-
unless @instance.class == Instance
|
169
|
+
unless @instance.class == Deltacloud::Instance
|
171
170
|
redirect instance_url(params[:id])
|
172
171
|
else
|
173
172
|
response = respond_to do |format|
|
174
|
-
format.xml { haml :"instances/show" }
|
175
|
-
format.html { haml :"instances/show" }
|
173
|
+
format.xml { haml :"instances/show", :locals => { :instance => @instance } }
|
174
|
+
format.html { haml :"instances/show", :locals => { :instance => @instance } }
|
176
175
|
format.json { JSON::dump(@instance.to_hash(self)) }
|
177
176
|
end
|
178
177
|
halt 202, response
|
@@ -325,10 +324,11 @@ module Deltacloud::Helpers
|
|
325
324
|
|
326
325
|
def new_route_for(route, &block)
|
327
326
|
get '/%s/new' % route.to_s do
|
327
|
+
@opts = {}
|
328
328
|
instance_eval(&block) if block_given?
|
329
329
|
respond_to do |format|
|
330
330
|
format.html do
|
331
|
-
haml :"#{route}/new"
|
331
|
+
haml :"#{route}/new", :locals => @opts
|
332
332
|
end
|
333
333
|
end
|
334
334
|
end
|
@@ -45,19 +45,16 @@ module Deltacloud::Helpers
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def driver_class
|
48
|
-
|
49
|
-
|
50
|
-
m.const_get(driver_class_name + "Driver").new
|
51
|
-
rescue NameError
|
52
|
-
nil
|
53
|
-
end
|
48
|
+
m = Deltacloud::Drivers.const_get(driver_class_name)
|
49
|
+
m.const_get(driver_class_name + "Driver").new
|
54
50
|
end
|
55
51
|
|
56
52
|
def driver
|
57
53
|
$:.unshift File.join(File.dirname(__FILE__), '..', '..')
|
58
54
|
begin
|
59
|
-
require_relative(driver_source_name) unless driver_class
|
60
55
|
driver_class
|
56
|
+
rescue NameError => e
|
57
|
+
require_relative(driver_source_name) ? retry : raise(LoadError.new(e.message))
|
61
58
|
rescue LoadError => e
|
62
59
|
raise "[ERROR] The driver '#{driver_name}' is unknown or not installed (#{driver_source_name})\n" +
|
63
60
|
"\n#{e.message}\n"
|
@@ -45,6 +45,7 @@ module Sinatra::Rabbit
|
|
45
45
|
c.operations.each do |operation|
|
46
46
|
URLHelper.instance_eval(&generate_url_helper_for(c, operation)[0])
|
47
47
|
end
|
48
|
+
URLFor(c.collections)
|
48
49
|
end
|
49
50
|
URLHelper
|
50
51
|
end
|
@@ -53,6 +54,10 @@ module Sinatra::Rabbit
|
|
53
54
|
operation_name = operation.operation_name.to_s
|
54
55
|
collection_name = collection.collection_name.to_s
|
55
56
|
|
57
|
+
if collection.subcollection?
|
58
|
+
collection_name = "#{collection.parent_collection.collection_name.to_s.singularize}_#{collection_name}"
|
59
|
+
end
|
60
|
+
|
56
61
|
# Construct OPERATION_COLLECTION_URL helper
|
57
62
|
# The :index and :create operation does not get any prefix
|
58
63
|
#
|
data/lib/deltacloud/server.rb
CHANGED
@@ -48,11 +48,11 @@ module Deltacloud
|
|
48
48
|
if params[:force_auth]
|
49
49
|
return [401, 'Authentication failed'] unless driver.valid_credentials?(credentials)
|
50
50
|
end
|
51
|
-
|
51
|
+
collections = driver.supported_collections(credentials)
|
52
52
|
respond_to do |format|
|
53
|
-
format.xml { haml :"api/show" }
|
54
|
-
format.json { collections_to_json(
|
55
|
-
format.html { haml :"api/show" }
|
53
|
+
format.xml { haml :"api/show", :locals => { :collections => collections } }
|
54
|
+
format.json { collections_to_json(collections) }
|
55
|
+
format.html { haml :"api/show", :locals => { :collections => collections } }
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
data/lib/deltacloud/version.rb
CHANGED
data/lib/deltacloud_rack.rb
CHANGED
@@ -147,7 +147,12 @@ module Deltacloud
|
|
147
147
|
@logger = logger
|
148
148
|
end
|
149
149
|
|
150
|
-
|
150
|
+
# Require the Deltacloud API Rack middleware
|
151
|
+
#
|
152
|
+
# opts[:initialize] = true will require 'initialize.rb'
|
153
|
+
#
|
154
|
+
def require!(opts={})
|
155
|
+
require_relative './initializers/mock_initialize' if opts[:mock_initialize]
|
151
156
|
Deltacloud.require_frontend!(@name)
|
152
157
|
end
|
153
158
|
|
data/lib/ec2/server.rb
CHANGED
@@ -29,7 +29,7 @@ module Deltacloud::EC2
|
|
29
29
|
extend Deltacloud::Helpers::Drivers
|
30
30
|
|
31
31
|
use Rack::ETag
|
32
|
-
use Deltacloud[:ec2].logger
|
32
|
+
use Deltacloud[:ec2].logger unless RUBY_PLATFORM == 'java'
|
33
33
|
|
34
34
|
helpers Sinatra::AuthHelper
|
35
35
|
helpers Deltacloud::Helpers::Drivers
|
@@ -38,6 +38,7 @@ module Deltacloud::EC2
|
|
38
38
|
enable :xhtml
|
39
39
|
enable :dump_errors
|
40
40
|
enable :show_errors
|
41
|
+
enable :logging
|
41
42
|
disable :show_exceptions
|
42
43
|
|
43
44
|
set :config, Deltacloud[:ec2]
|
@@ -57,6 +58,10 @@ module Deltacloud::EC2
|
|
57
58
|
headers 'Server' => 'Apache-Deltacloud-EC2/' + settings.version
|
58
59
|
end
|
59
60
|
|
61
|
+
error Deltacloud::Exceptions::AuthenticationFailure do
|
62
|
+
status 401
|
63
|
+
end
|
64
|
+
|
60
65
|
get '/' do
|
61
66
|
headers 'Connection' => 'close'
|
62
67
|
unless params['Action']
|
@@ -15,3 +15,36 @@ Deltacloud[:cimi].require!
|
|
15
15
|
Deltacloud[:cimi].default_frontend!
|
16
16
|
|
17
17
|
def formats; [ 'application/xml', 'application/json' ]; end
|
18
|
+
|
19
|
+
def model_class
|
20
|
+
resource = nil
|
21
|
+
resp = last_response
|
22
|
+
ct = resp.content_type
|
23
|
+
if ct == "application/json"
|
24
|
+
json = JSON::parse(last_response.body)
|
25
|
+
json["resourceURI"].wont_be_nil
|
26
|
+
resource = json["resourceURI"].split("/").last
|
27
|
+
elsif ct == "application/xml"
|
28
|
+
xml = Nokogiri::XML(last_response.body)
|
29
|
+
if xml.root.name == "Collection"
|
30
|
+
resource = xml.root["resourceURI"].split("/").last
|
31
|
+
else
|
32
|
+
resource = xml.root.name
|
33
|
+
end
|
34
|
+
elsif resp.body.nil? || resp.body.size == 0
|
35
|
+
raise "Can not construct model from empty body"
|
36
|
+
else
|
37
|
+
raise "Unexpected content type #{resp.content_type}"
|
38
|
+
end
|
39
|
+
if resource == "DiskCollection"
|
40
|
+
# We scope subcollections within the containing class
|
41
|
+
# CIMI resource_uri's don't
|
42
|
+
CIMI::Model::Machine::DiskCollection
|
43
|
+
else
|
44
|
+
CIMI::Model::const_get(resource)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def model
|
49
|
+
model_class.parse(last_response.body, last_response.content_type)
|
50
|
+
end
|
@@ -35,6 +35,25 @@ describe CIMI::Collections::Machines do
|
|
35
35
|
xml.root.name.must_equal 'Machine'
|
36
36
|
end
|
37
37
|
|
38
|
+
it 'should have an "add" operation for the machine collection' do
|
39
|
+
get root_url + '/machines'
|
40
|
+
model.operations.wont_be_empty
|
41
|
+
add_ops = model.operations.select { |op| op.rel == "add" }
|
42
|
+
add_ops.size.must_equal 1
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should return the disks collection for a machine" do
|
46
|
+
get root_url + '/machines'
|
47
|
+
model.operations.wont_be_empty
|
48
|
+
href = model.entries.first.disks[:href]
|
49
|
+
href.wont_be_empty
|
50
|
+
get href
|
51
|
+
status.must_equal 200
|
52
|
+
model.must_be_kind_of CIMI::Model::Machine::DiskCollection
|
53
|
+
model.entries.size.must_equal 1
|
54
|
+
model.entries.first.name.must_equal "inst0_disk_0"
|
55
|
+
end
|
56
|
+
|
38
57
|
describe "$expand" do
|
39
58
|
def machine(*expand)
|
40
59
|
url = '/machines/inst1'
|
@@ -38,4 +38,51 @@ describe CIMI::Collections::SystemTemplates do
|
|
38
38
|
status.must_equal 404
|
39
39
|
end
|
40
40
|
|
41
|
+
it 'should allow to retrieve system template\'s machine template\'s ref details' do
|
42
|
+
get root_url '/system_templates/template1'
|
43
|
+
(xml/'SystemTemplate/componentDescriptor').each do |c|
|
44
|
+
if (c/'name').inner_text == 'my third machine'
|
45
|
+
(c/'machineTemplate').wont_be_empty
|
46
|
+
(c/'machineTemplate').to_s.must_equal '<machineTemplate href="http://example.com/machine_templates/template1"/>'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should allow to retrieve system template\'s machine template\'s inline details' do
|
52
|
+
get root_url '/system_templates/template1'
|
53
|
+
(xml/'SystemTemplate/componentDescriptor').each do |c|
|
54
|
+
if (c/'name').inner_text == 'my machine'
|
55
|
+
(c/'machineTemplate').wont_be_empty
|
56
|
+
(c/'machineTemplate/name').inner_text.must_equal 'machine in mock system'
|
57
|
+
(c/'machineTemplate/description').inner_text.must_equal 'machine in system'
|
58
|
+
(c/'machineTemplate/machineConfig').to_s.must_equal '<machineConfig href="http://example.com/configs/m1-small"/>'
|
59
|
+
(c/'machineTemplate/machineImage').to_s.must_equal '<machineImage href="http://example.com/images/img1"/>'
|
60
|
+
(c/'machineTemplate/volumeTemplate').to_s.must_equal '<volumeTemplate href="http://example.com/volumes/sysvol1"/>'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should allow to retrieve system template\'s machine template\'s inline volume template' do
|
66
|
+
get root_url '/system_templates/template1'
|
67
|
+
(xml/'SystemTemplate/componentDescriptor').each do |c|
|
68
|
+
if (c/'name').inner_text == 'my second machine'
|
69
|
+
(c/'machineTemplate').wont_be_empty
|
70
|
+
(c/'machineTemplate/description').inner_text.must_equal 'another inline mock machine template'
|
71
|
+
(c/'machineTemplate/volumeTemplate').wont_be_empty
|
72
|
+
(c/'machineTemplate/volumeTemplate/volumeConfig').wont_be_empty
|
73
|
+
(c/'machineTemplate/volumeTemplate/volumeConfig/capacity').inner_text.must_equal '10485760'
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should allow to retrieve system template\'s network' do
|
79
|
+
get root_url '/system_templates/template1'
|
80
|
+
(xml/'SystemTemplate/componentDescriptor').each do |c|
|
81
|
+
if (c/'name').inner_text == 'network in mock system'
|
82
|
+
(c/'networkTemplate').inner_text.must_equal 'my network'
|
83
|
+
(c/'networkTemplate/networkConfig/networkType').inner_text.must_equal 'GOLD'
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
41
88
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'require_relative' if RUBY_VERSION < '1.9'
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require_relative './common.rb'
|
5
|
+
|
6
|
+
describe CIMI::Collections::Volumes do
|
7
|
+
|
8
|
+
def create_model(model_class, attr)
|
9
|
+
model = model_class.new(attr)
|
10
|
+
svc_class = CIMI::Service::const_get(model_class.name.split('::').last)
|
11
|
+
svc_class.new(nil, :model => model).save
|
12
|
+
model
|
13
|
+
end
|
14
|
+
|
15
|
+
before do
|
16
|
+
def app; run_frontend(:cimi) end
|
17
|
+
authorize 'mockuser', 'mockpassword'
|
18
|
+
|
19
|
+
@config = create_model CIMI::Model::VolumeConfiguration,
|
20
|
+
:id => "http://localhost:3001/cimi/volume_configurations/1",
|
21
|
+
:name => "volume_config",
|
22
|
+
:format => "ext3",
|
23
|
+
:capacity => 1
|
24
|
+
|
25
|
+
@collection = CIMI::Collections.collection(:volumes)
|
26
|
+
end
|
27
|
+
|
28
|
+
def make_volume_create
|
29
|
+
vt = CIMI::Model::VolumeTemplate.new
|
30
|
+
vt.volume_config.href = @config.id
|
31
|
+
CIMI::Model::VolumeCreate.new(:name => "new_cimi_volume_#{Time.now.to_i}",
|
32
|
+
:volume_template => vt)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'allows creation of a new volume' do
|
36
|
+
vc = make_volume_create
|
37
|
+
post '/cimi/volumes', vc.to_json, "CONTENT_TYPE" => "application/json"
|
38
|
+
|
39
|
+
last_response.status.must_equal 201
|
40
|
+
model.name.must_equal vc.name
|
41
|
+
end
|
42
|
+
end
|
@@ -16,7 +16,8 @@ describe Deltacloud::Helpers::Database do
|
|
16
16
|
before do
|
17
17
|
@provider = Deltacloud::Database::Provider
|
18
18
|
@entity = Deltacloud::Database::Entity
|
19
|
-
@
|
19
|
+
@baseService = CIMI::Service::Base
|
20
|
+
@baseModel = @baseService.model_class
|
20
21
|
|
21
22
|
@db = DatabaseHelper.new
|
22
23
|
@prov = @provider::lookup
|
@@ -98,7 +99,7 @@ describe Deltacloud::Helpers::Database do
|
|
98
99
|
check_entity_base_attrs new_entity, @entity, @prov
|
99
100
|
|
100
101
|
base = @baseModel.new(:id => 'base1')
|
101
|
-
base.destroy
|
102
|
+
@baseService.new(nil, :model => base).destroy
|
102
103
|
entity = @entity.retrieve(base)
|
103
104
|
entity.wont_be_nil
|
104
105
|
entity.exists?.must_equal false
|
@@ -123,10 +124,12 @@ describe Deltacloud::Helpers::Database do
|
|
123
124
|
}
|
124
125
|
}
|
125
126
|
'
|
126
|
-
|
127
|
+
|
128
|
+
model = CIMI::Model::Machine.from_json(json)
|
129
|
+
machine = CIMI::Service::Machine.new(nil, :model => model)
|
127
130
|
machine.save
|
128
131
|
|
129
|
-
m2 = CIMI::
|
132
|
+
m2 = CIMI::Service::Machine.new(nil, :values => { :id => machine.id })
|
130
133
|
m2.name.must_equal 'myDatabaseMachine'
|
131
134
|
m2.description.must_equal 'This is a demo machine'
|
132
135
|
m2.property.must_be_kind_of Hash
|
@@ -64,7 +64,7 @@ describe Deltacloud::Helpers::Drivers do
|
|
64
64
|
it 'should throw an exception on unknown driver' do
|
65
65
|
begin
|
66
66
|
Thread.current[:driver] = 'unknown'
|
67
|
-
Proc.new { @helper.driver }.must_raise
|
67
|
+
Proc.new { @helper.driver }.must_raise LoadError
|
68
68
|
ensure
|
69
69
|
Thread.current[:driver] = 'mock'
|
70
70
|
end
|
data/tests/drivers/ec2/common.rb
CHANGED
@@ -25,7 +25,10 @@ VCR.configure do |c|
|
|
25
25
|
matcher = VCR.request_matchers.uri_without_param("AWSAccessKeyId",
|
26
26
|
"Signature", "Timestamp")
|
27
27
|
c.register_request_matcher(:ec2_matcher, &matcher)
|
28
|
-
c.default_cassette_options = {
|
28
|
+
c.default_cassette_options = {
|
29
|
+
:record => vcr_record_mode,
|
30
|
+
:match_requests_on => [:method, :ec2_matcher]
|
31
|
+
}
|
29
32
|
end
|
30
33
|
|
31
34
|
# Setup resources we need for the tests
|