deltacloud-core 0.5.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/NOTICE +1 -1
- data/Rakefile +63 -21
- data/bin/deltacloudd +10 -6
- data/config.ru +62 -6
- data/config/drivers/ec2.yaml +8 -0
- data/config/drivers/fgcp.yaml +13 -0
- data/deltacloud-core.gemspec +10 -2
- data/lib/cimi/collections.rb +58 -0
- data/lib/cimi/collections/address_templates.rb +49 -0
- data/lib/cimi/collections/addresses.rb +74 -0
- data/lib/cimi/collections/cloud_entry_point.rb +37 -0
- data/lib/{deltacloud/helpers/conversion_helper.rb → cimi/collections/entity_metadata.rb} +24 -16
- data/lib/cimi/collections/machine_admins.rb +74 -0
- data/lib/cimi/collections/machine_configurations.rb +49 -0
- data/lib/cimi/collections/machine_images.rb +50 -0
- data/lib/cimi/collections/machines.rb +157 -0
- data/lib/cimi/collections/network_configurations.rb +47 -0
- data/lib/cimi/collections/network_templates.rb +48 -0
- data/lib/cimi/collections/networks.rb +125 -0
- data/lib/cimi/collections/routing_group_templates.rb +47 -0
- data/lib/cimi/collections/routing_groups.rb +48 -0
- data/lib/cimi/collections/volume_configurations.rb +48 -0
- data/lib/cimi/collections/volume_images.rb +50 -0
- data/lib/cimi/collections/volumes.rb +80 -0
- data/lib/cimi/collections/vsp_configurations.rb +48 -0
- data/lib/cimi/collections/vsp_templates.rb +50 -0
- data/lib/cimi/collections/vsps.rb +108 -0
- data/lib/cimi/dependencies.rb +1 -0
- data/lib/cimi/helpers.rb +116 -0
- data/lib/cimi/helpers/cimi_helper.rb +6 -2
- data/lib/cimi/models.rb +72 -0
- data/lib/cimi/{model → models}/action.rb +1 -1
- data/lib/cimi/models/address.rb +72 -0
- data/lib/cimi/models/address_collection.rb +34 -0
- data/lib/cimi/models/address_template.rb +54 -0
- data/lib/cimi/models/address_template_collection.rb +34 -0
- data/lib/cimi/{model → models}/base.rb +2 -2
- data/lib/cimi/{model → models}/cloud_entry_point.rb +3 -5
- data/lib/cimi/{model → models}/entity_metadata.rb +7 -6
- data/lib/cimi/{model → models}/entity_metadata_collection.rb +2 -2
- data/lib/cimi/{model → models}/errors.rb +8 -0
- data/lib/cimi/{model → models}/machine.rb +10 -10
- data/lib/cimi/{model → models}/machine_admin.rb +1 -1
- data/lib/cimi/{model → models}/machine_admin_collection.rb +2 -2
- data/lib/cimi/{model → models}/machine_collection.rb +2 -2
- data/lib/cimi/{model → models}/machine_configuration.rb +9 -6
- data/lib/cimi/{model → models}/machine_configuration_collection.rb +2 -2
- data/lib/cimi/{model → models}/machine_image.rb +1 -1
- data/lib/cimi/{model → models}/machine_image_collection.rb +2 -2
- data/lib/cimi/{model → models}/machine_template.rb +0 -0
- data/lib/cimi/{model → models}/machine_template_collection.rb +2 -2
- data/lib/cimi/models/network.rb +109 -0
- data/lib/cimi/{model → models}/network_collection.rb +2 -2
- data/lib/cimi/{model → models}/network_configuration.rb +3 -4
- data/lib/cimi/{model → models}/network_configuration_collection.rb +2 -2
- data/lib/cimi/models/network_template.rb +36 -0
- data/lib/cimi/models/network_template_collection.rb +35 -0
- data/lib/cimi/models/routing_group.rb +34 -0
- data/lib/cimi/models/routing_group_collection.rb +34 -0
- data/lib/cimi/models/routing_group_template.rb +34 -0
- data/lib/cimi/models/routing_group_template_collection.rb +35 -0
- data/lib/cimi/{model → models}/schema.rb +0 -0
- data/lib/cimi/{model → models}/volume.rb +4 -4
- data/lib/cimi/{model → models}/volume_collection.rb +2 -2
- data/lib/cimi/{model → models}/volume_configuration.rb +1 -1
- data/lib/cimi/{model → models}/volume_configuration_collection.rb +2 -2
- data/lib/cimi/{model → models}/volume_image.rb +1 -1
- data/lib/cimi/{model → models}/volume_image_collection.rb +2 -2
- data/lib/cimi/{model → models}/volume_template.rb +0 -0
- data/lib/cimi/{model → models}/volume_template_collection.rb +2 -2
- data/lib/cimi/models/vsp.rb +102 -0
- data/lib/cimi/models/vsp_collection.rb +34 -0
- data/lib/cimi/models/vsp_configuration.rb +40 -0
- data/lib/cimi/models/vsp_configuration_collection.rb +34 -0
- data/lib/cimi/models/vsp_template.rb +34 -0
- data/lib/cimi/models/vsp_template_collection.rb +34 -0
- data/lib/cimi/server.rb +27 -549
- data/lib/deltacloud/api.rb +79 -0
- data/lib/deltacloud/collections.rb +54 -0
- data/lib/deltacloud/collections/addresses.rb +91 -0
- data/lib/deltacloud/collections/buckets.rb +273 -0
- data/lib/deltacloud/collections/drivers.rb +51 -0
- data/lib/deltacloud/collections/firewalls.rb +116 -0
- data/lib/deltacloud/collections/hardware_profiles.rb +29 -0
- data/lib/deltacloud/collections/images.rb +73 -0
- data/lib/deltacloud/collections/instance_states.rb +59 -0
- data/lib/deltacloud/collections/instances.rb +113 -0
- data/lib/deltacloud/collections/keys.rb +61 -0
- data/lib/deltacloud/collections/load_balancers.rb +102 -0
- data/lib/deltacloud/collections/metrics.rb +28 -0
- data/lib/deltacloud/collections/realms.rb +28 -0
- data/lib/deltacloud/collections/storage_snapshots.rb +51 -0
- data/lib/deltacloud/collections/storage_volumes.rb +99 -0
- data/lib/deltacloud/core_ext.rb +14 -6
- data/lib/deltacloud/core_ext/string.rb +17 -5
- data/lib/deltacloud/drivers.rb +6 -42
- data/lib/deltacloud/drivers/azure/azure_driver.rb +0 -4
- data/lib/deltacloud/{base_driver → drivers}/base_driver.rb +56 -18
- data/lib/deltacloud/drivers/condor/condor_driver.rb +1 -8
- data/lib/deltacloud/drivers/ec2/ec2_driver.rb +142 -33
- data/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb +2 -6
- data/lib/deltacloud/{base_driver → drivers}/exceptions.rb +25 -2
- data/lib/deltacloud/drivers/features.rb +154 -0
- data/lib/deltacloud/drivers/fgcp/fgcp_client.rb +387 -0
- data/lib/deltacloud/drivers/fgcp/fgcp_driver.rb +1435 -0
- data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +8 -11
- data/lib/deltacloud/drivers/google/google_driver.rb +2 -5
- data/lib/deltacloud/drivers/mock/data/keys/test-key.yml +28 -0
- data/lib/deltacloud/drivers/mock/mock_client.rb +2 -2
- data/lib/deltacloud/drivers/mock/mock_driver.rb +58 -40
- data/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb +145 -0
- data/lib/deltacloud/drivers/opennebula/cloud_client.rb +107 -73
- data/lib/deltacloud/drivers/opennebula/occi_client.rb +285 -145
- data/lib/deltacloud/drivers/opennebula/opennebula_driver.rb +189 -126
- data/lib/deltacloud/drivers/openstack/openstack_driver.rb +427 -8
- data/lib/deltacloud/drivers/rackspace/rackspace_driver.rb +7 -9
- data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +48 -66
- data/lib/deltacloud/drivers/rimuhosting/rimuhosting_client.rb +44 -51
- data/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb +7 -8
- data/lib/deltacloud/drivers/sbc/sbc_client.rb +1 -1
- data/lib/deltacloud/drivers/sbc/sbc_driver.rb +3 -3
- data/lib/deltacloud/drivers/terremark/terremark_driver.rb +8 -8
- data/lib/deltacloud/drivers/vsphere/vsphere_driver.rb +39 -13
- data/lib/deltacloud/drivers/vsphere/vsphere_filemanager.rb +1 -0
- data/lib/deltacloud/helpers.rb +79 -7
- data/lib/{sinatra/lazy_auth.rb → deltacloud/helpers/auth_helper.rb} +5 -9
- data/lib/deltacloud/helpers/{blob_stream.rb → blob_stream_helper.rb} +7 -7
- data/lib/deltacloud/helpers/deltacloud_helper.rb +286 -0
- data/lib/deltacloud/helpers/driver_helper.rb +58 -0
- data/lib/deltacloud/helpers/rabbit_helper.rb +34 -0
- data/lib/{sinatra/url_for.rb → deltacloud/helpers/url_helper.rb} +31 -9
- data/lib/deltacloud/models.rb +19 -17
- data/lib/deltacloud/models/bucket.rb +4 -0
- data/lib/deltacloud/{hardware_profile.rb → models/hardware_profile.rb} +4 -2
- data/lib/deltacloud/models/image.rb +1 -0
- data/lib/deltacloud/models/instance.rb +4 -2
- data/lib/deltacloud/models/instance_address.rb +4 -0
- data/lib/deltacloud/models/key.rb +4 -0
- data/lib/deltacloud/models/metric.rb +40 -0
- data/lib/deltacloud/{state_machine.rb → models/state_machine.rb} +18 -1
- data/lib/deltacloud/server.rb +41 -1222
- data/lib/deltacloud_rack.rb +79 -0
- data/lib/{cimi/model/network_template.rb → ec2/helpers.rb} +7 -10
- data/lib/{deltacloud/backend_capability.rb → ec2/helpers/errors.rb} +24 -29
- data/lib/ec2/helpers/result.rb +31 -0
- data/lib/ec2/query_parser.rb +152 -0
- data/lib/ec2/server.rb +70 -0
- data/lib/{deltacloud.rb → sinatra.rb} +7 -12
- data/lib/sinatra/rack_accept.rb +13 -7
- data/lib/sinatra/rack_driver_select.rb +1 -1
- data/lib/sinatra/rack_matrix_params.rb +1 -3
- data/public/images/metric.png +0 -0
- data/public/javascripts/jquery.mobile-1.0.1.min.js +177 -0
- data/public/stylesheets/jquery.mobile-1.0.1.min.css +2 -0
- data/public/stylesheets/new.css +10 -0
- data/support/fedora/deltacloud-core.spec +1 -1
- data/tests/api/common.rb +1 -0
- data/tests/api/driver_test.rb +79 -0
- data/tests/api/library_test.rb +48 -0
- data/tests/cimi/features/step_definitions/common_steps.rb +2 -2
- data/tests/cimi/features/step_definitions/machines_steps.rb +5 -4
- data/tests/cimi/features/step_definitions/volumes_steps.rb +8 -8
- data/tests/cimi/features/support/env.rb +33 -11
- data/tests/common.rb +7 -8
- data/tests/drivers/ec2/api_test.rb +19 -0
- data/tests/drivers/ec2/common.rb +23 -0
- data/tests/drivers/ec2/drivers_test.rb +120 -0
- data/tests/drivers/ec2/hardware_profiles_test.rb +224 -0
- data/tests/drivers/ec2/images_test.rb +230 -0
- data/tests/drivers/ec2/instances_test.rb +356 -0
- data/tests/drivers/ec2/keys_test.rb +181 -0
- data/tests/drivers/ec2/realms_test.rb +146 -0
- data/tests/drivers/fgcp/api_test.rb +47 -0
- data/tests/drivers/fgcp/hardware_profiles_test.rb +54 -0
- data/tests/drivers/fgcp/realms_test.rb +42 -0
- data/tests/drivers/{rackspace → fgcp}/setup.rb +5 -6
- data/tests/drivers/google/api_test.rb +10 -26
- data/tests/drivers/google/buckets_test.rb +79 -95
- data/tests/drivers/google/common.rb +54 -0
- data/tests/drivers/mock/api_test.rb +4 -127
- data/tests/drivers/mock/buckets_test.rb +195 -0
- data/tests/drivers/mock/common.rb +7 -0
- data/tests/drivers/mock/drivers_test.rb +123 -0
- data/tests/drivers/mock/hardware_profiles_test.rb +190 -100
- data/tests/drivers/mock/images_test.rb +162 -103
- data/tests/drivers/mock/instances_test.rb +310 -220
- data/tests/drivers/mock/keys_test.rb +161 -0
- data/tests/drivers/mock/realms_test.rb +109 -70
- data/tests/drivers/mock/storage_snapshots_test.rb +114 -0
- data/tests/drivers/mock/storage_volumes_test.rb +122 -0
- data/tests/drivers/openstack/api_test.rb +8 -3
- data/tests/drivers/openstack/common.rb +21 -0
- data/tests/drivers/openstack/hardware_profiles_test.rb +20 -9
- data/tests/drivers/openstack/images_test.rb +11 -5
- data/tests/drivers/openstack/instances_test.rb +61 -16
- data/tests/drivers/openstack/realms_test.rb +11 -7
- data/tests/drivers/rackspace/api_test.rb +7 -2
- data/tests/drivers/rackspace/buckets_test.rb +7 -2
- data/tests/drivers/rackspace/common.rb +16 -0
- data/tests/drivers/rackspace/hardware_profiles_test.rb +7 -2
- data/tests/drivers/rackspace/images_test.rb +7 -2
- data/tests/drivers/rackspace/instances_test.rb +10 -5
- data/tests/drivers/rackspace/realms_test.rb +7 -2
- data/tests/drivers/rhevm/api_test.rb +12 -6
- data/tests/drivers/rhevm/{setup.rb → common.rb} +8 -1
- data/tests/drivers/rhevm/hardware_profiles_test.rb +7 -2
- data/tests/drivers/rhevm/images_test.rb +8 -2
- data/tests/drivers/rhevm/instances_test.rb +7 -2
- data/tests/drivers/rhevm/realms_test.rb +7 -2
- data/tests/minitest_common.rb +58 -0
- data/tests/minitest_common_api_test.rb +115 -0
- data/views/addresses/associate.html.haml +1 -1
- data/views/addresses/index.html.haml +1 -1
- data/views/addresses/show.html.haml +2 -3
- data/views/api/show.html.haml +22 -9
- data/views/api/show.xml.haml +8 -7
- data/views/blobs/show.xml.haml +7 -4
- data/views/buckets/new.html.haml +2 -2
- data/views/cimi/errors/401.xml.haml +1 -1
- data/views/error.html.haml +3 -3
- data/views/errors/400.html.haml +1 -1
- data/views/errors/400.xml.haml +1 -2
- data/views/errors/401.html.haml +8 -7
- data/views/errors/401.xml.haml +1 -1
- data/views/errors/404.xml.haml +1 -0
- data/views/errors/500.xml.haml +4 -2
- data/views/{cimi/errors/403.html.haml → errors/501.html.haml} +4 -2
- data/views/errors/501.xml.haml +1 -0
- data/views/errors/502.xml.haml +1 -7
- data/views/{cimi/errors/500.html.haml → errors/504.html.haml} +0 -0
- data/views/errors/504.xml.haml +1 -0
- data/views/firewalls/new.html.haml +2 -2
- data/views/firewalls/new_rule.html.haml +1 -1
- data/views/firewalls/show.html.haml +1 -1
- data/views/hardware_profiles/index.html.haml +3 -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 +3 -3
- data/views/images/show.html.haml +5 -0
- data/views/images/show.xml.haml +6 -1
- data/views/instance_states/show.html.haml +1 -1
- data/views/instances/index.html.haml +1 -1
- data/views/instances/new.html.haml +54 -39
- data/views/instances/run_command.html.haml +24 -15
- data/views/instances/show.html.haml +7 -3
- data/views/instances/show.xml.haml +2 -2
- data/views/keys/show.xml.haml +1 -0
- data/views/layout.html.haml +5 -9
- data/views/load_balancers/show.html.haml +12 -6
- data/views/metrics/index.html.haml +13 -0
- data/views/metrics/index.xml.haml +5 -0
- data/views/metrics/show.html.haml +23 -0
- data/views/metrics/show.xml.haml +9 -0
- data/views/realms/show.xml.haml +2 -1
- data/views/root/index.html.haml +1 -1
- data/views/storage_snapshots/show.html.haml +1 -1
- data/views/storage_snapshots/show.xml.haml +1 -0
- data/views/storage_volumes/attach.html.haml +1 -2
- data/views/storage_volumes/index.html.haml +1 -1
- data/views/storage_volumes/new.html.haml +22 -16
- data/views/storage_volumes/show.html.haml +10 -4
- data/views/storage_volumes/show.xml.haml +3 -4
- metadata +547 -519
- data/DISCLAIMER +0 -8
- data/lib/cimi/model.rb +0 -52
- data/lib/cimi/model/network.rb +0 -69
- data/lib/deltacloud/base_driver.rb +0 -18
- data/lib/deltacloud/base_driver/features.rb +0 -262
- data/lib/deltacloud/base_driver/mock_driver.rb +0 -78
- data/lib/deltacloud/drivers/ec2/ec2_mock_driver.rb +0 -186
- data/lib/deltacloud/drivers/rhevm/rhevm_client.rb +0 -521
- data/lib/deltacloud/helpers/application_helper.rb +0 -267
- data/lib/deltacloud/helpers/hardware_profiles_helper.rb +0 -50
- data/lib/deltacloud/helpers/json_helper.rb +0 -31
- data/lib/deltacloud/method_serializer.rb +0 -83
- data/lib/deltacloud/validation.rb +0 -107
- data/lib/sinatra/rabbit.rb +0 -441
- data/lib/sinatra/rack_runtime.rb +0 -47
- data/lib/sinatra/rack_syslog.rb +0 -86
- data/lib/sinatra/sinatra_verbose.rb +0 -73
- data/lib/sinatra/static_assets.rb +0 -99
- data/public/javascripts/jquery.mobile-1.0rc1.min.js +0 -170
- data/public/stylesheets/jquery.mobile-1.0rc1.min.css +0 -12
- data/tests/drivers/google/setup.rb +0 -38
- data/tests/drivers/mock/instance_states_test.rb +0 -71
- data/tests/drivers/mock/setup.rb +0 -3
- data/tests/drivers/mock/url_for_test.rb +0 -67
- data/tests/drivers/openstack/setup.rb +0 -20
- data/views/cimi/errors/400.html.haml +0 -41
- data/views/cimi/errors/401.html.haml +0 -41
- data/views/cimi/errors/404.html.haml +0 -29
- data/views/cimi/errors/405.html.haml +0 -29
- data/views/cimi/errors/502.html.haml +0 -43
- data/views/cimi/errors/backend_capability_failure.html.haml +0 -29
@@ -1,138 +1,197 @@
|
|
1
|
-
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
-
# contributor license agreements. See the NOTICE file distributed with
|
3
|
-
# this work for additional information regarding copyright ownership. The
|
4
|
-
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
-
# "License"); you may not use this file except in compliance with the
|
6
|
-
# License. You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
-
# License for the specific language governing permissions and limitations
|
14
|
-
# under the License.
|
15
|
-
#
|
16
|
-
|
17
1
|
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
18
|
-
require 'tests/common'
|
2
|
+
require 'tests/drivers/mock/common'
|
19
3
|
|
20
|
-
|
21
|
-
|
22
|
-
include Rack::Test::Methods
|
4
|
+
describe 'Deltacloud API Images' do
|
5
|
+
include Deltacloud::Test
|
23
6
|
|
24
|
-
|
25
|
-
|
26
|
-
|
7
|
+
it 'must advertise have the images collection in API entrypoint' do
|
8
|
+
get root_url
|
9
|
+
(xml_response/'api/link[@rel=images]').wont_be_empty
|
10
|
+
end
|
27
11
|
|
28
|
-
|
29
|
-
|
30
|
-
|
12
|
+
it 'must require authentication to access the "image" collection' do
|
13
|
+
get collection_url(:images)
|
14
|
+
last_response.status.must_equal 401
|
15
|
+
end
|
31
16
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
17
|
+
it 'should respond with HTTP_OK when accessing the :images collection with authentication' do
|
18
|
+
authenticate
|
19
|
+
get collection_url(:images)
|
20
|
+
last_response.status.must_equal 200
|
21
|
+
end
|
36
22
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
23
|
+
it 'should support the JSON media type' do
|
24
|
+
authenticate
|
25
|
+
header 'Accept', 'application/json'
|
26
|
+
get collection_url(:images)
|
27
|
+
last_response.status.must_equal 200
|
28
|
+
last_response.headers['Content-Type'].must_equal 'application/json'
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'must include the ETag in HTTP headers' do
|
32
|
+
authenticate
|
33
|
+
get collection_url(:images)
|
34
|
+
last_response.headers['ETag'].wont_be_nil
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'must have the "images" element on top level' do
|
38
|
+
authenticate
|
39
|
+
get collection_url(:images)
|
40
|
+
xml_response.root.name.must_equal 'images'
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'must have some "image" elements inside "images"' do
|
44
|
+
authenticate
|
45
|
+
get collection_url(:images)
|
46
|
+
(xml_response/'images/image').wont_be_empty
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'must provide the :id attribute for each image in collection' do
|
50
|
+
authenticate
|
51
|
+
get collection_url(:images)
|
52
|
+
(xml_response/'images/image').each do |r|
|
53
|
+
r[:id].wont_be_nil
|
42
54
|
end
|
55
|
+
end
|
43
56
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
57
|
+
it 'must include the :href attribute for each "image" element in collection' do
|
58
|
+
authenticate
|
59
|
+
get collection_url(:images)
|
60
|
+
(xml_response/'images/image').each do |r|
|
61
|
+
r[:href].wont_be_nil
|
48
62
|
end
|
63
|
+
end
|
49
64
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
65
|
+
it 'must use the absolute URL in each :href attribute' do
|
66
|
+
authenticate
|
67
|
+
get collection_url(:images)
|
68
|
+
(xml_response/'images/image').each do |r|
|
69
|
+
r[:href].must_match /^http/
|
54
70
|
end
|
71
|
+
end
|
55
72
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
62
|
-
ids.sort.should == ids.sort.uniq
|
73
|
+
it 'must have the URL ending with the :id of the image' do
|
74
|
+
authenticate
|
75
|
+
get collection_url(:images)
|
76
|
+
(xml_response/'images/image').each do |r|
|
77
|
+
r[:href].must_match /#{r[:id]}$/
|
63
78
|
end
|
79
|
+
end
|
64
80
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
81
|
+
it 'must return the list of valid parameters for the :index action' do
|
82
|
+
authenticate
|
83
|
+
options collection_url(:images) + '/index'
|
84
|
+
last_response.headers['Allow'].wont_be_nil
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'must have the "name" element defined for each image in collection' do
|
88
|
+
authenticate
|
89
|
+
get collection_url(:images)
|
90
|
+
(xml_response/'images/image').each do |r|
|
91
|
+
(r/'name').wont_be_empty
|
73
92
|
end
|
93
|
+
end
|
74
94
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
95
|
+
it 'must have the "state" element defined for each image in collection' do
|
96
|
+
authenticate
|
97
|
+
get collection_url(:images)
|
98
|
+
(xml_response/'images/image').each do |r|
|
99
|
+
(r/'state').wont_be_empty
|
79
100
|
end
|
101
|
+
end
|
80
102
|
|
81
|
-
|
82
|
-
|
83
|
-
|
103
|
+
it 'must return the full "image" when following the URL in image element' do
|
104
|
+
authenticate
|
105
|
+
get collection_url(:images)
|
106
|
+
(xml_response/'images/image').each do |r|
|
107
|
+
get collection_url(:images) + '/' + r[:id]
|
108
|
+
last_response.status.must_equal 200
|
84
109
|
end
|
110
|
+
end
|
85
111
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
112
|
+
it 'must have the "name" element for the image and it should match with the one in collection' do
|
113
|
+
authenticate
|
114
|
+
get collection_url(:images)
|
115
|
+
(xml_response/'images/image').each do |r|
|
116
|
+
get collection_url(:images) + '/' + r[:id]
|
117
|
+
(xml_response/'name').wont_be_empty
|
118
|
+
(xml_response/'name').first.text.must_equal((r/'name').first.text)
|
90
119
|
end
|
120
|
+
end
|
91
121
|
|
92
|
-
|
93
|
-
|
94
|
-
|
122
|
+
it 'must have the "name" element for the image and it should match with the one in collection' do
|
123
|
+
authenticate
|
124
|
+
get collection_url(:images)
|
125
|
+
(xml_response/'images/image').each do |r|
|
126
|
+
get collection_url(:images) + '/' + r[:id]
|
127
|
+
(xml_response/'state').wont_be_empty
|
128
|
+
(xml_response/'state').first.text.must_equal((r/'state').first.text)
|
95
129
|
end
|
130
|
+
end
|
96
131
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
JSON::parse(last_response.body).class.should == Hash
|
104
|
-
JSON::parse(last_response.body)['image'].class.should == Hash
|
132
|
+
it 'should have the "owner_id" element for each image' do
|
133
|
+
authenticate
|
134
|
+
get collection_url(:images)
|
135
|
+
(xml_response/'images/image').each do |r|
|
136
|
+
get collection_url(:images) + '/' + r[:id]
|
137
|
+
(xml_response/'owner_id').wont_be_empty
|
105
138
|
end
|
139
|
+
end
|
106
140
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
Nokogiri::HTML(last_response.body).search('html').first.name.should == 'html'
|
141
|
+
it 'should have the "description" element for each image' do
|
142
|
+
authenticate
|
143
|
+
get collection_url(:images)
|
144
|
+
(xml_response/'images/image').each do |r|
|
145
|
+
get collection_url(:images) + '/' + r[:id]
|
146
|
+
(xml_response/'description').wont_be_empty
|
114
147
|
end
|
148
|
+
end
|
115
149
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
(
|
122
|
-
delete_url "/api/images/img4", {}
|
123
|
-
last_response.status.should == 204
|
124
|
-
get_auth_url "/api/images/img4", {}
|
125
|
-
last_response.status.should == 404
|
150
|
+
it 'should have the "architecture" element for each image' do
|
151
|
+
authenticate
|
152
|
+
get collection_url(:images)
|
153
|
+
(xml_response/'images/image').each do |r|
|
154
|
+
get collection_url(:images) + '/' + r[:id]
|
155
|
+
(xml_response/'architecture').wont_be_empty
|
126
156
|
end
|
157
|
+
end
|
127
158
|
|
128
|
-
|
159
|
+
it 'should include the list of compatible hardware_profiles for each image' do
|
160
|
+
authenticate
|
161
|
+
get collection_url(:images)
|
162
|
+
(xml_response/'images/image').each do |r|
|
163
|
+
get collection_url(:images) + '/' + r[:id]
|
164
|
+
(xml_response/'hardware_profiles/hardware_profile').wont_be_empty
|
165
|
+
(xml_response/'hardware_profiles/hardware_profile').each do |hwp|
|
166
|
+
hwp[:href].wont_be_nil
|
167
|
+
hwp[:href].must_match /^http/
|
168
|
+
hwp[:id].wont_be_nil
|
169
|
+
hwp[:href].must_match /\/#{hwp[:id]}$/
|
170
|
+
hwp[:rel].must_equal 'hardware_profile'
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
129
174
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
(
|
175
|
+
it 'should advertise the list of actions that can be executed for each image' do
|
176
|
+
authenticate
|
177
|
+
get collection_url(:images)
|
178
|
+
(xml_response/'images/image').each do |r|
|
179
|
+
get collection_url(:images) + '/' + r[:id]
|
180
|
+
(xml_response/'actions/link').wont_be_empty
|
181
|
+
(xml_response/'actions/link').each do |l|
|
182
|
+
l[:href].wont_be_nil
|
183
|
+
l[:href].must_match /^http/
|
184
|
+
l[:method].wont_be_nil
|
185
|
+
l[:rel].wont_be_nil
|
186
|
+
end
|
135
187
|
end
|
188
|
+
end
|
136
189
|
|
190
|
+
it 'should give client HTML form to create new image' do
|
191
|
+
authenticate
|
192
|
+
header 'Accept', 'text/html'
|
193
|
+
get collection_url(:images) + '/new'
|
194
|
+
last_response.status.must_equal 200
|
137
195
|
end
|
196
|
+
|
138
197
|
end
|
@@ -1,253 +1,343 @@
|
|
1
|
-
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
-
# contributor license agreements. See the NOTICE file distributed with
|
3
|
-
# this work for additional information regarding copyright ownership. The
|
4
|
-
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
-
# "License"); you may not use this file except in compliance with the
|
6
|
-
# License. You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
-
# License for the specific language governing permissions and limitations
|
14
|
-
# under the License.
|
15
|
-
#
|
16
|
-
|
17
1
|
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
18
|
-
require 'tests/common'
|
2
|
+
require 'tests/drivers/mock/common'
|
3
|
+
|
4
|
+
describe 'Deltacloud API instances' do
|
5
|
+
include Deltacloud::Test
|
6
|
+
|
7
|
+
it 'must advertise have the instances collection in API entrypoint' do
|
8
|
+
get root_url
|
9
|
+
(xml_response/'api/link[@rel=instances]').wont_be_empty
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'must require authentication to access the "instance" collection' do
|
13
|
+
get collection_url(:instances)
|
14
|
+
last_response.status.must_equal 401
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should respond with HTTP_OK when accessing the :instances collection with authentication' do
|
18
|
+
authenticate
|
19
|
+
get collection_url(:instances)
|
20
|
+
last_response.status.must_equal 200
|
21
|
+
end
|
19
22
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
+
it 'should support the JSON media type' do
|
24
|
+
authenticate
|
25
|
+
header 'Accept', 'application/json'
|
26
|
+
get collection_url(:instances)
|
27
|
+
last_response.status.must_equal 200
|
28
|
+
last_response.headers['Content-Type'].must_equal 'application/json'
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'must include the ETag in HTTP headers' do
|
32
|
+
authenticate
|
33
|
+
get collection_url(:instances)
|
34
|
+
last_response.headers['ETag'].wont_be_nil
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'must have the "instances" element on top level' do
|
38
|
+
authenticate
|
39
|
+
get collection_url(:instances)
|
40
|
+
xml_response.root.name.must_equal 'instances'
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'must have some "instance" elements inside "instances"' do
|
44
|
+
authenticate
|
45
|
+
get collection_url(:instances)
|
46
|
+
(xml_response/'instances/instance').wont_be_empty
|
47
|
+
end
|
23
48
|
|
24
|
-
|
25
|
-
|
49
|
+
it 'must provide the :id attribute for each instance in collection' do
|
50
|
+
authenticate
|
51
|
+
get collection_url(:instances)
|
52
|
+
(xml_response/'instances/instance').each do |r|
|
53
|
+
r[:id].wont_be_nil
|
26
54
|
end
|
55
|
+
end
|
27
56
|
|
28
|
-
|
29
|
-
|
57
|
+
it 'must include the :href attribute for each "instance" element in collection' do
|
58
|
+
authenticate
|
59
|
+
get collection_url(:instances)
|
60
|
+
(xml_response/'instances/instance').each do |r|
|
61
|
+
r[:href].wont_be_nil
|
30
62
|
end
|
63
|
+
end
|
31
64
|
|
32
|
-
|
33
|
-
|
34
|
-
|
65
|
+
it 'must use the absolute URL in each :href attribute' do
|
66
|
+
authenticate
|
67
|
+
get collection_url(:instances)
|
68
|
+
(xml_response/'instances/instance').each do |r|
|
69
|
+
r[:href].must_match /^http/
|
35
70
|
end
|
71
|
+
end
|
36
72
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
73
|
+
it 'must have the URL ending with the :id of the instance' do
|
74
|
+
authenticate
|
75
|
+
get collection_url(:instances)
|
76
|
+
(xml_response/'instances/instance').each do |r|
|
77
|
+
r[:href].must_match /#{r[:id]}$/
|
42
78
|
end
|
79
|
+
end
|
43
80
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
instance = (last_xml_response/'instances/instance[@id="inst1"]')
|
56
|
-
test_instance_attributes(instance)
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_it_returns_valid_realm
|
60
|
-
get_auth_url '/api/instances/inst1', {}
|
61
|
-
instance = (last_xml_response/'instance')
|
62
|
-
test_instance_attributes(instance)
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_it_responses_to_json
|
66
|
-
get_auth_url '/api/instances', {}, { :format => :json }
|
67
|
-
JSON::parse(last_response.body).class.should == Hash
|
68
|
-
JSON::parse(last_response.body)['instances'].class.should == Array
|
69
|
-
|
70
|
-
get_auth_url '/api/instances/inst1', {}, { :format => :json }
|
71
|
-
last_response.status.should == 200
|
72
|
-
JSON::parse(last_response.body).class.should == Hash
|
73
|
-
JSON::parse(last_response.body)['instance'].class.should == Hash
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_it_responses_to_html
|
77
|
-
get_auth_url '/api/instances', {}, { :format => :html }
|
78
|
-
last_response.status.should == 200
|
79
|
-
Nokogiri::HTML(last_response.body).search('html').first.name.should == 'html'
|
80
|
-
get_auth_url '/api/instances/inst1', {}, { :format => :html }
|
81
|
-
last_response.status.should == 200
|
82
|
-
Nokogiri::HTML(last_response.body).search('html').first.name.should == 'html'
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_it_create_a_new_instance_using_image_id
|
86
|
-
params = {
|
87
|
-
:image_id => 'img1'
|
88
|
-
}
|
89
|
-
post_url '/api/instances', params
|
90
|
-
last_response.status.should == 201
|
91
|
-
last_response.headers['Location'].should_not == nil
|
92
|
-
get_auth_url last_response.headers['Location'], {}
|
93
|
-
(last_xml_response/'instance/name').should_not == nil
|
94
|
-
add_created_instance (last_xml_response/'instance').first['id']
|
95
|
-
test_instance_attributes(last_xml_response/'instance')
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_it_create_a_new_instance_using_image_id_and_name
|
99
|
-
params = {
|
100
|
-
:image_id => 'img1',
|
101
|
-
:name => "unit_test_instance1"
|
102
|
-
}
|
103
|
-
post_url '/api/instances', params
|
104
|
-
last_response.status.should == 201
|
105
|
-
last_response.headers['Location'].should_not == nil
|
106
|
-
get_auth_url last_response.headers['Location'], {}
|
107
|
-
(last_xml_response/'instance/name').text.should == 'unit_test_instance1'
|
108
|
-
add_created_instance (last_xml_response/'instance').first['id']
|
109
|
-
test_instance_attributes(last_xml_response/'instance')
|
110
|
-
end
|
111
|
-
|
112
|
-
def test_it_create_a_new_instance_using_image_id_and_name_and_hwp_storage_and_hwp_cpu
|
113
|
-
params = {
|
114
|
-
:image_id => 'img1',
|
115
|
-
:realm_id => '',
|
116
|
-
:name => "unit_test_instance3",
|
117
|
-
:hwp_id => "m1-large",
|
118
|
-
:hwp_storage => '850',
|
119
|
-
:hwp_memory => '7680.0',
|
120
|
-
:hwp_cpu => "1.0",
|
121
|
-
}
|
122
|
-
post_url '/api/instances', params
|
123
|
-
last_response.status.should == 400
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_it_create_a_new_instance_using_image_id_and_name_and_hwp_storage
|
127
|
-
params = {
|
128
|
-
:image_id => 'img1',
|
129
|
-
:name => "unit_test_instance2",
|
130
|
-
:hwp_id => "m1-small",
|
131
|
-
:hwp_storage => "160"
|
132
|
-
}
|
133
|
-
post_url '/api/instances', params
|
134
|
-
last_response.status.should == 201
|
135
|
-
last_response.headers['Location'].should_not == nil
|
136
|
-
get_auth_url last_response.headers['Location'], {}
|
137
|
-
(last_xml_response/'instance/name').text.should == 'unit_test_instance2'
|
138
|
-
(last_xml_response/'instance/hardware_profile').first['id'].should == 'm1-small'
|
139
|
-
add_created_instance (last_xml_response/'instance').first['id']
|
140
|
-
test_instance_attributes(last_xml_response/'instance')
|
141
|
-
end
|
142
|
-
|
143
|
-
def test_it_z0_stop_and_start_instance
|
144
|
-
$created_instances.each do |instance_id|
|
145
|
-
get_auth_url "/api/instances/#{instance_id}", {}
|
146
|
-
stop_url = (last_xml_response/'actions/link[@rel="stop"]').first['href']
|
147
|
-
stop_url.should_not == nil
|
148
|
-
post_url stop_url
|
149
|
-
last_response.status.should == 200
|
150
|
-
instance = Nokogiri::XML(last_response.body)
|
151
|
-
test_instance_attributes(instance)
|
152
|
-
(instance/'state').text.should == 'STOPPED'
|
153
|
-
get_auth_url "/api/instances/#{instance_id}", {}
|
154
|
-
start_url = (last_xml_response/'actions/link[@rel="start"]').first['href']
|
155
|
-
start_url.should_not == nil
|
156
|
-
post_url start_url
|
157
|
-
last_response.status.should == 200
|
158
|
-
instance = Nokogiri::XML(last_response.body)
|
159
|
-
test_instance_attributes(instance)
|
160
|
-
(instance/'state').text.should == 'RUNNING'
|
161
|
-
end
|
81
|
+
it 'must return the list of valid parameters for the :index action' do
|
82
|
+
authenticate
|
83
|
+
options collection_url(:instances) + '/index'
|
84
|
+
last_response.headers['Allow'].wont_be_nil
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'must have the "name" element defined for each instance in collection' do
|
88
|
+
authenticate
|
89
|
+
get collection_url(:instances)
|
90
|
+
(xml_response/'instances/instance').each do |r|
|
91
|
+
(r/'name').wont_be_empty
|
162
92
|
end
|
93
|
+
end
|
163
94
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
last_response.status.should == 200
|
171
|
-
instance = Nokogiri::XML(last_response.body)
|
172
|
-
test_instance_attributes(instance)
|
173
|
-
(instance/'state').text.should == 'RUNNING'
|
174
|
-
end
|
95
|
+
it 'must have the "state" element defined for each instance in collection' do
|
96
|
+
authenticate
|
97
|
+
get collection_url(:instances)
|
98
|
+
(xml_response/'instances/instance').each do |r|
|
99
|
+
(r/'state').wont_be_empty
|
100
|
+
(r/'state').first.must_match /(RUNNING|STOPPED|PENDING)/
|
175
101
|
end
|
102
|
+
end
|
176
103
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
last_response.status.should == 200
|
184
|
-
instance = Nokogiri::XML(last_response.body)
|
185
|
-
test_instance_attributes(instance)
|
186
|
-
(instance/'state').text.should == 'STOPPED'
|
187
|
-
end
|
104
|
+
it 'must return the full "instance" when following the URL in instance element' do
|
105
|
+
authenticate
|
106
|
+
get collection_url(:instances)
|
107
|
+
(xml_response/'instances/instance').each do |r|
|
108
|
+
get collection_url(:instances) + '/' + r[:id]
|
109
|
+
last_response.status.must_equal 200
|
188
110
|
end
|
111
|
+
end
|
189
112
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
113
|
+
it 'must have the "name" element for the instance and it should match with the one in collection' do
|
114
|
+
authenticate
|
115
|
+
get collection_url(:instances)
|
116
|
+
(xml_response/'instances/instance').each do |r|
|
117
|
+
get collection_url(:instances) + '/' + r[:id]
|
118
|
+
(xml_response/'name').wont_be_empty
|
119
|
+
(xml_response/'name').first.text.must_equal((r/'name').first.text)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'must have the "name" element for the instance and it should match with the one in collection' do
|
124
|
+
authenticate
|
125
|
+
get collection_url(:instances)
|
126
|
+
(xml_response/'instances/instance').each do |r|
|
127
|
+
get collection_url(:instances) + '/' + r[:id]
|
128
|
+
(xml_response/'state').wont_be_empty
|
129
|
+
(xml_response/'state').first.text.must_equal((r/'state').first.text)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'must have the "owner_id" element for the instance and it should match with the one in collection' do
|
134
|
+
authenticate
|
135
|
+
get collection_url(:instances)
|
136
|
+
(xml_response/'instances/instance').each do |r|
|
137
|
+
get collection_url(:instances) + '/' + r[:id]
|
138
|
+
(xml_response/'owner_id').wont_be_empty
|
139
|
+
(xml_response/'owner_id').first.text.must_equal((r/'owner_id').first.text)
|
198
140
|
end
|
141
|
+
end
|
199
142
|
|
200
|
-
|
201
|
-
|
202
|
-
|
143
|
+
it 'must link to the realm that was used to during instance creation' do
|
144
|
+
authenticate
|
145
|
+
get collection_url(:instances)
|
146
|
+
(xml_response/'instances/instance').each do |r|
|
147
|
+
get collection_url(:instances) + '/' + r[:id]
|
148
|
+
(xml_response/'realm').wont_be_empty
|
149
|
+
(xml_response/'realm').size.must_equal 1
|
150
|
+
(xml_response/'realm').first[:id].wont_be_nil
|
151
|
+
(xml_response/'realm').first[:href].wont_be_nil
|
152
|
+
(xml_response/'realm').first[:href].must_match /\/#{(xml_response/'realm').first[:id]}$/
|
203
153
|
end
|
154
|
+
end
|
204
155
|
|
205
|
-
|
156
|
+
it 'must link to the image that was used to during instance creation' do
|
157
|
+
authenticate
|
158
|
+
get collection_url(:instances)
|
159
|
+
(xml_response/'instances/instance').each do |r|
|
160
|
+
get collection_url(:instances) + '/' + r[:id]
|
161
|
+
(xml_response/'image').wont_be_empty
|
162
|
+
(xml_response/'image').size.must_equal 1
|
163
|
+
(xml_response/'image').first[:id].wont_be_nil
|
164
|
+
(xml_response/'image').first[:href].wont_be_nil
|
165
|
+
(xml_response/'image').first[:href].must_match /\/#{(xml_response/'image').first[:id]}$/
|
166
|
+
end
|
167
|
+
end
|
206
168
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
169
|
+
it 'must link to the hardware_profile that was used to during instance creation' do
|
170
|
+
authenticate
|
171
|
+
get collection_url(:instances)
|
172
|
+
(xml_response/'instances/instance').each do |r|
|
173
|
+
get collection_url(:instances) + '/' + r[:id]
|
174
|
+
(xml_response/'hardware_profile').wont_be_empty
|
175
|
+
(xml_response/'hardware_profile').size.must_equal 1
|
176
|
+
(xml_response/'hardware_profile').first[:id].wont_be_nil
|
177
|
+
(xml_response/'hardware_profile').first[:href].wont_be_nil
|
178
|
+
(xml_response/'hardware_profile').first[:href].must_match /\/#{(xml_response/'hardware_profile').first[:id]}$/
|
179
|
+
end
|
180
|
+
end
|
211
181
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
182
|
+
it 'should advertise the public and private addresses of the instance' do
|
183
|
+
authenticate
|
184
|
+
get collection_url(:instances)
|
185
|
+
(xml_response/'instances/instance').each do |r|
|
186
|
+
get collection_url(:instances) + '/' + r[:id]
|
187
|
+
(xml_response/'public_addresses').wont_be_empty
|
188
|
+
(xml_response/'public_addresses').size.must_equal 1
|
189
|
+
(xml_response/'public_addresses/address').each do |a|
|
190
|
+
a[:type].wont_be_nil
|
191
|
+
a.text.strip.wont_be_empty
|
192
|
+
end
|
193
|
+
(xml_response/'private_addresses').wont_be_empty
|
194
|
+
(xml_response/'private_addresses').size.must_equal 1
|
195
|
+
(xml_response/'private_addresses/address').each do |a|
|
196
|
+
a[:type].wont_be_nil
|
197
|
+
a.text.strip.wont_be_empty
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
216
201
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
202
|
+
it 'should advertise the storage volumes used by the instance' do
|
203
|
+
authenticate
|
204
|
+
get collection_url(:instances)
|
205
|
+
(xml_response/'instances/instance').each do |r|
|
206
|
+
get collection_url(:instances) + '/' + r[:id]
|
207
|
+
(xml_response/'storage_volumes').wont_be_empty
|
208
|
+
end
|
209
|
+
end
|
221
210
|
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
211
|
+
it 'should advertise the list of actions that can be executed for each instance' do
|
212
|
+
authenticate
|
213
|
+
get collection_url(:instances)
|
214
|
+
(xml_response/'instances/instance').each do |r|
|
215
|
+
get collection_url(:instances) + '/' + r[:id]
|
216
|
+
(xml_response/'actions/link').wont_be_empty
|
217
|
+
(xml_response/'actions/link').each do |l|
|
218
|
+
l[:href].wont_be_nil
|
219
|
+
l[:href].must_match /^http/
|
220
|
+
l[:method].wont_be_nil
|
221
|
+
l[:rel].wont_be_nil
|
228
222
|
end
|
223
|
+
end
|
224
|
+
end
|
229
225
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
226
|
+
it 'should allow to create and destroy new instance using the first available image without realm' do
|
227
|
+
authenticate
|
228
|
+
get collection_url(:images)
|
229
|
+
image_id = (xml_response/'images/image').first[:id]
|
230
|
+
image_id.wont_be_nil
|
231
|
+
post collection_url(:instances), {
|
232
|
+
:image_id => image_id
|
233
|
+
}
|
234
|
+
last_response.status.must_equal 201 # HTTP_CREATED
|
235
|
+
last_response.headers['Location'].wont_be_nil # Location header must be set, pointing to new the instance
|
236
|
+
instance_id = last_response.headers['Location'].split('/').last
|
237
|
+
# Get the instance and check if ID and image is set correctly
|
238
|
+
get collection_url(:instances) + '/' + instance_id
|
239
|
+
last_response.status.must_equal 200 # HTTP_OK
|
240
|
+
(xml_response/'instance').first[:id].must_equal instance_id
|
241
|
+
(xml_response/'instance/image').first[:id].must_equal image_id
|
242
|
+
# If instance is RUNNING then stop it
|
243
|
+
if (xml_response/'instance/state').first.text == 'RUNNING'
|
244
|
+
post collection_url(:instances) + '/' + instance_id + '/stop'
|
245
|
+
last_response.status.must_equal 202 # HTTP_NO_CONTENT
|
246
|
+
end
|
247
|
+
# Delete created instance
|
248
|
+
delete collection_url(:instances) + '/' + instance_id
|
249
|
+
last_response.status.must_equal 204 # HTTP_NO_CONTENT
|
250
|
+
end
|
236
251
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
252
|
+
it 'should allow to create and destroy new instance using the first available image within first realm' do
|
253
|
+
authenticate
|
254
|
+
get collection_url(:images)
|
255
|
+
image_id = (xml_response/'images/image').first[:id]
|
256
|
+
get collection_url(:realms)
|
257
|
+
realm_id = (xml_response/'realms/realm').first[:id]
|
258
|
+
image_id.wont_be_nil
|
259
|
+
realm_id.wont_be_nil
|
260
|
+
post collection_url(:instances), {
|
261
|
+
:image_id => image_id,
|
262
|
+
:realm_id => realm_id,
|
263
|
+
}
|
264
|
+
last_response.status.must_equal 201 # HTTP_CREATED
|
265
|
+
last_response.headers['Location'].wont_be_nil # Location header must be set, pointing to new the instance
|
266
|
+
instance_id = last_response.headers['Location'].split('/').last
|
267
|
+
# Get the instance and check if ID and image is set correctly
|
268
|
+
get collection_url(:instances) + '/' + instance_id
|
269
|
+
last_response.status.must_equal 200 # HTTP_OK
|
270
|
+
(xml_response/'instance').first[:id].must_equal instance_id
|
271
|
+
(xml_response/'instance/image').first[:id].must_equal image_id
|
272
|
+
(xml_response/'instance/realm').first[:id].must_equal realm_id
|
273
|
+
# If instance is RUNNING then stop it
|
274
|
+
if (xml_response/'instance/state').first.text == 'RUNNING'
|
275
|
+
post collection_url(:instances) + '/' + instance_id + '/stop'
|
276
|
+
last_response.status.must_equal 202 # HTTP_NO_CONTENT
|
277
|
+
end
|
278
|
+
# Delete created instance
|
279
|
+
delete collection_url(:instances) + '/' + instance_id
|
280
|
+
last_response.status.must_equal 204 # HTTP_NO_CONTENT
|
281
|
+
end
|
243
282
|
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
283
|
+
it 'should allow to create and destroy new instance using the first available image with user defined name' do
|
284
|
+
authenticate
|
285
|
+
get collection_url(:images)
|
286
|
+
image_id = (xml_response/'images/image').first[:id]
|
287
|
+
image_id.wont_be_nil
|
288
|
+
name = "i#{Time.now.to_i}"
|
289
|
+
post collection_url(:instances), {
|
290
|
+
:image_id => image_id,
|
291
|
+
:name => name
|
292
|
+
}
|
293
|
+
last_response.status.must_equal 201 # HTTP_CREATED
|
294
|
+
last_response.headers['Location'].wont_be_nil # Location header must be set, pointing to new the instance
|
295
|
+
instance_id = last_response.headers['Location'].split('/').last
|
296
|
+
# Get the instance and check if ID and image is set correctly
|
297
|
+
get collection_url(:instances) + '/' + instance_id
|
298
|
+
last_response.status.must_equal 200 # HTTP_OK
|
299
|
+
(xml_response/'instance').first[:id].must_equal instance_id
|
300
|
+
(xml_response/'instance/image').first[:id].must_equal image_id
|
301
|
+
(xml_response/'instance/name').first.text.must_equal name
|
302
|
+
# If instance is RUNNING then stop it
|
303
|
+
if (xml_response/'instance/state').first.text == 'RUNNING'
|
304
|
+
post collection_url(:instances) + '/' + instance_id + '/stop'
|
305
|
+
last_response.status.must_equal 202 # HTTP_NO_CONTENT
|
250
306
|
end
|
307
|
+
# Delete created instance
|
308
|
+
delete collection_url(:instances) + '/' + instance_id
|
309
|
+
last_response.status.must_equal 204 # HTTP_NO_CONTENT
|
310
|
+
end
|
251
311
|
|
312
|
+
it 'should allow to create and destroy new instance using the first available image and first hardware_profile' do
|
313
|
+
authenticate
|
314
|
+
get collection_url(:images)
|
315
|
+
image_id = (xml_response/'images/image').first[:id]
|
316
|
+
get collection_url(:hardware_profiles)
|
317
|
+
hwp_id = (xml_response/'hardware_profiles/hardware_profile').first[:id]
|
318
|
+
image_id.wont_be_nil
|
319
|
+
name = "i#{Time.now.to_i}"
|
320
|
+
post collection_url(:instances), {
|
321
|
+
:image_id => image_id,
|
322
|
+
:hwp_id => hwp_id
|
323
|
+
}
|
324
|
+
last_response.status.must_equal 201 # HTTP_CREATED
|
325
|
+
last_response.headers['Location'].wont_be_nil # Location header must be set, pointing to new the instance
|
326
|
+
instance_id = last_response.headers['Location'].split('/').last
|
327
|
+
# Get the instance and check if ID and image is set correctly
|
328
|
+
get collection_url(:instances) + '/' + instance_id
|
329
|
+
last_response.status.must_equal 200 # HTTP_OK
|
330
|
+
(xml_response/'instance').first[:id].must_equal instance_id
|
331
|
+
(xml_response/'instance/image').first[:id].must_equal image_id
|
332
|
+
(xml_response/'instance/hardware_profile').first[:id].must_equal hwp_id
|
333
|
+
# If instance is RUNNING then stop it
|
334
|
+
if (xml_response/'instance/state').first.text == 'RUNNING'
|
335
|
+
post collection_url(:instances) + '/' + instance_id + '/stop'
|
336
|
+
last_response.status.must_equal 202 # HTTP_NO_CONTENT
|
337
|
+
end
|
338
|
+
# Delete created instance
|
339
|
+
delete collection_url(:instances) + '/' + instance_id
|
340
|
+
last_response.status.must_equal 204 # HTTP_NO_CONTENT
|
252
341
|
end
|
342
|
+
|
253
343
|
end
|