deltacloud-core 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -1
- data/bin/deltacloudd +11 -5
- data/config.ru +3 -3
- data/deltacloud-core.gemspec +24 -18
- data/lib/cimi/collections/address_templates.rb +3 -3
- data/lib/cimi/collections/addresses.rb +6 -5
- data/lib/cimi/collections/entity_metadata.rb +0 -2
- data/lib/cimi/collections/machine_admins.rb +5 -5
- data/lib/cimi/collections/machine_configurations.rb +2 -2
- data/lib/cimi/collections/machine_images.rb +3 -3
- data/lib/cimi/collections/machines.rb +32 -10
- data/lib/cimi/collections/network_configurations.rb +4 -3
- data/lib/cimi/collections/network_templates.rb +4 -3
- data/lib/cimi/collections/networks.rb +8 -8
- data/lib/cimi/collections/routing_group_templates.rb +4 -3
- data/lib/cimi/collections/routing_groups.rb +4 -3
- data/lib/cimi/collections/volume_configurations.rb +3 -3
- data/lib/cimi/collections/volume_images.rb +3 -3
- data/lib/cimi/collections/volumes.rb +4 -3
- data/lib/cimi/collections/vsp_configurations.rb +4 -3
- data/lib/cimi/collections/vsp_templates.rb +4 -3
- data/lib/cimi/collections/vsps.rb +8 -7
- data/lib/cimi/helpers.rb +1 -1
- data/lib/cimi/helpers/cimi_helper.rb +11 -1
- data/lib/cimi/models.rb +4 -0
- data/lib/cimi/models/base.rb +11 -1
- data/lib/cimi/models/cloud_entry_point.rb +7 -14
- data/lib/cimi/models/disk.rb +40 -0
- data/lib/cimi/models/disk_collection.rb +38 -0
- data/lib/cimi/models/machine.rb +9 -43
- data/lib/cimi/models/machine_collection.rb +7 -4
- data/lib/cimi/models/machine_configuration.rb +8 -15
- data/lib/cimi/models/machine_configuration_collection.rb +6 -4
- data/lib/cimi/models/machine_image_collection.rb +6 -4
- data/lib/cimi/models/machine_template_collection.rb +6 -4
- data/lib/cimi/models/machine_volume.rb +42 -0
- data/lib/cimi/models/machine_volume_collection.rb +34 -0
- data/lib/cimi/models/network.rb +5 -9
- data/lib/cimi/models/network_collection.rb +6 -5
- data/lib/cimi/models/schema.rb +20 -0
- data/lib/cimi/models/volume_collection.rb +6 -4
- data/lib/cimi/models/volume_configuration_collection.rb +6 -4
- data/lib/cimi/models/volume_image_collection.rb +6 -4
- data/lib/cimi/models/volume_template_collection.rb +6 -4
- data/lib/deltacloud/api.rb +3 -3
- data/lib/deltacloud/collections/addresses.rb +1 -1
- data/lib/deltacloud/collections/firewalls.rb +4 -2
- data/lib/deltacloud/collections/keys.rb +1 -1
- data/lib/deltacloud/collections/load_balancers.rb +1 -1
- data/lib/deltacloud/collections/storage_volumes.rb +4 -4
- data/lib/deltacloud/drivers/base_driver.rb +12 -20
- data/lib/deltacloud/drivers/ec2/aws_vpc_monkey_patch.rb +294 -0
- data/lib/deltacloud/drivers/ec2/ec2_driver.rb +38 -6
- data/lib/deltacloud/drivers/fgcp/fgcp_client.rb +4 -0
- data/lib/deltacloud/drivers/fgcp/fgcp_driver.rb +40 -4
- data/lib/deltacloud/drivers/gogrid/gogrid_client.rb +8 -7
- data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +422 -416
- data/lib/deltacloud/drivers/google/google_driver.rb +2 -1
- data/lib/deltacloud/drivers/openstack/openstack_driver.rb +30 -16
- data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +1 -0
- data/lib/deltacloud/drivers/vsphere/vsphere_driver.rb +3 -9
- data/lib/deltacloud/helpers/deltacloud_helper.rb +0 -2
- data/lib/deltacloud/models/firewall_rule.rb +2 -0
- data/lib/deltacloud/models/hardware_profile.rb +61 -59
- data/{tests/deprecated/core_ext/string.rb → lib/deltacloud/version.rb} +3 -15
- data/lib/deltacloud_rack.rb +1 -0
- data/lib/ec2/server.rb +5 -3
- data/lib/sinatra/rack_accept.rb +53 -53
- data/lib/sinatra/rack_etag.rb +1 -1
- data/tests/cimi/collections/cloud_entry_point_test.rb +11 -2
- data/tests/deltacloud/common.rb +1 -1
- data/tests/deltacloud/rack_test.rb +3 -3
- data/tests/drivers/base/base_driver_test.rb +6 -2
- data/tests/drivers/base/common.rb +1 -0
- data/tests/drivers/base/library_test.rb +6 -2
- data/tests/drivers/ec2/common.rb +34 -15
- data/tests/drivers/ec2/images_test.rb +2 -3
- data/tests/drivers/ec2/instance_test.rb +12 -2
- data/tests/drivers/ec2/keys_test.rb +2 -2
- data/tests/drivers/ec2/realms_test.rb +7 -3
- data/tests/drivers/ec2/storage_snapshots_test.rb +2 -3
- data/tests/drivers/gogrid/common.rb +24 -0
- data/tests/drivers/gogrid/hardware_profiles_test.rb +51 -0
- data/tests/drivers/gogrid/images_test.rb +57 -0
- data/tests/drivers/gogrid/instances_test.rb +92 -0
- data/tests/drivers/gogrid/realms_test.rb +45 -0
- data/tests/drivers/google/buckets_test.rb +105 -0
- data/tests/drivers/google/common.rb +20 -0
- data/tests/drivers/mock/common.rb +1 -0
- data/tests/drivers/mock/images_test.rb +3 -2
- data/tests/drivers/mock/instances_test.rb +3 -2
- data/tests/drivers/mock/keys_test.rb +3 -2
- data/tests/drivers/mock/realms_test.rb +3 -2
- data/tests/drivers/mock/storage_snapshots_test.rb +3 -2
- data/tests/drivers/mock/storage_volumes_test.rb +3 -2
- data/tests/drivers/models/address_test.rb +3 -3
- data/tests/drivers/models/base_test.rb +4 -2
- data/tests/drivers/models/blob_test.rb +3 -3
- data/tests/drivers/models/common.rb +3 -0
- data/tests/drivers/models/hardware_profile_test.rb +5 -4
- data/tests/drivers/models/instance_address_test.rb +3 -3
- data/tests/drivers/models/instance_profile_test.rb +3 -3
- data/tests/drivers/models/instance_test.rb +3 -3
- data/tests/drivers/models/keys_test.rb +3 -3
- data/tests/drivers/models/metrics_test.rb +3 -3
- data/tests/drivers/openstack/common.rb +26 -0
- data/tests/drivers/openstack/hardware_profiles_test.rb +46 -0
- data/tests/drivers/openstack/images_test.rb +50 -0
- data/tests/drivers/openstack/instances_test.rb +66 -0
- data/tests/drivers/openstack/keys_test.rb +61 -0
- data/tests/drivers/openstack/realms_test.rb +46 -0
- data/tests/drivers/rhevm/common.rb +2 -0
- data/tests/drivers/rhevm/images_test.rb +3 -4
- data/tests/drivers/rhevm/instance_test.rb +2 -2
- data/tests/drivers/rhevm/provider_test.rb +2 -2
- data/tests/drivers/rhevm/realms_test.rb +2 -3
- data/tests/ec2/common.rb +5 -4
- data/tests/ec2/server_test.rb +3 -2
- data/tests/helpers/rack/common.rb +3 -0
- data/tests/helpers/rack/rack_accept_test.rb +65 -0
- data/tests/helpers/rack/rack_date_test.rb +27 -0
- data/tests/helpers/rack/rack_driver_select_test.rb +53 -0
- data/tests/helpers/rack/rack_etag_test.rb +29 -0
- data/tests/helpers/rack/rack_matrix_params_test.rb +72 -0
- data/tests/test_helper.rb +44 -36
- data/views/hardware_profiles/index.html.haml +1 -1
- data/views/hardware_profiles/show.html.haml +2 -2
- data/views/hardware_profiles/show.xml.haml +2 -1
- data/views/images/show.html.haml +6 -5
- metadata +74 -117
- data/tests/deprecated/api/common.rb +0 -1
- data/tests/deprecated/api/driver_test.rb +0 -79
- data/tests/deprecated/api/library_test.rb +0 -6
- data/tests/deprecated/cimi/features/step_definitions/common_steps.rb +0 -59
- data/tests/deprecated/cimi/features/step_definitions/machine_images_steps.rb +0 -0
- data/tests/deprecated/cimi/features/step_definitions/machines_steps.rb +0 -100
- data/tests/deprecated/cimi/features/step_definitions/volumes_steps.rb +0 -115
- data/tests/deprecated/cimi/features/support/env.rb +0 -75
- data/tests/deprecated/common.rb +0 -279
- data/tests/deprecated/drivers/ec2/api_test.rb +0 -19
- data/tests/deprecated/drivers/ec2/common.rb +0 -23
- data/tests/deprecated/drivers/ec2/drivers_test.rb +0 -120
- data/tests/deprecated/drivers/ec2/hardware_profiles_test.rb +0 -224
- data/tests/deprecated/drivers/ec2/images_test.rb +0 -230
- data/tests/deprecated/drivers/ec2/instances_test.rb +0 -356
- data/tests/deprecated/drivers/ec2/keys_test.rb +0 -181
- data/tests/deprecated/drivers/ec2/realms_test.rb +0 -146
- data/tests/deprecated/drivers/fgcp/api_test.rb +0 -47
- data/tests/deprecated/drivers/fgcp/hardware_profiles_test.rb +0 -54
- data/tests/deprecated/drivers/fgcp/realms_test.rb +0 -42
- data/tests/deprecated/drivers/fgcp/setup.rb +0 -13
- data/tests/deprecated/drivers/google/api_test.rb +0 -19
- data/tests/deprecated/drivers/google/buckets_test.rb +0 -100
- data/tests/deprecated/drivers/google/common.rb +0 -54
- data/tests/deprecated/drivers/mock/api_test.rb +0 -10
- data/tests/deprecated/drivers/mock/buckets_test.rb +0 -195
- data/tests/deprecated/drivers/mock/common.rb +0 -7
- data/tests/deprecated/drivers/mock/drivers_test.rb +0 -123
- data/tests/deprecated/drivers/mock/hardware_profiles_test.rb +0 -224
- data/tests/deprecated/drivers/mock/images_test.rb +0 -197
- data/tests/deprecated/drivers/mock/instances_test.rb +0 -343
- data/tests/deprecated/drivers/mock/keys_test.rb +0 -161
- data/tests/deprecated/drivers/mock/realms_test.rb +0 -132
- data/tests/deprecated/drivers/mock/storage_snapshots_test.rb +0 -114
- data/tests/deprecated/drivers/mock/storage_volumes_test.rb +0 -122
- data/tests/deprecated/drivers/openstack/api_test.rb +0 -46
- data/tests/deprecated/drivers/openstack/common.rb +0 -21
- data/tests/deprecated/drivers/openstack/hardware_profiles_test.rb +0 -64
- data/tests/deprecated/drivers/openstack/images_test.rb +0 -46
- data/tests/deprecated/drivers/openstack/instances_test.rb +0 -208
- data/tests/deprecated/drivers/openstack/realms_test.rb +0 -40
- data/tests/deprecated/drivers/rackspace/api_test.rb +0 -46
- data/tests/deprecated/drivers/rackspace/buckets_test.rb +0 -150
- data/tests/deprecated/drivers/rackspace/common.rb +0 -16
- data/tests/deprecated/drivers/rackspace/hardware_profiles_test.rb +0 -58
- data/tests/deprecated/drivers/rackspace/images_test.rb +0 -45
- data/tests/deprecated/drivers/rackspace/instances_test.rb +0 -166
- data/tests/deprecated/drivers/rackspace/realms_test.rb +0 -41
- data/tests/deprecated/drivers/rhevm/api_test.rb +0 -45
- data/tests/deprecated/drivers/rhevm/common.rb +0 -21
- data/tests/deprecated/drivers/rhevm/hardware_profiles_test.rb +0 -58
- data/tests/deprecated/drivers/rhevm/images_test.rb +0 -48
- data/tests/deprecated/drivers/rhevm/instances_test.rb +0 -182
- data/tests/deprecated/drivers/rhevm/realms_test.rb +0 -40
- data/tests/deprecated/minitest_common.rb +0 -58
- data/tests/deprecated/minitest_common_api_test.rb +0 -115
- data/tests/deprecated/rabbit_test.rb +0 -52
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'require_relative' if RUBY_VERSION < '1.9'
|
3
|
+
|
4
|
+
require_relative 'common'
|
5
|
+
|
6
|
+
describe 'GoGridDriver Realms' do
|
7
|
+
|
8
|
+
before do
|
9
|
+
@driver = Deltacloud::new(:gogrid, credentials)
|
10
|
+
VCR.insert_cassette __name__
|
11
|
+
end
|
12
|
+
|
13
|
+
after do
|
14
|
+
VCR.eject_cassette
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'must throw error when wrong credentials' do
|
18
|
+
Proc.new do
|
19
|
+
@driver.backend.realms(OpenStruct.new(:user => 'unknown', :password => 'wrong'))
|
20
|
+
end.must_raise Deltacloud::ExceptionHandler::AuthenticationFailure, 'Authentication Failure'
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'must return list of realms' do
|
24
|
+
@driver.realms.wont_be_empty
|
25
|
+
@driver.realms.first.must_be_kind_of Realm
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'must allow to filter realms' do
|
29
|
+
@driver.realms(:id => '1').wont_be_empty
|
30
|
+
@driver.realms(:id => '1').must_be_kind_of Array
|
31
|
+
@driver.realms(:id => '1').size.must_equal 1
|
32
|
+
@driver.realms(:id => '1').first.id.must_equal '1'
|
33
|
+
@driver.realms(:id => '1').first.name.must_equal 'US-West-1'
|
34
|
+
@driver.realms(:id => 'unknown').must_be_empty
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'must allow to retrieve single realm' do
|
38
|
+
@driver.realm(:id => '1').wont_be_nil
|
39
|
+
@driver.realm(:id => '1').must_be_kind_of Realm
|
40
|
+
@driver.realm(:id => '1').id.must_equal '1'
|
41
|
+
@driver.realm(:id => '1').name.must_equal 'US-West-1'
|
42
|
+
@driver.realm(:id => 'unknown').must_be_nil
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'require_relative' if RUBY_VERSION < '1.9'
|
3
|
+
|
4
|
+
require_relative 'common.rb'
|
5
|
+
|
6
|
+
require 'tempfile'
|
7
|
+
|
8
|
+
describe 'Deltacloud API' do
|
9
|
+
|
10
|
+
before do
|
11
|
+
@driver = Deltacloud::new(:google, credentials)
|
12
|
+
VCR.insert_cassette __name__
|
13
|
+
end
|
14
|
+
|
15
|
+
after do
|
16
|
+
VCR.eject_cassette
|
17
|
+
end
|
18
|
+
|
19
|
+
## FIXME:
|
20
|
+
i_suck_and_my_tests_are_order_dependent!
|
21
|
+
|
22
|
+
def bucket_name_google
|
23
|
+
"testbucki2rpux3wdelmegoogel"
|
24
|
+
end
|
25
|
+
|
26
|
+
def blob_name_google
|
27
|
+
"testblobk1ds91kVdelmegoogel"
|
28
|
+
end
|
29
|
+
|
30
|
+
#intentional typos here - bucket names cannot contain 'google'
|
31
|
+
#see http://code.google.com/apis/storage/docs/reference/v1/developer-guidev1.html
|
32
|
+
it 'can create a new bucket' do
|
33
|
+
bucket_name = bucket_name_google
|
34
|
+
bucket = @driver.create_bucket(bucket_name)
|
35
|
+
bucket.id.wont_be_nil
|
36
|
+
bucket.name.must_equal bucket_name
|
37
|
+
bucket.size.must_equal 0
|
38
|
+
bucket.blob_list.must_be_empty
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'can create a new blob with HTTP POST' do
|
42
|
+
temp_file = File.open(created_blob_local_file)
|
43
|
+
user_data = {
|
44
|
+
'HTTP-X-Deltacloud-Blobmeta-name1' => "Author",
|
45
|
+
'HTTP-X-Deltacloud-Blobmeta-value1' => "deltacloud",
|
46
|
+
'HTTP-X-Deltacloud-Blobmeta-name2' => "foo",
|
47
|
+
'HTTP-X-Deltacloud-Blobmeta-value2' => "bar"
|
48
|
+
}
|
49
|
+
blob = @driver.backend.create_blob(
|
50
|
+
@driver.credentials,
|
51
|
+
bucket_name_google,
|
52
|
+
blob_name_google,
|
53
|
+
{ :tempfile => temp_file, :type => 'image/png'},
|
54
|
+
user_data
|
55
|
+
)
|
56
|
+
blob.id.wont_be_nil
|
57
|
+
blob.bucket.must_equal bucket_name_google
|
58
|
+
blob.content_type.must_equal 'image/png'
|
59
|
+
blob.user_metadata.keys.wont_be_empty
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'can retrieve named bucket details' do
|
63
|
+
bucket = @driver.bucket(:id => bucket_name_google)
|
64
|
+
bucket.id.wont_be_nil
|
65
|
+
bucket.name.must_equal bucket_name_google
|
66
|
+
bucket.size.must_equal 1
|
67
|
+
bucket.blob_list.wont_be_nil
|
68
|
+
bucket.blob_list.must_include blob_name_google
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'can retrieve details of a named blob' do
|
72
|
+
blob = @driver.blob({:id => blob_name_google, 'bucket' => bucket_name_google})
|
73
|
+
blob.bucket.must_equal bucket_name_google
|
74
|
+
blob.id.must_equal blob_name_google
|
75
|
+
blob.content_length.to_i.must_be :'>',0
|
76
|
+
blob.last_modified.wont_be_empty
|
77
|
+
blob.content_type.must_equal 'text/html'
|
78
|
+
blob.user_metadata.keys.wont_be_empty
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'can retrieve named blob metadata' do
|
82
|
+
blob_metadata = @driver.blob_metadata({:id => blob_name_google, 'bucket' => bucket_name_google})
|
83
|
+
{"author"=>"deltacloud", "foo"=>"bar"}.must_equal blob_metadata
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'can update blob metadata' do
|
87
|
+
new_meta = { 'author' => 'ApacheDeltacloud', 'oof' => 'rab'}
|
88
|
+
r = @driver.update_blob_metadata({:id => blob_name_google, 'bucket' => bucket_name_google, 'meta_hash' => new_meta})
|
89
|
+
r.wont_be_nil
|
90
|
+
r.keys.wont_be_empty
|
91
|
+
r['author'].must_equal 'ApacheDeltacloud'
|
92
|
+
r['oof'].must_equal 'rab'
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'can delete blob' do
|
96
|
+
r = @driver.delete_blob(bucket_name_google, blob_name_google)
|
97
|
+
r.status.must_equal 204
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'can delete bucket' do
|
101
|
+
r = @driver.delete_bucket(bucket_name_google)
|
102
|
+
r.status.must_equal 204
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'vcr'
|
2
|
+
|
3
|
+
require_relative '../../test_helper'
|
4
|
+
|
5
|
+
def credentials
|
6
|
+
{
|
7
|
+
:user => 'GOOGXKQLYTEOZTILUBZ5',
|
8
|
+
:password => 'M3pvZUy2ivT78ipQ+u1xv6TkY83q9DUnGXkov3tA'
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
def created_blob_local_file
|
13
|
+
File.join(File.dirname(__FILE__),"data","deltacloud_blob_test.png")
|
14
|
+
end
|
15
|
+
|
16
|
+
VCR.configure do |c|
|
17
|
+
c.cassette_library_dir = "#{File.dirname(__FILE__)}/fixtures/"
|
18
|
+
c.hook_into :excon
|
19
|
+
c.default_cassette_options = { :record => :none }
|
20
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative '../../test_helper'
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'rubygems'
|
2
|
+
require 'require_relative' if RUBY_VERSION < '1.9'
|
2
3
|
|
3
|
-
require_relative
|
4
|
-
require_relative File.join('..', '..', '..', 'lib', 'deltacloud', 'models', 'address.rb')
|
4
|
+
require_relative 'common.rb'
|
5
5
|
|
6
6
|
describe Address do
|
7
7
|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'rubygems'
|
2
|
+
require 'require_relative' if RUBY_VERSION < '1.9'
|
2
3
|
|
3
|
-
require_relative
|
4
|
-
require_relative File.join('..', '..', '..', 'lib', 'deltacloud', 'models', 'address.rb')
|
4
|
+
require_relative 'common'
|
5
5
|
|
6
6
|
describe Address do
|
7
7
|
|
@@ -1,10 +1,11 @@
|
|
1
|
-
require '
|
1
|
+
require 'rubygems'
|
2
|
+
require 'require_relative' if RUBY_VERSION < '1.9'
|
3
|
+
|
4
|
+
require_relative 'common'
|
5
|
+
|
2
6
|
require 'sinatra/base'
|
3
7
|
require 'sinatra/rabbit'
|
4
8
|
|
5
|
-
require_relative File.join('..', '..', '..', 'lib', 'deltacloud', 'models', 'base_model.rb')
|
6
|
-
require_relative File.join('..', '..', '..', 'lib', 'deltacloud', 'models', 'hardware_profile.rb')
|
7
|
-
|
8
9
|
describe Deltacloud::HardwareProfile do
|
9
10
|
|
10
11
|
before do
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'rubygems'
|
2
|
+
require 'require_relative' if RUBY_VERSION < '1.9'
|
2
3
|
|
3
|
-
require_relative
|
4
|
-
require_relative File.join('..', '..', '..', 'lib', 'deltacloud', 'models', 'instance_address.rb')
|
4
|
+
require_relative 'common'
|
5
5
|
|
6
6
|
describe InstanceAddress do
|
7
7
|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'rubygems'
|
2
|
+
require 'require_relative' if RUBY_VERSION < '1.9'
|
2
3
|
|
3
|
-
require_relative
|
4
|
-
require_relative File.join('..', '..', '..', 'lib', 'deltacloud', 'models', 'instance_profile.rb')
|
4
|
+
require_relative 'common'
|
5
5
|
|
6
6
|
describe InstanceProfile do
|
7
7
|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'rubygems'
|
2
|
+
require 'require_relative' if RUBY_VERSION < '1.9'
|
2
3
|
|
3
|
-
require_relative
|
4
|
-
require_relative File.join('..', '..', '..', 'lib', 'deltacloud', 'models', 'instance.rb')
|
4
|
+
require_relative 'common'
|
5
5
|
|
6
6
|
describe Instance do
|
7
7
|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'rubygems'
|
2
|
+
require 'require_relative' if RUBY_VERSION < '1.9'
|
2
3
|
|
3
|
-
require_relative
|
4
|
-
require_relative File.join('..', '..', '..', 'lib', 'deltacloud', 'models', 'key.rb')
|
4
|
+
require_relative 'common'
|
5
5
|
|
6
6
|
describe Key do
|
7
7
|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'rubygems'
|
2
|
+
require 'require_relative' if RUBY_VERSION < '1.9'
|
2
3
|
|
3
|
-
require_relative
|
4
|
-
require_relative File.join('..', '..', '..', 'lib', 'deltacloud', 'models', 'metric.rb')
|
4
|
+
require_relative 'common'
|
5
5
|
|
6
6
|
describe Metric do
|
7
7
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'openstack'
|
2
|
+
require 'vcr'
|
3
|
+
|
4
|
+
def credentials
|
5
|
+
{
|
6
|
+
:user => 'admin+admin',
|
7
|
+
:password => 'password',
|
8
|
+
:provider => 'http://10.34.32.211:5000/v2.0'
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
def openstack_image_id
|
13
|
+
'bf7ce59a-d9f9-45d4-9313-f45b16436602'
|
14
|
+
end
|
15
|
+
|
16
|
+
unless Time.respond_to? :be
|
17
|
+
require_relative '../../test_helper.rb'
|
18
|
+
end
|
19
|
+
|
20
|
+
VCR.configure do |c|
|
21
|
+
# NOTE: Empty this directory before re-recording
|
22
|
+
c.cassette_library_dir = File.join(File.dirname(__FILE__), 'fixtures')
|
23
|
+
c.hook_into :webmock
|
24
|
+
# Set this to :new_episodes when you want to 're-record'
|
25
|
+
c.default_cassette_options = { :record => :new_episodes }
|
26
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
|
3
|
+
require_relative File.join('..', '..', '..', 'lib', 'deltacloud', 'api.rb')
|
4
|
+
require_relative 'common.rb'
|
5
|
+
|
6
|
+
describe 'OpenStackDriver HardwareProfiles' do
|
7
|
+
|
8
|
+
before do
|
9
|
+
@driver = Deltacloud::new(:openstack, credentials)
|
10
|
+
VCR.insert_cassette __name__
|
11
|
+
end
|
12
|
+
|
13
|
+
after do
|
14
|
+
VCR.eject_cassette
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'must throw error when wrong credentials' do
|
18
|
+
Proc.new do
|
19
|
+
@driver.backend.images(OpenStruct.new(:user => 'unknown+wrong', :password => 'wrong'))
|
20
|
+
end.must_raise Deltacloud::ExceptionHandler::AuthenticationFailure, 'Authentication Failure'
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'must return list of hardware_profiles' do
|
24
|
+
@driver.hardware_profiles.wont_be_empty
|
25
|
+
@driver.hardware_profiles.first.must_be_kind_of Deltacloud::HardwareProfile
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'must allow to filter hardware_profiles' do
|
29
|
+
hardware_profiles = @driver.hardware_profiles :id => '1'
|
30
|
+
hardware_profiles.wont_be_empty
|
31
|
+
hardware_profiles.must_be_kind_of Array
|
32
|
+
hardware_profiles.size.must_equal 1
|
33
|
+
hardware_profiles.first.name.must_equal '1'
|
34
|
+
@driver.hardware_profiles(:id => 'unknown').must_be_empty
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'must allow to retrieve single hardware_profile' do
|
38
|
+
hardware_profile = @driver.hardware_profile :id => '1'
|
39
|
+
hardware_profile.wont_be_nil
|
40
|
+
hardware_profile.name.must_equal '1'
|
41
|
+
hardware_profile.properties.must_be_kind_of Array
|
42
|
+
hardware_profile.properties.wont_be_empty
|
43
|
+
@driver.hardware_profile(:id => 'unknown').must_be_nil
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
|
3
|
+
require_relative File.join('..', '..', '..', 'lib', 'deltacloud', 'api.rb')
|
4
|
+
require_relative 'common.rb'
|
5
|
+
|
6
|
+
describe 'OpenStackDriver Images' do
|
7
|
+
|
8
|
+
before do
|
9
|
+
@driver = Deltacloud::new(:openstack, credentials)
|
10
|
+
VCR.insert_cassette __name__
|
11
|
+
end
|
12
|
+
|
13
|
+
after do
|
14
|
+
VCR.eject_cassette
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'must throw error when wrong credentials' do
|
18
|
+
Proc.new do
|
19
|
+
@driver.backend.images(OpenStruct.new(:user => 'unknown+wrong', :password => 'wrong'))
|
20
|
+
end.must_raise Deltacloud::ExceptionHandler::AuthenticationFailure, 'Authentication Failure'
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'must return list of images' do
|
24
|
+
@driver.images.wont_be_empty
|
25
|
+
@driver.images.first.must_be_kind_of Image
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'must allow to filter images' do
|
29
|
+
images = @driver.images :id => openstack_image_id
|
30
|
+
images.wont_be_empty
|
31
|
+
images.must_be_kind_of Array
|
32
|
+
images.size.must_equal 1
|
33
|
+
images.first.id.must_equal openstack_image_id
|
34
|
+
@driver.images(:owner_id => 'admin').wont_be_empty
|
35
|
+
@driver.images(:owner_id => 'unknown').must_be_empty
|
36
|
+
@driver.images(:id => 'unknown').must_be_empty
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'must allow to retrieve single image' do
|
40
|
+
@driver.image(:id => 'unknown').must_be_nil
|
41
|
+
image = @driver.image :id => openstack_image_id
|
42
|
+
image.wont_be_nil
|
43
|
+
image.must_be_kind_of Image
|
44
|
+
image.id.must_equal openstack_image_id
|
45
|
+
image.name.wont_be_empty
|
46
|
+
image.owner_id.wont_be_empty
|
47
|
+
image.state.wont_be_empty
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|