deltacloud-client 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +73 -0
- data/Rakefile +88 -5
- data/lib/deltacloud/client.rb +79 -0
- data/lib/deltacloud/client/base_error.rb +80 -0
- data/lib/deltacloud/client/connection.rb +139 -0
- data/lib/deltacloud/client/helpers/model_helper.rb +69 -0
- data/lib/deltacloud/client/helpers/property_helper.rb +103 -0
- data/lib/deltacloud/client/helpers/xml_helper.rb +33 -0
- data/lib/deltacloud/client/methods.rb +33 -0
- data/lib/deltacloud/client/methods/address.rb +67 -0
- data/lib/deltacloud/client/methods/api.rb +96 -0
- data/lib/deltacloud/client/methods/backward_compatiblity.rb +72 -0
- data/lib/deltacloud/client/methods/blob.rb +91 -0
- data/lib/deltacloud/client/methods/bucket.rb +55 -0
- data/lib/deltacloud/client/methods/common.rb +46 -0
- data/lib/deltacloud/client/methods/driver.rb +53 -0
- data/lib/deltacloud/client/methods/firewall.rb +67 -0
- data/lib/deltacloud/client/methods/hardware_profile.rb +41 -0
- data/lib/deltacloud/client/methods/image.rb +61 -0
- data/lib/deltacloud/client/methods/instance.rb +141 -0
- data/lib/deltacloud/client/methods/instance_state.rb +41 -0
- data/lib/deltacloud/client/methods/key.rb +58 -0
- data/lib/deltacloud/client/methods/load_balancer.rb +96 -0
- data/lib/deltacloud/client/methods/metric.rb +54 -0
- data/lib/deltacloud/client/methods/realm.rb +42 -0
- data/lib/deltacloud/client/methods/storage_snapshot.rb +61 -0
- data/lib/deltacloud/client/methods/storage_volume.rb +94 -0
- data/lib/deltacloud/client/models.rb +32 -0
- data/lib/deltacloud/client/models/address.rb +57 -0
- data/lib/deltacloud/client/models/base.rb +153 -0
- data/lib/deltacloud/client/models/blob.rb +56 -0
- data/lib/deltacloud/client/models/bucket.rb +65 -0
- data/lib/deltacloud/client/models/driver.rb +87 -0
- data/lib/deltacloud/client/models/firewall.rb +64 -0
- data/lib/deltacloud/client/models/hardware_profile.rb +68 -0
- data/lib/deltacloud/client/models/image.rb +60 -0
- data/lib/deltacloud/client/models/instance.rb +142 -0
- data/lib/deltacloud/client/models/instance_address.rb +40 -0
- data/lib/{instance_state.rb → deltacloud/client/models/instance_state.rb} +11 -3
- data/lib/deltacloud/client/models/key.rb +52 -0
- data/lib/deltacloud/client/models/load_balancer.rb +55 -0
- data/lib/deltacloud/client/models/metric.rb +72 -0
- data/lib/deltacloud/client/models/realm.rb +29 -0
- data/lib/deltacloud/client/models/storage_snapshot.rb +54 -0
- data/lib/deltacloud/client/models/storage_volume.rb +96 -0
- data/lib/deltacloud/core_ext.rb +19 -0
- data/lib/deltacloud/core_ext/element.rb +32 -0
- data/lib/deltacloud/core_ext/fixnum.rb +30 -0
- data/lib/deltacloud/core_ext/nil.rb +22 -0
- data/lib/{string.rb → deltacloud/core_ext/string.rb} +16 -26
- data/lib/deltacloud/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 +59 -11
- metadata +392 -41
- data/lib/base_object.rb +0 -386
- data/lib/client_bucket_methods.rb +0 -69
- data/lib/deltacloud.rb +0 -486
- data/lib/documentation.rb +0 -59
- data/lib/errors.rb +0 -140
- data/lib/hwp_properties.rb +0 -61
- data/tests/buckets_test.rb +0 -141
- data/tests/client_test.rb +0 -59
- data/tests/content_negotiation_test.rb +0 -127
- data/tests/errors_test.rb +0 -57
- data/tests/hardware_profiles_test.rb +0 -75
- data/tests/images_test.rb +0 -102
- data/tests/instance_states_test.rb +0 -66
- data/tests/instances_test.rb +0 -203
- data/tests/keys_test.rb +0 -81
- data/tests/realms_test.rb +0 -64
- data/tests/storage_snapshot_test.rb +0 -76
- data/tests/storage_volume_test.rb +0 -86
@@ -0,0 +1,166 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://localhost:3001/api
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/xml
|
12
|
+
Authorization:
|
13
|
+
- Basic bW9ja3VzZXI6bW9ja3Bhc3N3b3Jk
|
14
|
+
User-Agent:
|
15
|
+
- Faraday v0.8.6
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message:
|
20
|
+
headers:
|
21
|
+
content-type:
|
22
|
+
- application/xml
|
23
|
+
server:
|
24
|
+
- Apache-Deltacloud/1.1.1
|
25
|
+
x-deltacloud-driver:
|
26
|
+
- mock
|
27
|
+
content-length:
|
28
|
+
- '1368'
|
29
|
+
x-content-type-options:
|
30
|
+
- nosniff
|
31
|
+
etag:
|
32
|
+
- e43d25244dc2b8ce1da6fa91131507ee
|
33
|
+
cache-control:
|
34
|
+
- max-age=0, private, must-revalidate
|
35
|
+
date:
|
36
|
+
- Wed, 06 Mar 2013 08:56:17 GMT
|
37
|
+
connection:
|
38
|
+
- close
|
39
|
+
body:
|
40
|
+
encoding: US-ASCII
|
41
|
+
string: ! "<api driver='mock' version='1.1.1'>\n <link href='http://localhost:3001/api/instance_states'
|
42
|
+
rel='instance_states'>\n </link>\n <link href='http://localhost:3001/api/storage_volumes'
|
43
|
+
rel='storage_volumes'>\n </link>\n <link href='http://localhost:3001/api/metrics'
|
44
|
+
rel='metrics'>\n </link>\n <link href='http://localhost:3001/api/hardware_profiles'
|
45
|
+
rel='hardware_profiles'>\n </link>\n <link href='http://localhost:3001/api/instances'
|
46
|
+
rel='instances'>\n <feature name='metrics' rel='create'>\n <param
|
47
|
+
name='metrics' />\n </feature>\n <feature name='realm_filter' rel='index'>\n
|
48
|
+
\ <param name='realm_id' />\n </feature>\n <feature name='user_name'
|
49
|
+
rel='create'>\n <param name='name' />\n </feature>\n <feature name='authentication_key'
|
50
|
+
rel='create'>\n <param name='keyname' />\n </feature>\n </link>\n
|
51
|
+
\ <link href='http://localhost:3001/api/realms' rel='realms'>\n </link>\n
|
52
|
+
\ <link href='http://localhost:3001/api/storage_snapshots' rel='storage_snapshots'>\n
|
53
|
+
\ </link>\n <link href='http://localhost:3001/api/images' rel='images'>\n
|
54
|
+
\ </link>\n <link href='http://localhost:3001/api/addresses' rel='addresses'>\n
|
55
|
+
\ </link>\n <link href='http://localhost:3001/api/drivers' rel='drivers'>\n
|
56
|
+
\ </link>\n <link href='http://localhost:3001/api/buckets' rel='buckets'>\n
|
57
|
+
\ </link>\n <link href='http://localhost:3001/api/keys' rel='keys'>\n </link>\n</api>\n"
|
58
|
+
http_version:
|
59
|
+
recorded_at: Wed, 06 Mar 2013 08:56:17 GMT
|
60
|
+
- request:
|
61
|
+
method: post
|
62
|
+
uri: http://localhost:3001/api/instances?image_id=img1
|
63
|
+
body:
|
64
|
+
encoding: US-ASCII
|
65
|
+
string: ''
|
66
|
+
headers:
|
67
|
+
Accept:
|
68
|
+
- application/xml
|
69
|
+
Authorization:
|
70
|
+
- Basic bW9ja3VzZXI6bW9ja3Bhc3N3b3Jk
|
71
|
+
User-Agent:
|
72
|
+
- Faraday v0.8.6
|
73
|
+
response:
|
74
|
+
status:
|
75
|
+
code: 201
|
76
|
+
message:
|
77
|
+
headers:
|
78
|
+
content-type:
|
79
|
+
- application/xml
|
80
|
+
location:
|
81
|
+
- http://localhost:3001/api/instances/inst12
|
82
|
+
server:
|
83
|
+
- Apache-Deltacloud/1.1.1
|
84
|
+
x-deltacloud-driver:
|
85
|
+
- mock
|
86
|
+
content-length:
|
87
|
+
- '1175'
|
88
|
+
x-content-type-options:
|
89
|
+
- nosniff
|
90
|
+
etag:
|
91
|
+
- 45aa1a1069561afacf53bfa0617937c2
|
92
|
+
cache-control:
|
93
|
+
- max-age=0, private, must-revalidate
|
94
|
+
date:
|
95
|
+
- Wed, 06 Mar 2013 08:56:17 GMT
|
96
|
+
connection:
|
97
|
+
- close
|
98
|
+
body:
|
99
|
+
encoding: US-ASCII
|
100
|
+
string: ! "<?xml version='1.0' encoding='utf-8' ?>\n<instance href='http://localhost:3001/api/instances/inst12'
|
101
|
+
id='inst12'>\n <name>i-1362560177</name>\n <owner_id>mockuser</owner_id>\n
|
102
|
+
\ <image href='http://localhost:3001/api/images/img1' id='img1'></image>\n
|
103
|
+
\ <realm href='http://localhost:3001/api/realms/us' id='us'></realm>\n <state>RUNNING</state>\n
|
104
|
+
\ <hardware_profile href='http://localhost:3001/api/hardware_profiles/m1-small'
|
105
|
+
id='m1-small'>\n </hardware_profile>\n <actions>\n <link href='http://localhost:3001/api/instances/inst12/reboot'
|
106
|
+
method='post' rel='reboot' />\n <link href='http://localhost:3001/api/instances/inst12/stop'
|
107
|
+
method='post' rel='stop' />\n <link href='http://localhost:3001/api/instances/inst12/run;id=inst12'
|
108
|
+
method='post' rel='run' />\n <link href='http://localhost:3001/api/images;instance_id=inst12'
|
109
|
+
method='post' rel='create_image' />\n </actions>\n <public_addresses><address
|
110
|
+
type='hostname'>img1.inst12.public.com</address></public_addresses>\n <private_addresses><address
|
111
|
+
type='hostname'>img1.inst12.private.com</address></private_addresses>\n <storage_volumes></storage_volumes>\n
|
112
|
+
\ <authentication type='key'>\n </authentication>\n</instance>\n"
|
113
|
+
http_version:
|
114
|
+
recorded_at: Wed, 06 Mar 2013 08:56:17 GMT
|
115
|
+
- request:
|
116
|
+
method: post
|
117
|
+
uri: http://localhost:3001/api/instances/inst12/reboot
|
118
|
+
body:
|
119
|
+
encoding: US-ASCII
|
120
|
+
string: ''
|
121
|
+
headers:
|
122
|
+
Accept:
|
123
|
+
- application/xml
|
124
|
+
Authorization:
|
125
|
+
- Basic bW9ja3VzZXI6bW9ja3Bhc3N3b3Jk
|
126
|
+
User-Agent:
|
127
|
+
- Faraday v0.8.6
|
128
|
+
response:
|
129
|
+
status:
|
130
|
+
code: 202
|
131
|
+
message:
|
132
|
+
headers:
|
133
|
+
content-type:
|
134
|
+
- application/xml
|
135
|
+
x-backend-runtime:
|
136
|
+
- '0.0019261837005615234'
|
137
|
+
server:
|
138
|
+
- Apache-Deltacloud/1.1.1
|
139
|
+
x-deltacloud-driver:
|
140
|
+
- mock
|
141
|
+
content-length:
|
142
|
+
- '1175'
|
143
|
+
x-content-type-options:
|
144
|
+
- nosniff
|
145
|
+
date:
|
146
|
+
- Wed, 06 Mar 2013 08:56:17 GMT
|
147
|
+
connection:
|
148
|
+
- close
|
149
|
+
body:
|
150
|
+
encoding: US-ASCII
|
151
|
+
string: ! "<?xml version='1.0' encoding='utf-8' ?>\n<instance href='http://localhost:3001/api/instances/inst12'
|
152
|
+
id='inst12'>\n <name>i-1362560177</name>\n <owner_id>mockuser</owner_id>\n
|
153
|
+
\ <image href='http://localhost:3001/api/images/img1' id='img1'></image>\n
|
154
|
+
\ <realm href='http://localhost:3001/api/realms/us' id='us'></realm>\n <state>RUNNING</state>\n
|
155
|
+
\ <hardware_profile href='http://localhost:3001/api/hardware_profiles/m1-small'
|
156
|
+
id='m1-small'>\n </hardware_profile>\n <actions>\n <link href='http://localhost:3001/api/instances/inst12/reboot'
|
157
|
+
method='post' rel='reboot' />\n <link href='http://localhost:3001/api/instances/inst12/stop'
|
158
|
+
method='post' rel='stop' />\n <link href='http://localhost:3001/api/instances/inst12/run;id=inst12'
|
159
|
+
method='post' rel='run' />\n <link href='http://localhost:3001/api/images;instance_id=inst12'
|
160
|
+
method='post' rel='create_image' />\n </actions>\n <public_addresses><address
|
161
|
+
type='hostname'>img1.inst12.public.com</address></public_addresses>\n <private_addresses><address
|
162
|
+
type='hostname'>img1.inst12.private.com</address></private_addresses>\n <storage_volumes></storage_volumes>\n
|
163
|
+
\ <authentication type='key'>\n </authentication>\n</instance>\n"
|
164
|
+
http_version:
|
165
|
+
recorded_at: Wed, 06 Mar 2013 08:56:17 GMT
|
166
|
+
recorded_with: VCR 2.4.0
|
@@ -0,0 +1,60 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://localhost:3001/api
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/xml
|
12
|
+
Authorization:
|
13
|
+
- Basic bW9ja3VzZXI6bW9ja3Bhc3N3b3Jk
|
14
|
+
User-Agent:
|
15
|
+
- Faraday v0.8.6
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message:
|
20
|
+
headers:
|
21
|
+
content-type:
|
22
|
+
- application/xml
|
23
|
+
server:
|
24
|
+
- Apache-Deltacloud/1.1.1
|
25
|
+
x-deltacloud-driver:
|
26
|
+
- mock
|
27
|
+
content-length:
|
28
|
+
- '1368'
|
29
|
+
x-content-type-options:
|
30
|
+
- nosniff
|
31
|
+
etag:
|
32
|
+
- e43d25244dc2b8ce1da6fa91131507ee
|
33
|
+
cache-control:
|
34
|
+
- max-age=0, private, must-revalidate
|
35
|
+
date:
|
36
|
+
- Wed, 06 Mar 2013 08:56:15 GMT
|
37
|
+
connection:
|
38
|
+
- close
|
39
|
+
body:
|
40
|
+
encoding: US-ASCII
|
41
|
+
string: ! "<api driver='mock' version='1.1.1'>\n <link href='http://localhost:3001/api/instance_states'
|
42
|
+
rel='instance_states'>\n </link>\n <link href='http://localhost:3001/api/storage_volumes'
|
43
|
+
rel='storage_volumes'>\n </link>\n <link href='http://localhost:3001/api/metrics'
|
44
|
+
rel='metrics'>\n </link>\n <link href='http://localhost:3001/api/hardware_profiles'
|
45
|
+
rel='hardware_profiles'>\n </link>\n <link href='http://localhost:3001/api/instances'
|
46
|
+
rel='instances'>\n <feature name='metrics' rel='create'>\n <param
|
47
|
+
name='metrics' />\n </feature>\n <feature name='realm_filter' rel='index'>\n
|
48
|
+
\ <param name='realm_id' />\n </feature>\n <feature name='user_name'
|
49
|
+
rel='create'>\n <param name='name' />\n </feature>\n <feature name='authentication_key'
|
50
|
+
rel='create'>\n <param name='keyname' />\n </feature>\n </link>\n
|
51
|
+
\ <link href='http://localhost:3001/api/realms' rel='realms'>\n </link>\n
|
52
|
+
\ <link href='http://localhost:3001/api/storage_snapshots' rel='storage_snapshots'>\n
|
53
|
+
\ </link>\n <link href='http://localhost:3001/api/images' rel='images'>\n
|
54
|
+
\ </link>\n <link href='http://localhost:3001/api/addresses' rel='addresses'>\n
|
55
|
+
\ </link>\n <link href='http://localhost:3001/api/drivers' rel='drivers'>\n
|
56
|
+
\ </link>\n <link href='http://localhost:3001/api/buckets' rel='buckets'>\n
|
57
|
+
\ </link>\n <link href='http://localhost:3001/api/keys' rel='keys'>\n </link>\n</api>\n"
|
58
|
+
http_version:
|
59
|
+
recorded_at: Wed, 06 Mar 2013 08:56:15 GMT
|
60
|
+
recorded_with: VCR 2.4.0
|
@@ -0,0 +1,33 @@
|
|
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 Deltacloud::Client::Helpers::Model do
|
19
|
+
|
20
|
+
include Deltacloud::Client::Helpers::Model
|
21
|
+
|
22
|
+
it 'supports #model' do
|
23
|
+
model(:error).must_equal Deltacloud::Client::Error
|
24
|
+
model('error').must_equal Deltacloud::Client::Error
|
25
|
+
lambda { model(nil) }.must_raise Deltacloud::Client::Error
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'supports #error' do
|
29
|
+
error.must_equal Deltacloud::Client::Error
|
30
|
+
error(:not_supported).must_equal Deltacloud::Client::NotSupported
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,56 @@
|
|
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 Deltacloud::Client::Helpers::XmlHelper do
|
19
|
+
|
20
|
+
include Deltacloud::Client::Helpers::XmlHelper
|
21
|
+
|
22
|
+
before do
|
23
|
+
VCR.insert_cassette(__name__)
|
24
|
+
end
|
25
|
+
|
26
|
+
after do
|
27
|
+
VCR.eject_cassette
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'supports #extract_xml_body using string' do
|
31
|
+
extract_xml_body("test").must_be_kind_of String
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'supports #extract_xml_body using faraday connection' do
|
35
|
+
result = extract_xml_body(new_client.connection.get('/api'))
|
36
|
+
result.must_be_kind_of String
|
37
|
+
result.wont_be_empty
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'supports #extract_xml_body using nokogiri::document' do
|
41
|
+
result = extract_xml_body(
|
42
|
+
Nokogiri::XML(new_client.connection.get('/api').body)
|
43
|
+
)
|
44
|
+
result.must_be_kind_of String
|
45
|
+
result.wont_be_empty
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'supports #extract_xml_body using nokogiri::element' do
|
49
|
+
result = extract_xml_body(
|
50
|
+
Nokogiri::XML(new_client.connection.get('/api').body).root
|
51
|
+
)
|
52
|
+
result.must_be_kind_of String
|
53
|
+
result.wont_be_empty
|
54
|
+
end
|
55
|
+
|
56
|
+
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 Deltacloud::Client::Methods::Address 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 #addresses' do
|
30
|
+
@client.must_respond_to :addresses
|
31
|
+
@client.addresses.must_be_kind_of Array
|
32
|
+
@client.addresses.each { |r| r.must_be_instance_of Deltacloud::Client::Address }
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'supports filtering #addresses by :id param' do
|
36
|
+
result = @client.addresses(:id => '192.168.0.1')
|
37
|
+
result.must_be_kind_of Array
|
38
|
+
result.size.must_equal 1
|
39
|
+
result.first.must_be_instance_of Deltacloud::Client::Address
|
40
|
+
result = @client.addresses(:id => 'unknown')
|
41
|
+
result.must_be_kind_of Array
|
42
|
+
result.size.must_equal 0
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'support #address' do
|
46
|
+
@client.must_respond_to :address
|
47
|
+
result = @client.address('192.168.0.1')
|
48
|
+
result.must_be_instance_of Deltacloud::Client::Address
|
49
|
+
lambda { @client.address(nil) }.must_raise Deltacloud::Client::NotFound
|
50
|
+
lambda { @client.address('foo') }.must_raise Deltacloud::Client::NotFound
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'support #create_address' do
|
54
|
+
@client.must_respond_to :create_address
|
55
|
+
result = @client.create_address
|
56
|
+
result.must_be_instance_of Deltacloud::Client::Address
|
57
|
+
result.ip.wont_be_empty
|
58
|
+
result.instance_id.must_be_nil
|
59
|
+
@client.must_respond_to :destroy_address
|
60
|
+
@client.destroy_address(result._id).must_equal true
|
61
|
+
lambda { @client.address(result._id) }.must_raise Deltacloud::Client::NotFound
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,97 @@
|
|
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 Deltacloud::Client::Methods::Api 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 #path' do
|
30
|
+
@client.must_respond_to :path
|
31
|
+
@client.path.must_be_kind_of String
|
32
|
+
@client.path.must_equal '/api'
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'supports #api_uri' do
|
36
|
+
@client.must_respond_to :api_uri
|
37
|
+
@client.api_uri('/sample').must_be_kind_of URI::Generic
|
38
|
+
@client.api_uri('/sample').to_s.must_equal '/api/sample'
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'supports #version' do
|
42
|
+
@client.must_respond_to :version
|
43
|
+
@client.version.must_equal '1.1.1'
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'supports #current_driver' do
|
47
|
+
@client.must_respond_to :current_driver
|
48
|
+
@client.current_driver.must_equal 'mock'
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'supports #current_provider' do
|
52
|
+
@client.must_respond_to :current_provider
|
53
|
+
@client.current_provider.must_be_nil
|
54
|
+
@client.use(:ec2, 'foo', 'bar', 'eu-west-1').current_provider.must_equal 'eu-west-1'
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'supports #supported_collections' do
|
58
|
+
@client.must_respond_to :supported_collections
|
59
|
+
@client.supported_collections.must_be_kind_of Array
|
60
|
+
@client.supported_collections.wont_be_empty
|
61
|
+
@client.supported_collections.must_include 'realms'
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'supports #support?' do
|
65
|
+
@client.must_respond_to :"support?"
|
66
|
+
@client.support?('realms').must_equal true
|
67
|
+
@client.support?(:realms).must_equal true
|
68
|
+
@client.support?('foo').must_equal false
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'supports #must_support!' do
|
72
|
+
@client.must_respond_to :"must_support!"
|
73
|
+
@client.must_support!(:realms).must_be_nil
|
74
|
+
@client.must_support!('realms').must_be_nil
|
75
|
+
lambda { @client.must_support!(:foo) }.must_raise @client.error(:not_supported)
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'supports #features' do
|
79
|
+
@client.must_respond_to :features
|
80
|
+
@client.features.must_be_kind_of Hash
|
81
|
+
@client.features['instances'].wont_be_nil
|
82
|
+
@client.features['instances'].must_be_kind_of Array
|
83
|
+
@client.features['instances'].wont_be_empty
|
84
|
+
@client.features['instances'].must_include 'user_name'
|
85
|
+
@client.features['instances'].wont_include nil
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'supports #feature?' do
|
89
|
+
@client.must_respond_to :"feature?"
|
90
|
+
@client.feature?(:instances, 'user_name').must_equal true
|
91
|
+
@client.feature?('instances', :user_name).must_equal true
|
92
|
+
@client.feature?('instances', :foo).must_equal false
|
93
|
+
@client.feature?(:foo, :foo).must_equal false
|
94
|
+
@client.feature?(nil, nil).must_equal false
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|