fog 1.12.1 → 1.13.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -1
- data/Gemfile +5 -0
- data/Rakefile +14 -4
- data/bin/fog +22 -0
- data/changelog.txt +262 -0
- data/fog.gemspec +8 -4
- data/lib/fog/aws.rb +11 -0
- data/lib/fog/aws/auto_scaling.rb +15 -18
- data/lib/fog/aws/beanstalk.rb +8 -10
- data/lib/fog/aws/cloud_formation.rb +9 -12
- data/lib/fog/aws/compute.rb +8 -10
- data/lib/fog/aws/credential_fetcher.rb +6 -6
- data/lib/fog/aws/elasticache.rb +13 -17
- data/lib/fog/aws/elb.rb +29 -31
- data/lib/fog/aws/iam.rb +10 -13
- data/lib/fog/aws/models/auto_scaling/group.rb +6 -3
- data/lib/fog/aws/models/compute/spot_request.rb +1 -11
- data/lib/fog/aws/models/rds/log_file.rb +26 -0
- data/lib/fog/aws/models/rds/log_files.rb +50 -0
- data/lib/fog/aws/models/rds/server.rb +3 -1
- data/lib/fog/aws/models/rds/snapshot.rb +1 -0
- data/lib/fog/aws/models/rds/snapshots.rb +20 -13
- data/lib/fog/aws/parsers/rds/db_parser.rb +1 -1
- data/lib/fog/aws/parsers/rds/describe_db_log_files.rb +44 -0
- data/lib/fog/aws/parsers/rds/download_db_logfile_portion.rb +26 -0
- data/lib/fog/aws/parsers/ses/verify_domain_identity.rb +26 -0
- data/lib/fog/aws/parsers/storage/complete_multipart_upload.rb +1 -1
- data/lib/fog/aws/parsers/sts/assume_role.rb +30 -0
- data/lib/fog/aws/rds.rb +27 -14
- data/lib/fog/aws/requests/auto_scaling/create_auto_scaling_group.rb +8 -0
- data/lib/fog/aws/requests/auto_scaling/update_auto_scaling_group.rb +8 -1
- data/lib/fog/aws/requests/compute/create_volume.rb +3 -3
- data/lib/fog/aws/requests/rds/create_db_instance.rb +3 -1
- data/lib/fog/aws/requests/rds/describe_db_log_files.rb +67 -0
- data/lib/fog/aws/requests/rds/download_db_logfile_portion.rb +63 -0
- data/lib/fog/aws/requests/ses/send_raw_email.rb +1 -1
- data/lib/fog/aws/requests/ses/verify_domain_identity.rb +30 -0
- data/lib/fog/aws/requests/storage/complete_multipart_upload.rb +6 -2
- data/lib/fog/aws/requests/storage/get_object.rb +1 -1
- data/lib/fog/aws/requests/sts/assume_role.rb +46 -0
- data/lib/fog/aws/ses.rb +26 -9
- data/lib/fog/aws/storage.rb +2 -1
- data/lib/fog/aws/sts.rb +31 -21
- data/lib/fog/bin.rb +0 -1
- data/lib/fog/bin/openstack.rb +5 -0
- data/lib/fog/brightbox/compute.rb +20 -212
- data/lib/fog/brightbox/compute/shared.rb +232 -0
- data/lib/fog/brightbox/models/compute/collaboration.rb +43 -0
- data/lib/fog/brightbox/models/compute/collaborations.rb +23 -0
- data/lib/fog/brightbox/models/compute/user_collaboration.rb +29 -0
- data/lib/fog/brightbox/models/compute/user_collaborations.rb +23 -0
- data/lib/fog/brightbox/requests/compute/accept_user_collaboration.rb +21 -0
- data/lib/fog/brightbox/requests/compute/create_collaboration.rb +23 -0
- data/lib/fog/brightbox/requests/compute/delete_collaboration.rb +28 -0
- data/lib/fog/brightbox/requests/compute/delete_user_collaboration.rb +28 -0
- data/lib/fog/brightbox/requests/compute/destroy_user_collaboration.rb +21 -0
- data/lib/fog/brightbox/requests/compute/get_collaboration.rb +21 -0
- data/lib/fog/brightbox/requests/compute/get_user_collaboration.rb +21 -0
- data/lib/fog/brightbox/requests/compute/list_collaborations.rb +19 -0
- data/lib/fog/brightbox/requests/compute/list_user_collaborations.rb +19 -0
- data/lib/fog/brightbox/requests/compute/reject_user_collaboration.rb +21 -0
- data/lib/fog/brightbox/requests/compute/resend_collaboration.rb +21 -0
- data/lib/fog/cloudsigma/docs/getting_started.md +59 -0
- data/lib/fog/core.rb +7 -2
- data/lib/fog/core/connection.rb +62 -29
- data/lib/fog/core/deprecated/connection.rb +24 -0
- data/lib/fog/core/parser.rb +1 -1
- data/lib/fog/digitalocean/examples/getting_started.md +1 -1
- data/lib/fog/digitalocean/models/compute/server.rb +2 -2
- data/lib/fog/google/compute.rb +31 -7
- data/lib/fog/google/models/compute/disk.rb +80 -0
- data/lib/fog/google/models/compute/disks.rb +28 -0
- data/lib/fog/google/models/compute/image.rb +36 -0
- data/lib/fog/google/models/compute/server.rb +46 -33
- data/lib/fog/google/models/compute/servers.rb +15 -8
- data/lib/fog/google/requests/compute/delete_server.rb +5 -2
- data/lib/fog/google/requests/compute/get_disk.rb +3 -0
- data/lib/fog/google/requests/compute/get_server.rb +7 -1
- data/lib/fog/google/requests/compute/insert_disk.rb +8 -2
- data/lib/fog/google/requests/compute/insert_server.rb +51 -22
- data/lib/fog/google/requests/compute/list_machine_types.rb +3 -2
- data/lib/fog/google/requests/storage/get_object.rb +1 -1
- data/lib/fog/hp/requests/storage/get_object.rb +1 -1
- data/lib/fog/hp/storage.rb +26 -9
- data/lib/fog/ibm/requests/compute/create_instance.rb +20 -15
- data/lib/fog/internet_archive/requests/storage/get_object.rb +1 -1
- data/lib/fog/{core/json.rb → json.rb} +13 -2
- data/lib/fog/metering.rb +25 -0
- data/lib/fog/openstack.rb +1 -0
- data/lib/fog/openstack/metering.rb +215 -0
- data/lib/fog/openstack/models/compute/flavors.rb +2 -2
- data/lib/fog/openstack/models/compute/metadata.rb +1 -1
- data/lib/fog/openstack/models/compute/server.rb +5 -2
- data/lib/fog/openstack/models/image/images.rb +1 -1
- data/lib/fog/openstack/models/metering/meter.rb +0 -0
- data/lib/fog/openstack/models/metering/meters.rb +0 -0
- data/lib/fog/openstack/models/metering/resource.rb +24 -0
- data/lib/fog/openstack/models/metering/resources.rb +25 -0
- data/lib/fog/openstack/models/volume/volume.rb +3 -1
- data/lib/fog/openstack/models/volume/volumes.rb +2 -1
- data/lib/fog/openstack/network.rb +1 -1
- data/lib/fog/openstack/requests/compute/create_flavor.rb +1 -1
- data/lib/fog/openstack/requests/compute/create_server.rb +19 -1
- data/lib/fog/openstack/requests/compute/detach_volume.rb +2 -1
- data/lib/fog/openstack/requests/compute/list_flavors_detail.rb +4 -3
- data/lib/fog/openstack/requests/compute/list_security_groups.rb +1 -1
- data/lib/fog/openstack/requests/identity/create_tenant.rb +2 -2
- data/lib/fog/openstack/requests/metering/get_resource.rb +32 -0
- data/lib/fog/openstack/requests/metering/get_samples.rb +55 -0
- data/lib/fog/openstack/requests/metering/get_statistics.rb +56 -0
- data/lib/fog/openstack/requests/metering/list_meters.rb +50 -0
- data/lib/fog/openstack/requests/metering/list_resources.rb +32 -0
- data/lib/fog/openstack/requests/volume/create_volume.rb +4 -2
- data/lib/fog/rackspace.rb +16 -1
- data/lib/fog/rackspace/block_storage.rb +13 -28
- data/lib/fog/rackspace/cdn.rb +10 -24
- data/lib/fog/rackspace/compute.rb +17 -45
- data/lib/fog/rackspace/compute_v2.rb +13 -33
- data/lib/fog/rackspace/databases.rb +13 -29
- data/lib/fog/rackspace/dns.rb +27 -23
- data/lib/fog/rackspace/identity.rb +10 -26
- data/lib/fog/rackspace/load_balancers.rb +13 -29
- data/lib/fog/rackspace/mock_data.rb +3 -3
- data/lib/fog/rackspace/models/compute/server.rb +1 -1
- data/lib/fog/rackspace/models/dns/zones.rb +34 -21
- data/lib/fog/rackspace/models/identity/users.rb +2 -2
- data/lib/fog/rackspace/models/storage/file.rb +1 -0
- data/lib/fog/rackspace/requests/dns/list_domains.rb +2 -2
- data/lib/fog/rackspace/requests/storage/delete_multiple_objects.rb +75 -0
- data/lib/fog/rackspace/requests/storage/delete_static_large_object.rb +50 -0
- data/lib/fog/rackspace/requests/storage/get_object.rb +3 -1
- data/lib/fog/rackspace/requests/storage/put_dynamic_obj_manifest.rb +44 -0
- data/lib/fog/rackspace/requests/storage/put_object_manifest.rb +3 -30
- data/lib/fog/rackspace/requests/storage/put_static_obj_manifest.rb +60 -0
- data/lib/fog/rackspace/service.rb +43 -1
- data/lib/fog/rackspace/storage.rb +25 -43
- data/lib/fog/riakcs/provisioning.rb +2 -1
- data/lib/fog/riakcs/usage.rb +2 -1
- data/lib/fog/vcloud/requests/compute/configure_vm_cpus.rb +1 -1
- data/lib/fog/vcloud/requests/compute/configure_vm_memory.rb +1 -1
- data/lib/fog/version.rb +1 -1
- data/lib/fog/vsphere/requests/compute/get_folder.rb +1 -1
- data/lib/fog/xenserver/compute.rb +2 -0
- data/lib/fog/xenserver/models/compute/server.rb +9 -7
- data/lib/fog/xenserver/requests/compute/snapshot_revert.rb +22 -0
- data/lib/fog/xenserver/requests/compute/snapshot_server.rb +22 -0
- data/lib/fog/xml.rb +21 -0
- data/lib/fog/xml/sax_parser_connection.rb +43 -0
- data/lib/tasks/changelog_task.rb +1 -0
- data/tests/aws/models/auto_scaling/groups_test.rb +22 -0
- data/tests/aws/requests/compute/volume_tests.rb +3 -3
- data/tests/aws/requests/rds/helper.rb +14 -0
- data/tests/aws/requests/rds/log_file_tests.rb +19 -0
- data/tests/aws/requests/ses/verified_domain_identity_tests.rb +16 -0
- data/tests/aws/requests/sts/assume_role_tests.rb +19 -0
- data/tests/brightbox/requests/compute/collaboration_tests.rb +41 -0
- data/tests/brightbox/requests/compute/helper.rb +46 -2
- data/tests/brightbox/requests/compute/user_collaboration_tests.rb +67 -0
- data/tests/core/connection_tests.rb +26 -0
- data/tests/helper.rb +13 -0
- data/tests/openstack/requests/metering/meter_tests.rb +52 -0
- data/tests/openstack/requests/metering/resource_tests.rb +19 -0
- data/tests/openvz/helper.rb +14 -8
- data/tests/rackspace/block_storage_tests.rb +9 -0
- data/tests/rackspace/compute_tests.rb +9 -0
- data/tests/rackspace/compute_v2_tests.rb +9 -0
- data/tests/rackspace/databases_tests.rb +9 -0
- data/tests/rackspace/dns_tests.rb +20 -0
- data/tests/rackspace/helper.rb +12 -1
- data/tests/rackspace/identity_tests.rb +25 -0
- data/tests/rackspace/load_balancer_tests.rb +10 -0
- data/tests/rackspace/models/block_storage/volume_tests.rb +2 -2
- data/tests/rackspace/models/compute_v2/metadata_tests.rb +2 -2
- data/tests/rackspace/models/compute_v2/server_tests.rb +22 -21
- data/tests/rackspace/models/dns/zones_tests.rb +19 -5
- data/tests/rackspace/models/storage/file_tests.rb +22 -6
- data/tests/rackspace/rackspace_tests.rb +35 -0
- data/tests/rackspace/requests/block_storage/snapshot_tests.rb +2 -3
- data/tests/rackspace/requests/block_storage/volume_type_tests.rb +4 -11
- data/tests/rackspace/requests/compute_v2/address_tests.rb +1 -1
- data/tests/rackspace/requests/compute_v2/attachment_tests.rb +8 -9
- data/tests/rackspace/requests/compute_v2/flavor_tests.rb +1 -1
- data/tests/rackspace/requests/compute_v2/metadata_tests.rb +4 -4
- data/tests/rackspace/requests/databases/database_tests.rb +23 -20
- data/tests/rackspace/requests/databases/user_tests.rb +6 -6
- data/tests/rackspace/requests/identity/user_tests.rb +4 -1
- data/tests/rackspace/requests/load_balancers/usage_tests.rb +4 -2
- data/tests/rackspace/requests/storage/large_object_tests.rb +303 -59
- data/tests/rackspace/requests/storage/object_tests.rb +73 -18
- data/tests/rackspace/service_tests.rb +83 -0
- data/tests/rackspace/storage_tests.rb +9 -0
- data/tests/xenserver/models/compute/server_tests.rb +11 -1
- metadata +89 -19
- data/tests/core/user_agent_tests.rb +0 -6
@@ -0,0 +1,32 @@
|
|
1
|
+
module Fog
|
2
|
+
module Metering
|
3
|
+
class OpenStack
|
4
|
+
class Real
|
5
|
+
|
6
|
+
def list_resources(options = {})
|
7
|
+
request(
|
8
|
+
:expects => 200,
|
9
|
+
:method => 'GET',
|
10
|
+
:path => 'resources'
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
class Mock
|
17
|
+
|
18
|
+
def list_resources(options = {})
|
19
|
+
response = Excon::Response.new
|
20
|
+
response.status = 200
|
21
|
+
response.body = [{
|
22
|
+
'resource_id'=>'glance',
|
23
|
+
'project_id'=>'d646b40dea6347dfb8caee2da1484c56',
|
24
|
+
'user_id'=>'1d5fd9eda19142289a60ed9330b5d284',
|
25
|
+
'metadata'=>{}}]
|
26
|
+
response
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -12,7 +12,8 @@ module Fog
|
|
12
12
|
}
|
13
13
|
}
|
14
14
|
|
15
|
-
vanilla_options = [
|
15
|
+
vanilla_options = [:snapshot_id, :imageRef, :volume_type,
|
16
|
+
:source_volid]
|
16
17
|
vanilla_options.select{|o| options[o]}.each do |key|
|
17
18
|
data['volume'][key] = options[key]
|
18
19
|
end
|
@@ -38,7 +39,8 @@ module Fog
|
|
38
39
|
'display_description' => description,
|
39
40
|
'size' => size,
|
40
41
|
'status' => 'creating',
|
41
|
-
'snapshot_id' => options[
|
42
|
+
'snapshot_id' => options[:snapshot_id] || nil,
|
43
|
+
'image_id' => options[:imageRef] || nil,
|
42
44
|
'volume_type' => nil,
|
43
45
|
'availability_zone' => 'nova',
|
44
46
|
'created_at' => Time.now,
|
data/lib/fog/rackspace.rb
CHANGED
@@ -28,7 +28,7 @@ module Fog
|
|
28
28
|
unless error.response.body.empty?
|
29
29
|
begin
|
30
30
|
data = Fog::JSON.decode(error.response.body)
|
31
|
-
message = data
|
31
|
+
message = extract_message(data)
|
32
32
|
rescue => e
|
33
33
|
Fog::Logger.warning("Received exception '#{e}' while decoding>> #{error.response.body}")
|
34
34
|
message = error.response.body
|
@@ -42,6 +42,16 @@ module Fog
|
|
42
42
|
new_error.instance_variable_set(:@status_code, status_code)
|
43
43
|
new_error
|
44
44
|
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def self.extract_message(data)
|
49
|
+
if data.is_a?(Hash)
|
50
|
+
message = data.values.first['message'] if data.values.first.is_a?(Hash)
|
51
|
+
message ||= data['message']
|
52
|
+
end
|
53
|
+
message || data.inspect
|
54
|
+
end
|
45
55
|
end
|
46
56
|
|
47
57
|
class InternalServerError < ServiceError; end
|
@@ -96,6 +106,11 @@ module Fog
|
|
96
106
|
end
|
97
107
|
end
|
98
108
|
|
109
|
+
def self.json_response?(response)
|
110
|
+
return false unless response && response.headers
|
111
|
+
response.headers['Content-Type'] =~ %r{application/json}i ? true : false
|
112
|
+
end
|
113
|
+
|
99
114
|
def self.normalize_url(endpoint)
|
100
115
|
return nil unless endpoint
|
101
116
|
str = endpoint.chomp " "
|
@@ -87,40 +87,25 @@ module Fog
|
|
87
87
|
@connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
|
88
88
|
end
|
89
89
|
|
90
|
-
def request(params)
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
}))
|
101
|
-
rescue Excon::Errors::NotFound => error
|
102
|
-
raise NotFound.slurp(error, region)
|
103
|
-
rescue Excon::Errors::BadRequest => error
|
104
|
-
raise BadRequest.slurp error
|
105
|
-
rescue Excon::Errors::InternalServerError => error
|
106
|
-
raise InternalServerError.slurp error
|
107
|
-
rescue Excon::Errors::HTTPStatusError => error
|
108
|
-
raise ServiceError.slurp error
|
109
|
-
end
|
110
|
-
unless response.body.empty?
|
111
|
-
response.body = Fog::JSON.decode(response.body)
|
112
|
-
end
|
113
|
-
response
|
90
|
+
def request(params, parse_json = true, &block)
|
91
|
+
super(params, parse_json, &block)
|
92
|
+
rescue Excon::Errors::NotFound => error
|
93
|
+
raise NotFound.slurp(error, region)
|
94
|
+
rescue Excon::Errors::BadRequest => error
|
95
|
+
raise BadRequest.slurp error
|
96
|
+
rescue Excon::Errors::InternalServerError => error
|
97
|
+
raise InternalServerError.slurp error
|
98
|
+
rescue Excon::Errors::HTTPStatusError => error
|
99
|
+
raise ServiceError.slurp error
|
114
100
|
end
|
115
101
|
|
116
|
-
def authenticate
|
117
|
-
|
102
|
+
def authenticate(options={})
|
103
|
+
super({
|
118
104
|
:rackspace_api_key => @rackspace_api_key,
|
119
105
|
:rackspace_username => @rackspace_username,
|
120
106
|
:rackspace_auth_url => @rackspace_auth_url,
|
121
107
|
:connection_options => @connection_options
|
122
|
-
}
|
123
|
-
super(options)
|
108
|
+
})
|
124
109
|
end
|
125
110
|
|
126
111
|
def service_name
|
data/lib/fog/rackspace/cdn.rb
CHANGED
@@ -152,30 +152,16 @@ module Fog
|
|
152
152
|
true
|
153
153
|
end
|
154
154
|
|
155
|
-
def request(params, parse_json = true)
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
}))
|
166
|
-
rescue Excon::Errors::NotFound => error
|
167
|
-
raise Fog::Storage::Rackspace::NotFound.slurp(error, region)
|
168
|
-
rescue Excon::Errors::BadRequest => error
|
169
|
-
raise Fog::Storage::Rackspace::BadRequest.slurp error
|
170
|
-
rescue Excon::Errors::InternalServerError => error
|
171
|
-
raise Fog::Storage::Rackspace::InternalServerError.slurp error
|
172
|
-
rescue Excon::Errors::HTTPStatusError => error
|
173
|
-
raise Fog::Storage::Rackspace::ServiceError.slurp error
|
174
|
-
end
|
175
|
-
if !response.body.empty? && parse_json && response.headers['Content-Type'] =~ %r{application/json}
|
176
|
-
response.body = Fog::JSON.decode(response.body)
|
177
|
-
end
|
178
|
-
response
|
155
|
+
def request(params, parse_json = true, &block)
|
156
|
+
super(params, parse_json, &block)
|
157
|
+
rescue Excon::Errors::NotFound => error
|
158
|
+
raise Fog::Storage::Rackspace::NotFound.slurp(error, region)
|
159
|
+
rescue Excon::Errors::BadRequest => error
|
160
|
+
raise Fog::Storage::Rackspace::BadRequest.slurp error
|
161
|
+
rescue Excon::Errors::InternalServerError => error
|
162
|
+
raise Fog::Storage::Rackspace::InternalServerError.slurp error
|
163
|
+
rescue Excon::Errors::HTTPStatusError => error
|
164
|
+
raise Fog::Storage::Rackspace::ServiceError.slurp error
|
179
165
|
end
|
180
166
|
|
181
167
|
private
|
@@ -190,7 +190,6 @@ module Fog
|
|
190
190
|
@rackspace_servicenet = options[:rackspace_servicenet]
|
191
191
|
@rackspace_auth_token = options[:rackspace_auth_token]
|
192
192
|
@rackspace_endpoint = Fog::Rackspace.normalize_url(options[:rackspace_compute_v1_url] || options[:rackspace_management_url])
|
193
|
-
@rackspace_must_reauthenticate = false
|
194
193
|
@connection_options = options[:connection_options] || {}
|
195
194
|
authenticate
|
196
195
|
Excon.defaults[:ssl_verify_peer] = false if service_net?
|
@@ -202,56 +201,29 @@ module Fog
|
|
202
201
|
@connection.reset
|
203
202
|
end
|
204
203
|
|
205
|
-
def request(params)
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
rescue Excon::Errors::Unauthorized => error
|
216
|
-
if error.response.body != 'Bad username or password' # token expiration
|
217
|
-
@rackspace_must_reauthenticate = true
|
218
|
-
authenticate
|
219
|
-
retry
|
220
|
-
else # bad credentials
|
221
|
-
raise error
|
222
|
-
end
|
223
|
-
rescue Excon::Errors::HTTPStatusError => error
|
224
|
-
raise case error
|
225
|
-
when Excon::Errors::NotFound
|
226
|
-
NotFound.slurp(error, region)
|
227
|
-
else
|
228
|
-
error
|
229
|
-
end
|
230
|
-
end
|
231
|
-
unless response.body.empty?
|
232
|
-
response.body = Fog::JSON.decode(response.body)
|
233
|
-
end
|
234
|
-
response
|
204
|
+
def request(params, parse_json = true, &block)
|
205
|
+
super(params, parse_json, &block)
|
206
|
+
rescue Excon::Errors::NotFound => error
|
207
|
+
raise NotFound.slurp(error, region)
|
208
|
+
rescue Excon::Errors::BadRequest => error
|
209
|
+
raise BadRequest.slurp error
|
210
|
+
rescue Excon::Errors::InternalServerError => error
|
211
|
+
raise InternalServerError.slurp error
|
212
|
+
rescue Excon::Errors::HTTPStatusError => error
|
213
|
+
raise ServiceError.slurp error
|
235
214
|
end
|
236
215
|
|
237
|
-
|
238
216
|
def service_net?
|
239
217
|
@rackspace_servicenet == true
|
240
218
|
end
|
241
219
|
|
242
|
-
def authenticate
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
}
|
250
|
-
super(options)
|
251
|
-
else
|
252
|
-
@auth_token = @rackspace_auth_token
|
253
|
-
@uri = URI.parse(@rackspace_endpoint)
|
254
|
-
end
|
220
|
+
def authenticate(options={})
|
221
|
+
super({
|
222
|
+
:rackspace_api_key => @rackspace_api_key,
|
223
|
+
:rackspace_username => @rackspace_username,
|
224
|
+
:rackspace_auth_url => @rackspace_auth_url,
|
225
|
+
:connection_options => @connection_options
|
226
|
+
})
|
255
227
|
end
|
256
228
|
|
257
229
|
def service_name
|
@@ -139,45 +139,25 @@ module Fog
|
|
139
139
|
@connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
|
140
140
|
end
|
141
141
|
|
142
|
-
def request(params)
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
}))
|
153
|
-
rescue Excon::Errors::NotFound => error
|
154
|
-
raise NotFound.slurp(error, region)
|
155
|
-
rescue Excon::Errors::BadRequest => error
|
156
|
-
raise BadRequest.slurp error
|
157
|
-
rescue Excon::Errors::InternalServerError => error
|
158
|
-
raise InternalServerError.slurp error
|
159
|
-
rescue Excon::Errors::HTTPStatusError => error
|
160
|
-
raise ServiceError.slurp error
|
161
|
-
end
|
162
|
-
|
163
|
-
unless response.body.empty?
|
164
|
-
begin
|
165
|
-
response.body = Fog::JSON.decode(response.body)
|
166
|
-
rescue MultiJson::DecodeError => e
|
167
|
-
response.body = {}
|
168
|
-
end
|
169
|
-
end
|
170
|
-
response
|
142
|
+
def request(params, parse_json = true, &block)
|
143
|
+
super(params, parse_json, &block)
|
144
|
+
rescue Excon::Errors::NotFound => error
|
145
|
+
raise NotFound.slurp(error, region)
|
146
|
+
rescue Excon::Errors::BadRequest => error
|
147
|
+
raise BadRequest.slurp error
|
148
|
+
rescue Excon::Errors::InternalServerError => error
|
149
|
+
raise InternalServerError.slurp error
|
150
|
+
rescue Excon::Errors::HTTPStatusError => error
|
151
|
+
raise ServiceError.slurp error
|
171
152
|
end
|
172
153
|
|
173
|
-
def authenticate
|
174
|
-
|
154
|
+
def authenticate(options={})
|
155
|
+
super({
|
175
156
|
:rackspace_api_key => @rackspace_api_key,
|
176
157
|
:rackspace_username => @rackspace_username,
|
177
158
|
:rackspace_auth_url => @rackspace_auth_url,
|
178
159
|
:connection_options => @connection_options
|
179
|
-
}
|
180
|
-
super(options)
|
160
|
+
})
|
181
161
|
end
|
182
162
|
|
183
163
|
def service_name
|
@@ -85,45 +85,29 @@ module Fog
|
|
85
85
|
@connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
|
86
86
|
end
|
87
87
|
|
88
|
-
def request(params)
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
}))
|
99
|
-
rescue Excon::Errors::NotFound => error
|
100
|
-
raise NotFound.slurp(error, region)
|
101
|
-
rescue Excon::Errors::BadRequest => error
|
102
|
-
raise BadRequest.slurp error
|
103
|
-
rescue Excon::Errors::InternalServerError => error
|
104
|
-
raise InternalServerError.slurp error
|
105
|
-
rescue Excon::Errors::HTTPStatusError => error
|
106
|
-
raise ServiceError.slurp error
|
107
|
-
end
|
108
|
-
unless response.body.empty?
|
109
|
-
response.body = Fog::JSON.decode(response.body)
|
110
|
-
end
|
111
|
-
response
|
88
|
+
def request(params, parse_json = true, &block)
|
89
|
+
super(params, parse_json, &block)
|
90
|
+
rescue Excon::Errors::NotFound => error
|
91
|
+
raise NotFound.slurp(error, region)
|
92
|
+
rescue Excon::Errors::BadRequest => error
|
93
|
+
raise BadRequest.slurp error
|
94
|
+
rescue Excon::Errors::InternalServerError => error
|
95
|
+
raise InternalServerError.slurp error
|
96
|
+
rescue Excon::Errors::HTTPStatusError => error
|
97
|
+
raise ServiceError.slurp error
|
112
98
|
end
|
113
99
|
|
114
100
|
def endpoint_uri(service_endpoint_url=nil)
|
115
101
|
@uri = super(@rackspace_endpoint || service_endpoint_url, :rackspace_database_url)
|
116
102
|
end
|
117
103
|
|
118
|
-
def authenticate
|
119
|
-
|
104
|
+
def authenticate(options={})
|
105
|
+
super({
|
120
106
|
:rackspace_api_key => @rackspace_api_key,
|
121
107
|
:rackspace_username => @rackspace_username,
|
122
108
|
:rackspace_auth_url => @rackspace_auth_url,
|
123
109
|
:connection_options => @connection_options
|
124
|
-
}
|
125
|
-
|
126
|
-
super(options)
|
110
|
+
})
|
127
111
|
end
|
128
112
|
|
129
113
|
private
|
data/lib/fog/rackspace/dns.rb
CHANGED
@@ -6,6 +6,12 @@ module Fog
|
|
6
6
|
class Rackspace < Fog::Service
|
7
7
|
include Fog::Rackspace::Errors
|
8
8
|
|
9
|
+
class ServiceError < Fog::Rackspace::Errors::ServiceError; end
|
10
|
+
class InternalServerError < Fog::Rackspace::Errors::InternalServerError; end
|
11
|
+
class BadRequest < Fog::Rackspace::Errors::BadRequest; end
|
12
|
+
class Conflict < Fog::Rackspace::Errors::Conflict; end
|
13
|
+
class ServiceUnavailable < Fog::Rackspace::Errors::ServiceUnavailable; end
|
14
|
+
|
9
15
|
class CallbackError < Fog::Errors::Error
|
10
16
|
attr_reader :response, :message, :details
|
11
17
|
def initialize(response)
|
@@ -95,9 +101,6 @@ module Fog
|
|
95
101
|
|
96
102
|
deprecation_warnings(options)
|
97
103
|
|
98
|
-
@connection_options[:headers] ||= {}
|
99
|
-
@connection_options[:headers].merge!({ 'Content-Type' => 'application/json', 'X-Auth-Token' => auth_token })
|
100
|
-
|
101
104
|
@persistent = options[:persistent] || false
|
102
105
|
@connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
|
103
106
|
end
|
@@ -108,29 +111,32 @@ module Fog
|
|
108
111
|
|
109
112
|
private
|
110
113
|
|
111
|
-
def request(params)
|
112
|
-
#TODO - Unify code with other rackspace services
|
114
|
+
def request(params, parse_json = true, &block)
|
113
115
|
begin
|
114
|
-
|
115
|
-
:path => "#{endpoint_uri.path}/#{params[:path]}"
|
116
|
-
}))
|
117
|
-
rescue Excon::Errors::BadRequest => error
|
118
|
-
raise Fog::Rackspace::Errors::BadRequest.slurp error
|
119
|
-
rescue Excon::Errors::Conflict => error
|
120
|
-
raise Fog::Rackspace::Errors::Conflict.slurp error
|
116
|
+
super(params, parse_json, &block)
|
121
117
|
rescue Excon::Errors::NotFound => error
|
122
118
|
raise NotFound.slurp(error, region)
|
119
|
+
rescue Excon::Errors::BadRequest => error
|
120
|
+
raise BadRequest.slurp error
|
121
|
+
rescue Excon::Errors::InternalServerError => error
|
122
|
+
raise InternalServerError.slurp error
|
123
123
|
rescue Excon::Errors::ServiceUnavailable => error
|
124
|
-
raise
|
125
|
-
|
126
|
-
|
127
|
-
|
124
|
+
raise ServiceUnavailable.slurp error
|
125
|
+
rescue Excon::Errors::Conflict => error
|
126
|
+
raise Conflict.slurp error
|
127
|
+
rescue Excon::Errors::HTTPStatusError => error
|
128
|
+
raise ServiceError.slurp error
|
128
129
|
end
|
129
|
-
response
|
130
130
|
end
|
131
131
|
|
132
132
|
def array_to_query_string(arr)
|
133
|
-
|
133
|
+
return "" unless arr
|
134
|
+
query_array = arr.collect do | k, v |
|
135
|
+
val_str = v.is_a?(Array) ? v.join(",") : v.to_s
|
136
|
+
"#{k}=#{val_str}"
|
137
|
+
end
|
138
|
+
|
139
|
+
query_array.join('&')
|
134
140
|
end
|
135
141
|
|
136
142
|
def validate_path_fragment(name, fragment)
|
@@ -158,15 +164,13 @@ module Fog
|
|
158
164
|
@auth_token = credentials['X-Auth-Token']
|
159
165
|
end
|
160
166
|
|
161
|
-
def authenticate
|
162
|
-
|
167
|
+
def authenticate(options={})
|
168
|
+
super({
|
163
169
|
:rackspace_api_key => @rackspace_api_key,
|
164
170
|
:rackspace_username => @rackspace_username,
|
165
171
|
:rackspace_auth_url => @rackspace_auth_url,
|
166
172
|
:connection_options => @connection_options
|
167
|
-
}
|
168
|
-
|
169
|
-
super(options)
|
173
|
+
})
|
170
174
|
end
|
171
175
|
end
|
172
176
|
end
|