deltacloud-client-vm 1.1.4.2 → 1.1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +176 -0
- data/NOTICE +8 -0
- data/README.md +73 -0
- data/Rakefile +122 -0
- data/deltacloud-client-vm.gemspec +24 -0
- data/lib/deltacloud_vm/client.rb +79 -0
- data/lib/deltacloud_vm/client/base_error.rb +80 -0
- data/lib/deltacloud_vm/client/connection.rb +139 -0
- data/lib/deltacloud_vm/client/helpers/model_helper.rb +69 -0
- data/lib/deltacloud_vm/client/helpers/property_helper.rb +103 -0
- data/lib/deltacloud_vm/client/helpers/xml_helper.rb +33 -0
- data/lib/deltacloud_vm/client/methods.rb +33 -0
- data/lib/deltacloud_vm/client/methods/address.rb +67 -0
- data/lib/deltacloud_vm/client/methods/api.rb +96 -0
- data/lib/deltacloud_vm/client/methods/backward_compatiblity.rb +72 -0
- data/lib/deltacloud_vm/client/methods/blob.rb +91 -0
- data/lib/deltacloud_vm/client/methods/bucket.rb +55 -0
- data/lib/deltacloud_vm/client/methods/common.rb +46 -0
- data/lib/deltacloud_vm/client/methods/driver.rb +53 -0
- data/lib/deltacloud_vm/client/methods/firewall.rb +67 -0
- data/lib/deltacloud_vm/client/methods/hardware_profile.rb +41 -0
- data/lib/deltacloud_vm/client/methods/image.rb +61 -0
- data/lib/deltacloud_vm/client/methods/instance.rb +141 -0
- data/lib/deltacloud_vm/client/methods/instance_state.rb +41 -0
- data/lib/deltacloud_vm/client/methods/key.rb +58 -0
- data/lib/deltacloud_vm/client/methods/load_balancer.rb +96 -0
- data/lib/deltacloud_vm/client/methods/metric.rb +54 -0
- data/lib/deltacloud_vm/client/methods/realm.rb +42 -0
- data/lib/deltacloud_vm/client/methods/storage_snapshot.rb +61 -0
- data/lib/deltacloud_vm/client/methods/storage_volume.rb +94 -0
- data/lib/deltacloud_vm/client/models.rb +32 -0
- data/lib/deltacloud_vm/client/models/address.rb +57 -0
- data/lib/deltacloud_vm/client/models/base.rb +153 -0
- data/lib/deltacloud_vm/client/models/blob.rb +56 -0
- data/lib/deltacloud_vm/client/models/bucket.rb +65 -0
- data/lib/deltacloud_vm/client/models/driver.rb +87 -0
- data/lib/deltacloud_vm/client/models/firewall.rb +64 -0
- data/lib/deltacloud_vm/client/models/hardware_profile.rb +68 -0
- data/lib/deltacloud_vm/client/models/image.rb +60 -0
- data/lib/deltacloud_vm/client/models/instance.rb +142 -0
- data/lib/deltacloud_vm/client/models/instance_address.rb +40 -0
- data/lib/deltacloud_vm/client/models/instance_state.rb +52 -0
- data/lib/deltacloud_vm/client/models/key.rb +52 -0
- data/lib/deltacloud_vm/client/models/load_balancer.rb +55 -0
- data/lib/deltacloud_vm/client/models/metric.rb +72 -0
- data/lib/deltacloud_vm/client/models/realm.rb +29 -0
- data/lib/deltacloud_vm/client/models/storage_snapshot.rb +54 -0
- data/lib/deltacloud_vm/client/models/storage_volume.rb +96 -0
- data/lib/deltacloud_vm/core_ext.rb +19 -0
- data/lib/deltacloud_vm/core_ext/element.rb +32 -0
- data/lib/deltacloud_vm/core_ext/fixnum.rb +30 -0
- data/lib/deltacloud_vm/core_ext/nil.rb +22 -0
- data/lib/deltacloud_vm/core_ext/string.rb +49 -0
- data/lib/deltacloud_vm/error_response.rb +93 -0
- data/tests/client/client_test.rb +51 -0
- data/tests/client/connection_test.rb +77 -0
- data/tests/core_ext/element_test.rb +40 -0
- data/tests/core_ext/fixnum_test.rb +35 -0
- data/tests/core_ext/nil.rb +27 -0
- data/tests/core_ext/string_test.rb +47 -0
- data/tests/fixtures/instances_cleanup.yml +681 -0
- data/tests/fixtures/test_0001_connects_to_Deltacloud_API.yml +60 -0
- data/tests/fixtures/test_0001_support_cpu.yml +444 -0
- data/tests/fixtures/test_0001_support_original_body.yml +116 -0
- data/tests/fixtures/test_0001_supports_addresses.yml +178 -0
- data/tests/fixtures/test_0001_supports_api_host.yml +60 -0
- data/tests/fixtures/test_0001_supports_attached_.yml +282 -0
- data/tests/fixtures/test_0001_supports_blobs.yml +475 -0
- data/tests/fixtures/test_0001_supports_bucket.yml +200 -0
- data/tests/fixtures/test_0001_supports_buckets.yml +160 -0
- data/tests/fixtures/test_0001_supports_drivers.yml +202 -0
- data/tests/fixtures/test_0001_supports_firewalls.yml +399 -0
- data/tests/fixtures/test_0001_supports_hardware_profiles.yml +262 -0
- data/tests/fixtures/test_0001_supports_images.yml +224 -0
- data/tests/fixtures/test_0001_supports_instance_states.yml +156 -0
- data/tests/fixtures/test_0001_supports_instances.yml +486 -0
- data/tests/fixtures/test_0001_supports_keys.yml +198 -0
- data/tests/fixtures/test_0001_supports_path.yml +60 -0
- data/tests/fixtures/test_0001_supports_realms.yml +152 -0
- data/tests/fixtures/test_0001_supports_storage_snapshots.yml +164 -0
- data/tests/fixtures/test_0001_supports_storage_volumes.yml +176 -0
- data/tests/fixtures/test_0001_supports_to_get_providers.yml +410 -0
- data/tests/fixtures/test_0002_support_blob.yml +148 -0
- data/tests/fixtures/test_0002_support_instance_state.yml +204 -0
- data/tests/fixtures/test_0002_support_memory.yml +444 -0
- data/tests/fixtures/test_0002_support_on_Provider.yml +130 -0
- data/tests/fixtures/test_0002_supports_api_port.yml +60 -0
- data/tests/fixtures/test_0002_supports_api_uri.yml +60 -0
- data/tests/fixtures/test_0002_supports_driver.yml +219 -0
- data/tests/fixtures/test_0002_supports_extract_xml_body_using_faraday_connection.yml +117 -0
- data/tests/fixtures/test_0002_supports_filtering_addresses_by_id_param.yml +156 -0
- data/tests/fixtures/test_0002_supports_filtering_buckets_by_id_param.yml +156 -0
- data/tests/fixtures/test_0002_supports_filtering_firewalls_by_id_param.yml +207 -0
- data/tests/fixtures/test_0002_supports_filtering_hardware_profiles_by_id_param.yml +158 -0
- data/tests/fixtures/test_0002_supports_filtering_images_by_id_param.yml +165 -0
- data/tests/fixtures/test_0002_supports_filtering_instances_by_id_param.yml +164 -0
- data/tests/fixtures/test_0002_supports_filtering_keys_by_id_param.yml +178 -0
- data/tests/fixtures/test_0002_supports_filtering_realms_by_id.yml +104 -0
- data/tests/fixtures/test_0002_supports_filtering_storage_snapshots_by_id_param.yml +155 -0
- data/tests/fixtures/test_0002_supports_filtering_storage_volumes_by_id_param.yml +157 -0
- data/tests/fixtures/test_0002_supports_hardware_profiles.yml +262 -0
- data/tests/fixtures/test_0002_supports_is_compatible_.yml +116 -0
- data/tests/fixtures/test_0002_supports_snapshot_.yml +202 -0
- data/tests/fixtures/test_0002_supports_version.yml +60 -0
- data/tests/fixtures/test_0003_caches_the_API_entrypoint.yml +60 -0
- data/tests/fixtures/test_0003_support_address.yml +197 -0
- data/tests/fixtures/test_0003_support_bucket.yml +198 -0
- data/tests/fixtures/test_0003_support_create_blob.yml +105 -0
- data/tests/fixtures/test_0003_support_create_blob_and_destroy_blob.yml +138 -0
- data/tests/fixtures/test_0003_support_firewall.yml +768 -0
- data/tests/fixtures/test_0003_support_hardware_profile.yml +199 -0
- data/tests/fixtures/test_0003_support_image.yml +207 -0
- data/tests/fixtures/test_0003_support_instance.yml +206 -0
- data/tests/fixtures/test_0003_support_key.yml +220 -0
- data/tests/fixtures/test_0003_support_realm.yml +195 -0
- data/tests/fixtures/test_0003_support_storage.yml +444 -0
- data/tests/fixtures/test_0003_support_storage_snapshot.yml +196 -0
- data/tests/fixtures/test_0003_support_storage_volume.yml +197 -0
- data/tests/fixtures/test_0003_support_to_change_driver_with_Client.yml +72 -0
- data/tests/fixtures/test_0003_supports_connect.yml +60 -0
- data/tests/fixtures/test_0003_supports_extract_xml_body_using_nokogiri_document.yml +117 -0
- data/tests/fixtures/test_0003_supports_instance.yml +396 -0
- data/tests/fixtures/test_0003_supports_is_compatible_.yml +116 -0
- data/tests/fixtures/test_0003_supports_lunch_image.yml +367 -0
- data/tests/fixtures/test_0003_supports_providers.yml +102 -0
- data/tests/fixtures/test_0003_supports_version.yml +60 -0
- data/tests/fixtures/test_0004_support_architecture.yml +444 -0
- data/tests/fixtures/test_0004_support_create_address.yml +197 -0
- data/tests/fixtures/test_0004_support_create_blob_and_destroy_blob_with_meta_params.yml +139 -0
- data/tests/fixtures/test_0004_support_create_bucket.yml +180 -0
- data/tests/fixtures/test_0004_support_create_bucket_and_destroy_bucket.yml +180 -0
- data/tests/fixtures/test_0004_support_create_firewall_and_destroy_firewall.yml +496 -0
- data/tests/fixtures/test_0004_support_create_image_and_destroy_image.yml +1527 -0
- data/tests/fixtures/test_0004_support_create_instance.yml +115 -0
- data/tests/fixtures/test_0004_support_create_key_and_destroy_key.yml +206 -0
- data/tests/fixtures/test_0004_support_create_volume.yml +105 -0
- data/tests/fixtures/test_0004_support_create_volume_and_destroy_volume.yml +181 -0
- data/tests/fixtures/test_0004_support_to_test_of_valid_DC_connection.yml +60 -0
- data/tests/fixtures/test_0004_supports_current_driver.yml +60 -0
- data/tests/fixtures/test_0004_supports_extract_xml_body_using_nokogiri_element.yml +117 -0
- data/tests/fixtures/test_0004_supports_lunch_image.yml +312 -0
- data/tests/fixtures/test_0004_supports_valid_credentials_.yml +215 -0
- data/tests/fixtures/test_0004_supports_with_config.yml +129 -0
- data/tests/fixtures/test_0005_support_attach_storage_volume.yml +102 -0
- data/tests/fixtures/test_0005_support_attach_storage_volume_and_detach_storage_volume.yml +142 -0
- data/tests/fixtures/test_0005_support_create_instance_with_hwp_id.yml +115 -0
- data/tests/fixtures/test_0005_support_opaque_.yml +152 -0
- data/tests/fixtures/test_0005_supports_current_provider.yml +134 -0
- data/tests/fixtures/test_0005_supports_id.yml +116 -0
- data/tests/fixtures/test_0005_supports_switching_drivers_per_instance.yml +129 -0
- data/tests/fixtures/test_0005_supports_use_driver.yml +60 -0
- data/tests/fixtures/test_0006_support_create_instance_with_realm_id.yml +115 -0
- data/tests/fixtures/test_0006_supports_discovered_.yml +60 -0
- data/tests/fixtures/test_0006_supports_supported_collections.yml +60 -0
- data/tests/fixtures/test_0006_supports_switching_providers_per_instance.yml +208 -0
- data/tests/fixtures/test_0007_support_create_instance_with_name.yml +115 -0
- data/tests/fixtures/test_0007_support_switching_provider_without_credentials.yml +208 -0
- data/tests/fixtures/test_0007_supports_support_.yml +60 -0
- data/tests/fixtures/test_0007_supports_valid_credentials_on_class.yml +370 -0
- data/tests/fixtures/test_0008_support_stop_instance.yml +166 -0
- data/tests/fixtures/test_0008_supports_must_support_.yml +60 -0
- data/tests/fixtures/test_0009_support_start_instance.yml +217 -0
- data/tests/fixtures/test_0009_supports_features.yml +60 -0
- data/tests/fixtures/test_0010_support_reboot_instance.yml +166 -0
- data/tests/fixtures/test_0010_supports_feature_.yml +60 -0
- data/tests/helpers/model_test.rb +33 -0
- data/tests/helpers/xml_test.rb +56 -0
- data/tests/methods/address_test.rb +64 -0
- data/tests/methods/api_test.rb +97 -0
- data/tests/methods/backward_compatibility_test.rb +87 -0
- data/tests/methods/blob_test.rb +64 -0
- data/tests/methods/bucket_test.rb +62 -0
- data/tests/methods/driver_test.rb +48 -0
- data/tests/methods/firewall_test.rb +84 -0
- data/tests/methods/hardware_profile_test.rb +53 -0
- data/tests/methods/image_test.rb +64 -0
- data/tests/methods/instance_state_test.rb +43 -0
- data/tests/methods/instance_test.rb +126 -0
- data/tests/methods/key_test.rb +63 -0
- data/tests/methods/realm_test.rb +50 -0
- data/tests/methods/storage_snapshot_test.rb +53 -0
- data/tests/methods/storage_volume_test.rb +81 -0
- data/tests/models/blob_test.rb +40 -0
- data/tests/models/bucket_test.rb +37 -0
- data/tests/models/driver_test.rb +42 -0
- data/tests/models/hardware_profile_test.rb +80 -0
- data/tests/models/image_test.rb +65 -0
- data/tests/models/storage_volume_test.rb +52 -0
- data/tests/test_helper.rb +64 -0
- metadata +191 -2
@@ -0,0 +1,87 @@
|
|
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
|
+
require_relative '../test_helper'
|
17
|
+
|
18
|
+
describe DeltacloudVM::Client::Methods::BackwardCompatibility do
|
19
|
+
|
20
|
+
before do
|
21
|
+
VCR.insert_cassette(__name__)
|
22
|
+
@client = new_client
|
23
|
+
end
|
24
|
+
|
25
|
+
after do
|
26
|
+
VCR.eject_cassette
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'supports #api_host' do
|
30
|
+
@client.must_respond_to :api_host
|
31
|
+
@client.api_host.must_equal 'localhost'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'supports #api_port' do
|
35
|
+
@client.must_respond_to :api_port
|
36
|
+
@client.api_port.must_equal 3001
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'supports #connect' do
|
40
|
+
@client.must_respond_to :connect
|
41
|
+
@client.connect do |new_client|
|
42
|
+
new_client.must_be_instance_of DeltacloudVM::Client::Connection
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'supports #with_config' do
|
47
|
+
@client.must_respond_to :with_config
|
48
|
+
@client.with_config(:driver => :ec2, :username => 'f', :password => 'b') do |c|
|
49
|
+
c.must_be_instance_of DeltacloudVM::Client::Connection
|
50
|
+
c.current_driver.must_equal 'ec2'
|
51
|
+
c.request_driver.must_equal :ec2
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'supports #use_driver' do
|
56
|
+
@client.must_respond_to :use_driver
|
57
|
+
@client.use_driver(:ec2, :username => 'f', :password => 'b') do |c|
|
58
|
+
c.must_be_instance_of DeltacloudVM::Client::Connection
|
59
|
+
c.current_driver.must_equal 'ec2'
|
60
|
+
c.request_driver.must_equal :ec2
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'supports #discovered?' do
|
65
|
+
@client.must_respond_to :"discovered?"
|
66
|
+
@client.discovered?.must_equal true
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'supports #valid_credentials? on class' do
|
70
|
+
DeltacloudVM::Client.must_respond_to :"valid_credentials?"
|
71
|
+
r = DeltacloudVM::Client.valid_credentials? DELTACLOUD_USER,
|
72
|
+
DELTACLOUD_PASSWORD, DELTACLOUD_URL
|
73
|
+
r.must_equal true
|
74
|
+
r = DeltacloudVM::Client.valid_credentials? 'foo',
|
75
|
+
DELTACLOUD_PASSWORD, DELTACLOUD_URL
|
76
|
+
r.must_equal false
|
77
|
+
r = DeltacloudVM::Client.valid_credentials? 'foo',
|
78
|
+
'bar', DELTACLOUD_URL
|
79
|
+
r.must_equal false
|
80
|
+
lambda {
|
81
|
+
DeltacloudVM::Client.valid_credentials? 'foo',
|
82
|
+
'bar', 'http://unknown.local'
|
83
|
+
}.must_raise Faraday::Error::ConnectionFailed
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
end
|
@@ -0,0 +1,64 @@
|
|
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
|
+
require_relative '../test_helper'
|
17
|
+
|
18
|
+
describe DeltacloudVM::Client::Methods::Blob do
|
19
|
+
|
20
|
+
before do
|
21
|
+
VCR.insert_cassette(__name__)
|
22
|
+
@client = new_client
|
23
|
+
end
|
24
|
+
|
25
|
+
after do
|
26
|
+
VCR.eject_cassette
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'supports #blobs' do
|
30
|
+
@client.must_respond_to :blobs
|
31
|
+
@client.blobs('bucket1').must_be_kind_of Array
|
32
|
+
@client.blobs('bucket1').each { |r| r.must_be_instance_of DeltacloudVM::Client::Blob }
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'support #blob' do
|
36
|
+
@client.must_respond_to :blob
|
37
|
+
result = @client.blob('bucket1', 'blob1')
|
38
|
+
result.must_be_instance_of DeltacloudVM::Client::Blob
|
39
|
+
lambda { @client.blob('bucket1', 'foo') }.must_raise DeltacloudVM::Client::NotFound
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'support #create_blob and #destroy_blob' do
|
43
|
+
@client.must_respond_to :create_blob
|
44
|
+
result = @client.create_blob('bucket1', 'fooblob123', 'content_of_blob')
|
45
|
+
result.must_be_instance_of DeltacloudVM::Client::Blob
|
46
|
+
result.bucket_id.must_equal 'bucket1'
|
47
|
+
result._id.must_equal 'fooblob123'
|
48
|
+
result.content_length.must_equal '15'
|
49
|
+
result.content_type.must_equal 'text/plain'
|
50
|
+
@client.must_respond_to :destroy_blob
|
51
|
+
@client.destroy_blob('bucket1', result._id).must_equal true
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'support #create_blob and #destroy_blob with meta_params' do
|
55
|
+
@client.must_respond_to :create_blob
|
56
|
+
result = @client.create_blob('bucket1', 'fooblob123', 'content', :user_metadata => { :key => :value })
|
57
|
+
result.must_be_instance_of DeltacloudVM::Client::Blob
|
58
|
+
result.user_metadata.must_be_kind_of Hash
|
59
|
+
result.user_metadata['key'].must_equal 'value'
|
60
|
+
@client.must_respond_to :destroy_blob
|
61
|
+
@client.destroy_blob('bucket1', result._id).must_equal true
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,62 @@
|
|
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
|
+
require_relative '../test_helper'
|
17
|
+
|
18
|
+
describe DeltacloudVM::Client::Methods::Bucket do
|
19
|
+
|
20
|
+
before do
|
21
|
+
VCR.insert_cassette(__name__)
|
22
|
+
@client = new_client
|
23
|
+
end
|
24
|
+
|
25
|
+
after do
|
26
|
+
VCR.eject_cassette
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'supports #buckets' do
|
30
|
+
@client.must_respond_to :buckets
|
31
|
+
@client.buckets.must_be_kind_of Array
|
32
|
+
@client.buckets.each { |r| r.must_be_instance_of DeltacloudVM::Client::Bucket }
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'supports filtering #buckets by :id param' do
|
36
|
+
result = @client.buckets(:id => 'bucket1')
|
37
|
+
result.must_be_kind_of Array
|
38
|
+
result.size.must_equal 1
|
39
|
+
result.first.must_be_instance_of DeltacloudVM::Client::Bucket
|
40
|
+
result = @client.buckets(:id => 'unknown')
|
41
|
+
result.must_be_kind_of Array
|
42
|
+
result.size.must_equal 0
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'support #bucket' do
|
46
|
+
@client.must_respond_to :bucket
|
47
|
+
result = @client.bucket('bucket1')
|
48
|
+
result.must_be_instance_of DeltacloudVM::Client::Bucket
|
49
|
+
lambda { @client.bucket(nil) }.must_raise DeltacloudVM::Client::NotFound
|
50
|
+
lambda { @client.bucket('foo') }.must_raise DeltacloudVM::Client::NotFound
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'support #create_bucket and #destroy_bucket' do
|
54
|
+
@client.must_respond_to :create_bucket
|
55
|
+
b = @client.create_bucket('foo123')
|
56
|
+
b.must_be_instance_of DeltacloudVM::Client::Bucket
|
57
|
+
b.name.must_equal 'foo123'
|
58
|
+
@client.destroy_bucket(b._id)
|
59
|
+
lambda { @client.bucket(b._id) }.must_raise DeltacloudVM::Client::NotFound
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,48 @@
|
|
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
|
+
require_relative '../test_helper'
|
17
|
+
|
18
|
+
describe DeltacloudVM::Client::Methods::Driver do
|
19
|
+
|
20
|
+
before do
|
21
|
+
VCR.insert_cassette(__name__)
|
22
|
+
@client = new_client
|
23
|
+
end
|
24
|
+
|
25
|
+
after do
|
26
|
+
VCR.eject_cassette
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'supports #drivers' do
|
30
|
+
@client.must_respond_to :drivers
|
31
|
+
@client.drivers.must_be_kind_of Array
|
32
|
+
@client.drivers.each { |r| r.must_be_instance_of DeltacloudVM::Client::Driver }
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'supports #driver' do
|
36
|
+
@client.must_respond_to :driver
|
37
|
+
result = @client.driver('ec2')
|
38
|
+
result.must_be_instance_of DeltacloudVM::Client::Driver
|
39
|
+
lambda { @client.driver(nil) }.must_raise DeltacloudVM::Client::NotFound
|
40
|
+
lambda { @client.driver('foo') }.must_raise DeltacloudVM::Client::NotFound
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'supports #providers' do
|
44
|
+
@client.must_respond_to :providers
|
45
|
+
@client.providers.must_be_empty
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,84 @@
|
|
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
|
+
require_relative '../test_helper'
|
17
|
+
|
18
|
+
describe DeltacloudVM::Client::Methods::Firewall do
|
19
|
+
|
20
|
+
def new_client
|
21
|
+
DeltacloudVM::Client(DELTACLOUD_URL, 'AKIAJYOQYLLOIWN5LQ3A', 'Ra2ViYaYgocAJqPAQHxMVU/l2sGGU2pifmWT4q3H', :driver => :ec2 )
|
22
|
+
end
|
23
|
+
|
24
|
+
before do
|
25
|
+
VCR.insert_cassette(__name__)
|
26
|
+
@client = new_client
|
27
|
+
end
|
28
|
+
|
29
|
+
after do
|
30
|
+
VCR.eject_cassette
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'supports #firewalls' do
|
34
|
+
@client.must_respond_to :firewalls
|
35
|
+
begin
|
36
|
+
@client.firewalls.must_be_kind_of Array
|
37
|
+
rescue DeltacloudVM::Client::AuthenticationError
|
38
|
+
skip
|
39
|
+
end
|
40
|
+
@client.firewalls.each { |r| r.must_be_instance_of DeltacloudVM::Client::Firewall }
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'supports filtering #firewalls by :id param' do
|
44
|
+
begin
|
45
|
+
result = @client.firewalls(:id => 'mfojtik')
|
46
|
+
rescue DeltacloudVM::Client::AuthenticationError
|
47
|
+
skip
|
48
|
+
end
|
49
|
+
result.must_be_kind_of Array
|
50
|
+
result.size.must_equal 1
|
51
|
+
result.first.must_be_instance_of DeltacloudVM::Client::Firewall
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'support #firewall' do
|
55
|
+
@client.must_respond_to :firewall
|
56
|
+
begin
|
57
|
+
result = @client.firewall('mfojtik')
|
58
|
+
rescue
|
59
|
+
skip
|
60
|
+
end
|
61
|
+
result.must_be_instance_of DeltacloudVM::Client::Firewall
|
62
|
+
lambda { @client.firewall(nil) }.must_raise DeltacloudVM::Client::NotFound
|
63
|
+
lambda { @client.firewall('foo') }.must_raise DeltacloudVM::Client::NotFound
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'support #create_firewall and #destroy_firewall' do
|
67
|
+
@client.must_respond_to :create_firewall
|
68
|
+
@client.must_respond_to :destroy_firewall
|
69
|
+
begin
|
70
|
+
result = @client.create_firewall('foofirewall', :description => 'testing firewalls')
|
71
|
+
result.must_be_instance_of DeltacloudVM::Client::Firewall
|
72
|
+
result.name.must_equal 'foofirewall'
|
73
|
+
@client.destroy_firewall(result._id).must_equal true
|
74
|
+
lambda {
|
75
|
+
@client.create_firewall('foofirewall')
|
76
|
+
}.must_raise DeltacloudVM::Client::ClientFailure
|
77
|
+
rescue
|
78
|
+
skip
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
# FIXME: TBD, not supported by mock driver yet.
|
84
|
+
end
|
@@ -0,0 +1,53 @@
|
|
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
|
+
require_relative '../test_helper'
|
17
|
+
|
18
|
+
describe DeltacloudVM::Client::Methods::HardwareProfile do
|
19
|
+
|
20
|
+
before do
|
21
|
+
VCR.insert_cassette(__name__)
|
22
|
+
@client = new_client
|
23
|
+
end
|
24
|
+
|
25
|
+
after do
|
26
|
+
VCR.eject_cassette
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'supports #hardware_profiles' do
|
30
|
+
@client.must_respond_to :hardware_profiles
|
31
|
+
@client.hardware_profiles.must_be_kind_of Array
|
32
|
+
@client.hardware_profiles.each { |r| r.must_be_instance_of DeltacloudVM::Client::HardwareProfile }
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'supports filtering #hardware_profiles by :id param' do
|
36
|
+
result = @client.hardware_profiles(:id => 'm1-small')
|
37
|
+
result.must_be_kind_of Array
|
38
|
+
result.size.must_equal 1
|
39
|
+
result.first.must_be_instance_of DeltacloudVM::Client::HardwareProfile
|
40
|
+
result = @client.hardware_profiles(:id => 'unknown')
|
41
|
+
result.must_be_kind_of Array
|
42
|
+
result.size.must_equal 0
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'support #hardware_profile' do
|
46
|
+
@client.must_respond_to :hardware_profile
|
47
|
+
result = @client.hardware_profile('m1-small')
|
48
|
+
result.must_be_instance_of DeltacloudVM::Client::HardwareProfile
|
49
|
+
lambda { @client.hardware_profile(nil) }.must_raise DeltacloudVM::Client::NotFound
|
50
|
+
lambda { @client.hardware_profile('foo') }.must_raise DeltacloudVM::Client::NotFound
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,64 @@
|
|
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
|
+
require_relative '../test_helper'
|
17
|
+
|
18
|
+
describe DeltacloudVM::Client::Methods::Image do
|
19
|
+
|
20
|
+
before do
|
21
|
+
VCR.insert_cassette(__name__)
|
22
|
+
@client = new_client
|
23
|
+
end
|
24
|
+
|
25
|
+
after do
|
26
|
+
VCR.eject_cassette
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'supports #images' do
|
30
|
+
@client.must_respond_to :images
|
31
|
+
@client.images.must_be_kind_of Array
|
32
|
+
@client.images.each { |r| r.must_be_instance_of DeltacloudVM::Client::Image }
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'supports filtering #images by :id param' do
|
36
|
+
result = @client.images(:id => 'img1')
|
37
|
+
result.must_be_kind_of Array
|
38
|
+
result.size.must_equal 1
|
39
|
+
result.first.must_be_instance_of DeltacloudVM::Client::Image
|
40
|
+
result = @client.images(:id => 'unknown')
|
41
|
+
result.must_be_kind_of Array
|
42
|
+
result.size.must_equal 0
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'support #image' do
|
46
|
+
@client.must_respond_to :image
|
47
|
+
result = @client.image('img1')
|
48
|
+
result.must_be_instance_of DeltacloudVM::Client::Image
|
49
|
+
lambda { @client.image(nil) }.must_raise DeltacloudVM::Client::NotFound
|
50
|
+
lambda { @client.image('foo') }.must_raise DeltacloudVM::Client::NotFound
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'support #create_image and #destroy_image' do
|
54
|
+
@client.must_respond_to :create_image
|
55
|
+
img = @client.create_image('inst1', :name => 'test')
|
56
|
+
img.must_be_instance_of DeltacloudVM::Client::Image
|
57
|
+
img.name.must_equal 'test'
|
58
|
+
@client.destroy_image(img._id)
|
59
|
+
lambda {
|
60
|
+
@client.create_image(nil, :name => 'test')
|
61
|
+
}.must_raise DeltacloudVM::Client::ServerError
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|