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,14 +1,13 @@
|
|
1
|
-
ENV
|
2
|
-
ENV['
|
3
|
-
ENV['
|
1
|
+
ENV.delete 'API_VERBOSE'
|
2
|
+
ENV['API_DRIVER'] = "fgcp"
|
3
|
+
ENV['API_USER'] = 'cert-dir'
|
4
|
+
ENV['API_PASSWORD'] = 'secret'
|
4
5
|
|
5
6
|
require 'vcr'
|
6
|
-
|
7
7
|
DeltacloudTestCommon::record!
|
8
8
|
|
9
9
|
VCR.config do |c|
|
10
|
-
c.cassette_library_dir = "#{File.dirname(__FILE__)}/../../../tests/drivers/
|
10
|
+
c.cassette_library_dir = "#{File.dirname(__FILE__)}/../../../tests/drivers/fgcp/fixtures/"
|
11
11
|
c.stub_with :webmock
|
12
12
|
c.default_cassette_options = { :record => :new_episodes }
|
13
13
|
end
|
14
|
-
|
@@ -1,35 +1,19 @@
|
|
1
1
|
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
2
|
-
require 'tests/common'
|
2
|
+
require 'tests/drivers/google/common'
|
3
3
|
|
4
|
-
|
4
|
+
describe 'Deltacloud API' do
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
before do
|
7
|
+
VCR.insert_cassette __name__
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
after do
|
11
|
+
VCR.eject_cassette
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
get_auth_url '/api;driver=google/?force_auth=1'
|
15
|
-
(last_xml_response/'/api').first[:driver].should == 'google'
|
16
|
-
(last_xml_response/'/api/link').length.should > 0
|
17
|
-
end
|
14
|
+
include Deltacloud::Test
|
18
15
|
|
19
|
-
|
20
|
-
get_url '/api;driver=google'
|
21
|
-
features = (last_xml_response/'/api/link[@rel="buckets"]/feature').collect { |f| f[:name] }
|
22
|
-
features.include?('bucket_location').should == true
|
23
|
-
features.length.should == 1
|
24
|
-
end
|
16
|
+
eval File.read('tests/minitest_common_api_test.rb')
|
25
17
|
|
26
|
-
def test_03_it_has_google_collections
|
27
|
-
get_url '/api;driver=google'
|
28
|
-
collections = (last_xml_response/'/api/link').collect { |f| f[:rel] }
|
29
|
-
collections.include?('buckets').should == true
|
30
|
-
collections.include?('drivers').should == true
|
31
|
-
collections.length.should == 2
|
32
|
-
end
|
33
18
|
|
34
|
-
end
|
35
19
|
end
|
@@ -1,116 +1,100 @@
|
|
1
1
|
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
2
|
-
require 'tests/common'
|
3
|
-
#require 'webmock/test_unit'
|
4
|
-
module GoogleTest
|
2
|
+
require 'tests/drivers/google/common'
|
5
3
|
|
6
|
-
|
7
|
-
include Rack::Test::Methods
|
4
|
+
describe 'Deltacloud API' do
|
8
5
|
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
before do
|
7
|
+
VCR.insert_cassette __name__
|
8
|
+
end
|
9
|
+
|
10
|
+
after do
|
11
|
+
VCR.eject_cassette
|
12
|
+
end
|
13
|
+
|
14
|
+
include Deltacloud::Test
|
15
|
+
|
16
|
+
i_suck_and_my_tests_are_order_dependent!
|
12
17
|
|
13
18
|
@@bucket_name_google="#{@@created_bucket_name}googel"
|
14
19
|
@@blob_name_google="#{@@created_blob_name}googel"
|
15
20
|
#intentional typos here - bucket names cannot contain 'google'
|
16
21
|
#see http://code.google.com/apis/storage/docs/reference/v1/developer-guidev1.html
|
22
|
+
it 'can create a new bucket' do
|
23
|
+
authenticate
|
24
|
+
bucket_name = @@bucket_name_google
|
25
|
+
post collection_url(:buckets), {:name=>bucket_name}
|
26
|
+
last_response.status.must_equal 201
|
27
|
+
bucket = xml_response
|
28
|
+
check_bucket_basics(bucket, "googel")
|
29
|
+
(bucket/'bucket/size').first.text.must_equal "0"
|
30
|
+
end
|
17
31
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
params = {
|
34
|
-
'blob_id' => @@blob_name_google,
|
35
|
-
:meta_params=>"2",
|
36
|
-
:meta_name1=>"Author",
|
37
|
-
:meta_value1=>"deltacloud",
|
38
|
-
:meta_name2=>"foo",
|
39
|
-
:meta_value2=>"bar",
|
40
|
-
:'api[driver]' => 'google'
|
41
|
-
}
|
42
|
-
uri="/api/buckets/#{@@bucket_name_google}"
|
43
|
-
vcr_cassette = stable_vcr_cassette_name('post', uri, params)
|
44
|
-
params.merge!({'blob_data' => Rack::Test::UploadedFile.new(temp_file.path, "text/html")})
|
45
|
-
post_url uri, params, {'vcr_cassette'=>vcr_cassette}
|
46
|
-
last_response.status.should == 200
|
47
|
-
blob= last_xml_response
|
48
|
-
check_blob_basics(blob, "googel")
|
49
|
-
end
|
32
|
+
it 'can create a new blob with HTTP POST' do
|
33
|
+
authenticate
|
34
|
+
temp_file=File.open(@@created_blob_local_file)
|
35
|
+
params = { 'blob_id' => @@blob_name_google,
|
36
|
+
:meta_params=>"2",
|
37
|
+
:meta_name1=>"Author",
|
38
|
+
:meta_value1=>"deltacloud",
|
39
|
+
:meta_name2=>"foo",
|
40
|
+
:meta_value2=>"bar",
|
41
|
+
'blob_data' => Rack::Test::UploadedFile.new(temp_file.path, "text/html") }
|
42
|
+
post "#{collection_url(:buckets)}/#{@@bucket_name_google}", params
|
43
|
+
last_response.status.must_equal 200
|
44
|
+
blob = xml_response
|
45
|
+
check_blob_basics(blob, "googel")
|
46
|
+
end
|
50
47
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
(bucket/'bucket/size').first.text.should == "1" #assuming blob created succesfully right?
|
60
|
-
end
|
48
|
+
it 'can retrieve named bucket details' do
|
49
|
+
authenticate
|
50
|
+
get "#{collection_url(:buckets)}/#{@@bucket_name_google}"
|
51
|
+
last_response.status.must_equal 200
|
52
|
+
bucket = xml_response
|
53
|
+
check_bucket_basics(bucket, "googel")
|
54
|
+
(bucket/'bucket/size').first.text.must_equal "1" #assuming blob created succesfully right?
|
55
|
+
end
|
61
56
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
last_response.status.should == 200
|
68
|
-
blob = last_xml_response
|
57
|
+
it 'can retrieve details of a named blob' do
|
58
|
+
authenticate
|
59
|
+
get "#{collection_url(:buckets)}/#{@@bucket_name_google}/#{@@blob_name_google}"
|
60
|
+
last_response.status.must_equal 200
|
61
|
+
blob = xml_response
|
69
62
|
check_blob_basics(blob, "googel")
|
70
63
|
check_blob_metadata(blob, {"author"=>"deltacloud", "foo"=>"bar"})
|
71
|
-
|
64
|
+
end
|
72
65
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
({"author"=>"deltacloud", "foo"=>"bar"}.eql?(blob_meta_hash)).should == true
|
82
|
-
end
|
66
|
+
it 'can retrieve named blob metadata' do
|
67
|
+
authenticate
|
68
|
+
head "#{collection_url(:buckets)}/#{@@bucket_name_google}/#{@@blob_name_google}"
|
69
|
+
last_response.status.must_equal 204
|
70
|
+
blob_meta_hash = last_response.headers.inject({}){|result, (k,v)| result[k]=v if k=~/^X-Deltacloud-Blobmeta-/i ; result}
|
71
|
+
blob_meta_hash.gsub_keys(/x-.*meta-/i, "")
|
72
|
+
{"author"=>"deltacloud", "foo"=>"bar"}.must_equal blob_meta_hash
|
73
|
+
end
|
83
74
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
new_meta.each_pair do |k,v|
|
90
|
-
header k, v
|
91
|
-
end
|
92
|
-
post_url "/api/buckets/#{@@bucket_name_google}/#{@@blob_name_google}", params
|
93
|
-
last_response.status.should == 204
|
94
|
-
new_meta.each_pair do |k,v|
|
95
|
-
(last_response.headers[k]==v).should == true
|
96
|
-
end
|
75
|
+
it 'can update blob metadata' do
|
76
|
+
authenticate
|
77
|
+
new_meta = {"X-Deltacloud-Blobmeta-author" => "ApacheDeltacloud", "X-Deltacloud-Blobmeta-oof" => "rab"}
|
78
|
+
new_meta.each_pair do |k,v|
|
79
|
+
header k, v
|
97
80
|
end
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
}
|
103
|
-
delete_url "/api/buckets/#{@@bucket_name_google}/#{@@blob_name_google}", params
|
104
|
-
last_response.status.should == 204
|
81
|
+
post "#{collection_url(:buckets)}/#{@@bucket_name_google}/#{@@blob_name_google}"
|
82
|
+
last_response.status.must_equal 204
|
83
|
+
new_meta.each_pair do |k,v|
|
84
|
+
last_response.headers[k].must_equal v
|
105
85
|
end
|
86
|
+
end
|
106
87
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
last_response.status.should == 204
|
113
|
-
end
|
88
|
+
it 'can delete blob' do
|
89
|
+
authenticate
|
90
|
+
delete "#{collection_url(:buckets)}/#{@@bucket_name_google}/#{@@blob_name_google}"
|
91
|
+
last_response.status.must_equal 204
|
92
|
+
end
|
114
93
|
|
94
|
+
it 'can delete bucket' do
|
95
|
+
authenticate
|
96
|
+
delete "#{collection_url(:buckets)}/#{@@bucket_name_google}"
|
97
|
+
last_response.status.must_equal 204
|
115
98
|
end
|
99
|
+
|
116
100
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
ENV['API_DRIVER'] = "google"
|
2
|
+
ENV['TESTS_API_USERNAME'] = 'GOOGUM2I5ZVSPSV5H42U'
|
3
|
+
ENV['TESTS_API_PASSWORD'] = 'sXhLOsE4SYU+M7SKsTwwNX2YPpMOKIiRyZaZxcBp'
|
4
|
+
|
5
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
6
|
+
require 'tests/minitest_common'
|
7
|
+
|
8
|
+
require 'vcr'
|
9
|
+
|
10
|
+
VCR.configure do |c|
|
11
|
+
c.cassette_library_dir = "#{File.dirname(__FILE__)}/fixtures/"
|
12
|
+
c.hook_into :excon
|
13
|
+
c.default_cassette_options = { :record => :new_episodes}
|
14
|
+
end
|
15
|
+
|
16
|
+
#the following can probably be moved to somewhere more 'common'
|
17
|
+
#once other driver tests start using them (e.g. openstack).
|
18
|
+
|
19
|
+
@@created_bucket_name="testbucki2rpux3wdelme"
|
20
|
+
@@created_blob_name="testblobk1ds91kVdelme"
|
21
|
+
@@created_blob_local_file="#{File.dirname(__FILE__)}/../common_fixtures/deltacloud_blob_test.png"
|
22
|
+
|
23
|
+
def check_bucket_basics(bucket, cloud)
|
24
|
+
(bucket/'bucket/name').first.text.must_equal "#{@@created_bucket_name}#{cloud}"
|
25
|
+
(bucket/'bucket').attribute("id").text.must_equal "#{@@created_bucket_name}#{cloud}"
|
26
|
+
(bucket/'bucket').length.must_be :>, 0
|
27
|
+
(bucket/'bucket/name').first.text.wont_be_nil
|
28
|
+
(bucket/'bucket').attribute("href").text.wont_be_nil
|
29
|
+
end
|
30
|
+
|
31
|
+
def check_blob_basics(blob, cloud)
|
32
|
+
(blob/'blob').length.must_equal 1
|
33
|
+
(blob/'blob').attribute("id").text.wont_be_nil
|
34
|
+
(blob/'blob').attribute("href").text.wont_be_nil
|
35
|
+
(blob/'blob/bucket').text.wont_be_nil
|
36
|
+
(blob/'blob/content_length').text.wont_be_nil
|
37
|
+
(blob/'blob/content_type').text.wont_be_nil
|
38
|
+
(blob/'blob').attribute("id").text.must_equal "#{@@created_blob_name}#{cloud}"
|
39
|
+
(blob/'blob/bucket').text.must_equal "#{@@created_bucket_name}#{cloud}"
|
40
|
+
(blob/'blob/content_length').text.to_i.must_equal File.size(@@created_blob_local_file)
|
41
|
+
end
|
42
|
+
|
43
|
+
def check_blob_metadata(blob, metadata_hash)
|
44
|
+
meta_from_blob = {}
|
45
|
+
#extract metadata from nokogiri blob xml
|
46
|
+
(0.. (((blob/'blob/user_metadata').first).elements.size - 1) ).each do |i|
|
47
|
+
meta_from_blob[(((blob/'blob/user_metadata').first).elements[i].attribute("key").value)] =
|
48
|
+
(((blob/'blob/user_metadata').first).elements[i].children[1].text)
|
49
|
+
end
|
50
|
+
#remove any 'x-goog-meta-' prefixes (problem for google blobs and vcr...)
|
51
|
+
meta_from_blob.gsub_keys(/x-.*-meta-/i, "")
|
52
|
+
meta_from_blob.must_equal metadata_hash
|
53
|
+
end
|
54
|
+
|
@@ -1,133 +1,10 @@
|
|
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'
|
19
|
-
|
20
|
-
module DeltacloudUnitTest
|
21
|
-
class ApiTest < Test::Unit::TestCase
|
22
|
-
include Rack::Test::Methods
|
23
|
-
|
24
|
-
def app
|
25
|
-
Sinatra::Application
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_it_returns_entry_points
|
29
|
-
get_auth_url '/api'
|
30
|
-
(last_xml_response/'/api/link').length.should > 0
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_it_has_correct_attributes_set
|
34
|
-
get_auth_url '/api'
|
35
|
-
(last_xml_response/'/api/link').each do |link|
|
36
|
-
link.attributes.keys.sort.should == [ 'href', 'rel' ]
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_it_responses_to_html
|
41
|
-
get_url '/api', {}, { :format => :html }
|
42
|
-
last_response.status.should == 200
|
43
|
-
Nokogiri::HTML(last_response.body).search('html').first.name.should == 'html'
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_it_responses_to_json
|
47
|
-
get_url '/api', {}, { :format => :json }
|
48
|
-
last_response.status.should == 200
|
49
|
-
JSON::parse(last_response.body).class.should == Hash
|
50
|
-
JSON::parse(last_response.body)['api'].class.should == Hash
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_it_switches_drivers
|
54
|
-
with_provider("") do
|
55
|
-
get_auth_url '/api'
|
56
|
-
(last_xml_response/"api/link[rel = 'instances']").first.should_not == nil
|
57
|
-
end
|
58
|
-
|
59
|
-
# Switch to storage-only mock driver
|
60
|
-
with_provider("storage") do
|
61
|
-
get_auth_url '/api'
|
62
|
-
(last_xml_response/"api/link[rel = 'instances']").first.should == nil
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_it_handles_unsupported_collections
|
67
|
-
get_auth_url '/api/no_such_collection'
|
68
|
-
last_response.status.should == 404
|
69
|
-
|
70
|
-
with_provider("storage") do
|
71
|
-
get_auth_url '/api/instances'
|
72
|
-
last_response.status.should == 403
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_it_allows_accessing_docs
|
77
|
-
get_url '/api/docs/instances'
|
78
|
-
last_response.status.should == 200
|
79
|
-
|
80
|
-
with_provider("storage") do
|
81
|
-
get_url '/api/docs/instances'
|
82
|
-
last_response.status.should == 403
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_it_respond_to_head
|
87
|
-
head '/api/instances'
|
88
|
-
last_response.headers['Allow'].should_not == nil
|
89
|
-
last_response.headers['Allow'].split(',').include?('HEAD').should == true
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_it_expose_available_drivers
|
93
|
-
get_auth_url '/api/drivers'
|
94
|
-
last_response.status.should == 200
|
95
|
-
(last_xml_response/"drivers").length.should > 0
|
96
|
-
(last_xml_response/'drivers/driver').length.should > 0
|
97
|
-
(last_xml_response/"drivers/driver[@id = 'mock']").length.should == 1
|
98
|
-
end
|
2
|
+
require 'tests/drivers/mock/common'
|
99
3
|
|
100
|
-
|
101
|
-
get_auth_url '/api/drivers'
|
102
|
-
last_response.status.should == 200
|
103
|
-
ec2 = (last_xml_response/'drivers/driver[@id=ec2]').first
|
104
|
-
(ec2/"provider").length.should > 0
|
105
|
-
(ec2/"provider[@id = 'eu-west-1']").length.should == 1
|
106
|
-
get_auth_url ec2[:href]
|
107
|
-
eu_west = (last_xml_response/"provider[@id = 'eu-west-1']").first
|
108
|
-
(eu_west/"entrypoint").length.should > 0
|
109
|
-
(eu_west/"entrypoint[@kind = 'ec2']").length.should == 1
|
110
|
-
end
|
4
|
+
describe 'Deltacloud API' do
|
111
5
|
|
112
|
-
|
113
|
-
get_auth_url "/api;driver=ec2"
|
114
|
-
last_response.status.should == 200
|
115
|
-
(last_xml_response/'api').first[:driver].should == 'ec2'
|
116
|
-
get_auth_url "/api;driver=mock"
|
117
|
-
(last_xml_response/'api').first[:driver].should == 'mock'
|
118
|
-
get_auth_url "/api;driver=ec2/hardware_profiles"
|
119
|
-
(last_xml_response/'hardware_profiles/hardware_profile/@id').map {|n| n.to_s}.include?('m1.small').should == true
|
120
|
-
last_response.status.should == 200
|
121
|
-
end
|
6
|
+
include Deltacloud::Test
|
122
7
|
|
123
|
-
|
124
|
-
get_auth_url "/api;driver=ec2"
|
125
|
-
(last_xml_response/'api/link[@rel="instances"]/feature[@name="user_name"]').first.should == nil
|
126
|
-
(last_xml_response/'api/link[@rel="instances"]/feature[@name="user_data"]').first.should_not == nil
|
127
|
-
get_auth_url "/api;driver=mock"
|
128
|
-
(last_xml_response/'api/link[@rel="instances"]/feature[@name="user_name"]').first.should_not == nil
|
129
|
-
(last_xml_response/'api/link[@rel="instances"]/feature[@name="firewalls"]').first.should == nil
|
130
|
-
end
|
8
|
+
eval File.read('tests/minitest_common_api_test.rb')
|
131
9
|
|
132
|
-
end
|
133
10
|
end
|