fog 1.12.1 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. data/.travis.yml +1 -1
  2. data/Gemfile +5 -0
  3. data/Rakefile +14 -4
  4. data/bin/fog +22 -0
  5. data/changelog.txt +262 -0
  6. data/fog.gemspec +8 -4
  7. data/lib/fog/aws.rb +11 -0
  8. data/lib/fog/aws/auto_scaling.rb +15 -18
  9. data/lib/fog/aws/beanstalk.rb +8 -10
  10. data/lib/fog/aws/cloud_formation.rb +9 -12
  11. data/lib/fog/aws/compute.rb +8 -10
  12. data/lib/fog/aws/credential_fetcher.rb +6 -6
  13. data/lib/fog/aws/elasticache.rb +13 -17
  14. data/lib/fog/aws/elb.rb +29 -31
  15. data/lib/fog/aws/iam.rb +10 -13
  16. data/lib/fog/aws/models/auto_scaling/group.rb +6 -3
  17. data/lib/fog/aws/models/compute/spot_request.rb +1 -11
  18. data/lib/fog/aws/models/rds/log_file.rb +26 -0
  19. data/lib/fog/aws/models/rds/log_files.rb +50 -0
  20. data/lib/fog/aws/models/rds/server.rb +3 -1
  21. data/lib/fog/aws/models/rds/snapshot.rb +1 -0
  22. data/lib/fog/aws/models/rds/snapshots.rb +20 -13
  23. data/lib/fog/aws/parsers/rds/db_parser.rb +1 -1
  24. data/lib/fog/aws/parsers/rds/describe_db_log_files.rb +44 -0
  25. data/lib/fog/aws/parsers/rds/download_db_logfile_portion.rb +26 -0
  26. data/lib/fog/aws/parsers/ses/verify_domain_identity.rb +26 -0
  27. data/lib/fog/aws/parsers/storage/complete_multipart_upload.rb +1 -1
  28. data/lib/fog/aws/parsers/sts/assume_role.rb +30 -0
  29. data/lib/fog/aws/rds.rb +27 -14
  30. data/lib/fog/aws/requests/auto_scaling/create_auto_scaling_group.rb +8 -0
  31. data/lib/fog/aws/requests/auto_scaling/update_auto_scaling_group.rb +8 -1
  32. data/lib/fog/aws/requests/compute/create_volume.rb +3 -3
  33. data/lib/fog/aws/requests/rds/create_db_instance.rb +3 -1
  34. data/lib/fog/aws/requests/rds/describe_db_log_files.rb +67 -0
  35. data/lib/fog/aws/requests/rds/download_db_logfile_portion.rb +63 -0
  36. data/lib/fog/aws/requests/ses/send_raw_email.rb +1 -1
  37. data/lib/fog/aws/requests/ses/verify_domain_identity.rb +30 -0
  38. data/lib/fog/aws/requests/storage/complete_multipart_upload.rb +6 -2
  39. data/lib/fog/aws/requests/storage/get_object.rb +1 -1
  40. data/lib/fog/aws/requests/sts/assume_role.rb +46 -0
  41. data/lib/fog/aws/ses.rb +26 -9
  42. data/lib/fog/aws/storage.rb +2 -1
  43. data/lib/fog/aws/sts.rb +31 -21
  44. data/lib/fog/bin.rb +0 -1
  45. data/lib/fog/bin/openstack.rb +5 -0
  46. data/lib/fog/brightbox/compute.rb +20 -212
  47. data/lib/fog/brightbox/compute/shared.rb +232 -0
  48. data/lib/fog/brightbox/models/compute/collaboration.rb +43 -0
  49. data/lib/fog/brightbox/models/compute/collaborations.rb +23 -0
  50. data/lib/fog/brightbox/models/compute/user_collaboration.rb +29 -0
  51. data/lib/fog/brightbox/models/compute/user_collaborations.rb +23 -0
  52. data/lib/fog/brightbox/requests/compute/accept_user_collaboration.rb +21 -0
  53. data/lib/fog/brightbox/requests/compute/create_collaboration.rb +23 -0
  54. data/lib/fog/brightbox/requests/compute/delete_collaboration.rb +28 -0
  55. data/lib/fog/brightbox/requests/compute/delete_user_collaboration.rb +28 -0
  56. data/lib/fog/brightbox/requests/compute/destroy_user_collaboration.rb +21 -0
  57. data/lib/fog/brightbox/requests/compute/get_collaboration.rb +21 -0
  58. data/lib/fog/brightbox/requests/compute/get_user_collaboration.rb +21 -0
  59. data/lib/fog/brightbox/requests/compute/list_collaborations.rb +19 -0
  60. data/lib/fog/brightbox/requests/compute/list_user_collaborations.rb +19 -0
  61. data/lib/fog/brightbox/requests/compute/reject_user_collaboration.rb +21 -0
  62. data/lib/fog/brightbox/requests/compute/resend_collaboration.rb +21 -0
  63. data/lib/fog/cloudsigma/docs/getting_started.md +59 -0
  64. data/lib/fog/core.rb +7 -2
  65. data/lib/fog/core/connection.rb +62 -29
  66. data/lib/fog/core/deprecated/connection.rb +24 -0
  67. data/lib/fog/core/parser.rb +1 -1
  68. data/lib/fog/digitalocean/examples/getting_started.md +1 -1
  69. data/lib/fog/digitalocean/models/compute/server.rb +2 -2
  70. data/lib/fog/google/compute.rb +31 -7
  71. data/lib/fog/google/models/compute/disk.rb +80 -0
  72. data/lib/fog/google/models/compute/disks.rb +28 -0
  73. data/lib/fog/google/models/compute/image.rb +36 -0
  74. data/lib/fog/google/models/compute/server.rb +46 -33
  75. data/lib/fog/google/models/compute/servers.rb +15 -8
  76. data/lib/fog/google/requests/compute/delete_server.rb +5 -2
  77. data/lib/fog/google/requests/compute/get_disk.rb +3 -0
  78. data/lib/fog/google/requests/compute/get_server.rb +7 -1
  79. data/lib/fog/google/requests/compute/insert_disk.rb +8 -2
  80. data/lib/fog/google/requests/compute/insert_server.rb +51 -22
  81. data/lib/fog/google/requests/compute/list_machine_types.rb +3 -2
  82. data/lib/fog/google/requests/storage/get_object.rb +1 -1
  83. data/lib/fog/hp/requests/storage/get_object.rb +1 -1
  84. data/lib/fog/hp/storage.rb +26 -9
  85. data/lib/fog/ibm/requests/compute/create_instance.rb +20 -15
  86. data/lib/fog/internet_archive/requests/storage/get_object.rb +1 -1
  87. data/lib/fog/{core/json.rb → json.rb} +13 -2
  88. data/lib/fog/metering.rb +25 -0
  89. data/lib/fog/openstack.rb +1 -0
  90. data/lib/fog/openstack/metering.rb +215 -0
  91. data/lib/fog/openstack/models/compute/flavors.rb +2 -2
  92. data/lib/fog/openstack/models/compute/metadata.rb +1 -1
  93. data/lib/fog/openstack/models/compute/server.rb +5 -2
  94. data/lib/fog/openstack/models/image/images.rb +1 -1
  95. data/lib/fog/openstack/models/metering/meter.rb +0 -0
  96. data/lib/fog/openstack/models/metering/meters.rb +0 -0
  97. data/lib/fog/openstack/models/metering/resource.rb +24 -0
  98. data/lib/fog/openstack/models/metering/resources.rb +25 -0
  99. data/lib/fog/openstack/models/volume/volume.rb +3 -1
  100. data/lib/fog/openstack/models/volume/volumes.rb +2 -1
  101. data/lib/fog/openstack/network.rb +1 -1
  102. data/lib/fog/openstack/requests/compute/create_flavor.rb +1 -1
  103. data/lib/fog/openstack/requests/compute/create_server.rb +19 -1
  104. data/lib/fog/openstack/requests/compute/detach_volume.rb +2 -1
  105. data/lib/fog/openstack/requests/compute/list_flavors_detail.rb +4 -3
  106. data/lib/fog/openstack/requests/compute/list_security_groups.rb +1 -1
  107. data/lib/fog/openstack/requests/identity/create_tenant.rb +2 -2
  108. data/lib/fog/openstack/requests/metering/get_resource.rb +32 -0
  109. data/lib/fog/openstack/requests/metering/get_samples.rb +55 -0
  110. data/lib/fog/openstack/requests/metering/get_statistics.rb +56 -0
  111. data/lib/fog/openstack/requests/metering/list_meters.rb +50 -0
  112. data/lib/fog/openstack/requests/metering/list_resources.rb +32 -0
  113. data/lib/fog/openstack/requests/volume/create_volume.rb +4 -2
  114. data/lib/fog/rackspace.rb +16 -1
  115. data/lib/fog/rackspace/block_storage.rb +13 -28
  116. data/lib/fog/rackspace/cdn.rb +10 -24
  117. data/lib/fog/rackspace/compute.rb +17 -45
  118. data/lib/fog/rackspace/compute_v2.rb +13 -33
  119. data/lib/fog/rackspace/databases.rb +13 -29
  120. data/lib/fog/rackspace/dns.rb +27 -23
  121. data/lib/fog/rackspace/identity.rb +10 -26
  122. data/lib/fog/rackspace/load_balancers.rb +13 -29
  123. data/lib/fog/rackspace/mock_data.rb +3 -3
  124. data/lib/fog/rackspace/models/compute/server.rb +1 -1
  125. data/lib/fog/rackspace/models/dns/zones.rb +34 -21
  126. data/lib/fog/rackspace/models/identity/users.rb +2 -2
  127. data/lib/fog/rackspace/models/storage/file.rb +1 -0
  128. data/lib/fog/rackspace/requests/dns/list_domains.rb +2 -2
  129. data/lib/fog/rackspace/requests/storage/delete_multiple_objects.rb +75 -0
  130. data/lib/fog/rackspace/requests/storage/delete_static_large_object.rb +50 -0
  131. data/lib/fog/rackspace/requests/storage/get_object.rb +3 -1
  132. data/lib/fog/rackspace/requests/storage/put_dynamic_obj_manifest.rb +44 -0
  133. data/lib/fog/rackspace/requests/storage/put_object_manifest.rb +3 -30
  134. data/lib/fog/rackspace/requests/storage/put_static_obj_manifest.rb +60 -0
  135. data/lib/fog/rackspace/service.rb +43 -1
  136. data/lib/fog/rackspace/storage.rb +25 -43
  137. data/lib/fog/riakcs/provisioning.rb +2 -1
  138. data/lib/fog/riakcs/usage.rb +2 -1
  139. data/lib/fog/vcloud/requests/compute/configure_vm_cpus.rb +1 -1
  140. data/lib/fog/vcloud/requests/compute/configure_vm_memory.rb +1 -1
  141. data/lib/fog/version.rb +1 -1
  142. data/lib/fog/vsphere/requests/compute/get_folder.rb +1 -1
  143. data/lib/fog/xenserver/compute.rb +2 -0
  144. data/lib/fog/xenserver/models/compute/server.rb +9 -7
  145. data/lib/fog/xenserver/requests/compute/snapshot_revert.rb +22 -0
  146. data/lib/fog/xenserver/requests/compute/snapshot_server.rb +22 -0
  147. data/lib/fog/xml.rb +21 -0
  148. data/lib/fog/xml/sax_parser_connection.rb +43 -0
  149. data/lib/tasks/changelog_task.rb +1 -0
  150. data/tests/aws/models/auto_scaling/groups_test.rb +22 -0
  151. data/tests/aws/requests/compute/volume_tests.rb +3 -3
  152. data/tests/aws/requests/rds/helper.rb +14 -0
  153. data/tests/aws/requests/rds/log_file_tests.rb +19 -0
  154. data/tests/aws/requests/ses/verified_domain_identity_tests.rb +16 -0
  155. data/tests/aws/requests/sts/assume_role_tests.rb +19 -0
  156. data/tests/brightbox/requests/compute/collaboration_tests.rb +41 -0
  157. data/tests/brightbox/requests/compute/helper.rb +46 -2
  158. data/tests/brightbox/requests/compute/user_collaboration_tests.rb +67 -0
  159. data/tests/core/connection_tests.rb +26 -0
  160. data/tests/helper.rb +13 -0
  161. data/tests/openstack/requests/metering/meter_tests.rb +52 -0
  162. data/tests/openstack/requests/metering/resource_tests.rb +19 -0
  163. data/tests/openvz/helper.rb +14 -8
  164. data/tests/rackspace/block_storage_tests.rb +9 -0
  165. data/tests/rackspace/compute_tests.rb +9 -0
  166. data/tests/rackspace/compute_v2_tests.rb +9 -0
  167. data/tests/rackspace/databases_tests.rb +9 -0
  168. data/tests/rackspace/dns_tests.rb +20 -0
  169. data/tests/rackspace/helper.rb +12 -1
  170. data/tests/rackspace/identity_tests.rb +25 -0
  171. data/tests/rackspace/load_balancer_tests.rb +10 -0
  172. data/tests/rackspace/models/block_storage/volume_tests.rb +2 -2
  173. data/tests/rackspace/models/compute_v2/metadata_tests.rb +2 -2
  174. data/tests/rackspace/models/compute_v2/server_tests.rb +22 -21
  175. data/tests/rackspace/models/dns/zones_tests.rb +19 -5
  176. data/tests/rackspace/models/storage/file_tests.rb +22 -6
  177. data/tests/rackspace/rackspace_tests.rb +35 -0
  178. data/tests/rackspace/requests/block_storage/snapshot_tests.rb +2 -3
  179. data/tests/rackspace/requests/block_storage/volume_type_tests.rb +4 -11
  180. data/tests/rackspace/requests/compute_v2/address_tests.rb +1 -1
  181. data/tests/rackspace/requests/compute_v2/attachment_tests.rb +8 -9
  182. data/tests/rackspace/requests/compute_v2/flavor_tests.rb +1 -1
  183. data/tests/rackspace/requests/compute_v2/metadata_tests.rb +4 -4
  184. data/tests/rackspace/requests/databases/database_tests.rb +23 -20
  185. data/tests/rackspace/requests/databases/user_tests.rb +6 -6
  186. data/tests/rackspace/requests/identity/user_tests.rb +4 -1
  187. data/tests/rackspace/requests/load_balancers/usage_tests.rb +4 -2
  188. data/tests/rackspace/requests/storage/large_object_tests.rb +303 -59
  189. data/tests/rackspace/requests/storage/object_tests.rb +73 -18
  190. data/tests/rackspace/service_tests.rb +83 -0
  191. data/tests/rackspace/storage_tests.rb +9 -0
  192. data/tests/xenserver/models/compute/server_tests.rb +11 -1
  193. metadata +89 -19
  194. data/tests/core/user_agent_tests.rb +0 -6
@@ -3,38 +3,11 @@ module Fog
3
3
  class Rackspace
4
4
  class Real
5
5
 
6
- # Create a new manifest object
6
+ # Create a new dynamic large object manifest
7
7
  #
8
- # Creates an object with a +X-Object-Manifest+ header that specifies the common prefix ("<container>/<prefix>")
9
- # for all uploaded segments. Retrieving the manifest object streams all segments matching this prefix.
10
- # Segments must sort in the order they should be concatenated. Note that any future objects stored in the container
11
- # along with the segments that match the prefix will be included when retrieving the manifest object.
12
- #
13
- # All segments must be stored in the same container, but may be in a different container than the manifest object.
14
- # The default +X-Object-Manifest+ header is set to "+container+/+object+", but may be overridden in +options+
15
- # to specify the prefix and/or the container where segments were stored.
16
- # If overridden, names should be CGI escaped (excluding spaces) if needed (see {Fog::Rackspace.escape}).
17
- #
18
- # @param container [String] Name for container where +object+ will be stored. Should be < 256 bytes and must not contain '/'
19
- # @param object [String] Name for manifest object.
20
- # @param options [Hash] Config headers for +object+.
21
- # @option options [String] 'X-Object-Manifest' ("container/object") "<container>/<prefix>" for segment objects.
22
- #
23
- # @raise [Fog::Storage::Rackspace::NotFound] HTTP 404
24
- # @raise [Fog::Storage::Rackspace::BadRequest] HTTP 400
25
- # @raise [Fog::Storage::Rackspace::InternalServerError] HTTP 500
26
- # @raise [Fog::Storage::Rackspace::ServiceError]
27
- #
28
- # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/Large_Object_Creation-d1e2019.html
8
+ # This is an alias for {#put_dynamic_obj_manifest} for backward compatibility.
29
9
  def put_object_manifest(container, object, options = {})
30
- path = "#{Fog::Rackspace.escape(container)}/#{Fog::Rackspace.escape(object)}"
31
- headers = {'X-Object-Manifest' => path}.merge(options)
32
- request(
33
- :expects => 201,
34
- :headers => headers,
35
- :method => 'PUT',
36
- :path => path
37
- )
10
+ put_dynamic_obj_manifest(container, object, options)
38
11
  end
39
12
 
40
13
  end
@@ -0,0 +1,60 @@
1
+ module Fog
2
+ module Storage
3
+ class Rackspace
4
+ class Real
5
+
6
+ # Create a new static large object manifest.
7
+ #
8
+ # A static large object is similar to a dynamic large object. Whereas a GET for a dynamic large object manifest
9
+ # will stream segments based on the manifest's +X-Object-Manifest+ object name prefix, a static large object
10
+ # manifest streams segments which are defined by the user within the manifest. Information about each segment is
11
+ # provided in +segments+ as an Array of Hash objects, ordered in the sequence which the segments should be streamed.
12
+ #
13
+ # When the SLO manifest is received, each segment's +etag+ and +size_bytes+ will be verified.
14
+ # The +etag+ for each segment is returned in the response to {#put_object}, but may also be calculated.
15
+ # e.g. +Digest::MD5.hexdigest(segment_data)+
16
+ #
17
+ # The maximum number of segments for a static large object is 1000, and all segments (except the last) must be
18
+ # at least 1 MiB in size. Unlike a dynamic large object, segments are not required to be in the same container.
19
+ #
20
+ # @example
21
+ # segments = [
22
+ # { :path => 'segments_container/first_segment',
23
+ # :etag => 'md5 for first_segment',
24
+ # :size_bytes => 'byte size of first_segment' },
25
+ # { :path => 'segments_container/second_segment',
26
+ # :etag => 'md5 for second_segment',
27
+ # :size_bytes => 'byte size of second_segment' }
28
+ # ]
29
+ # put_static_obj_manifest('my_container', 'my_large_object', segments)
30
+ #
31
+ # @param container [String] Name for container where +object+ will be stored.
32
+ # Should be < 256 bytes and must not contain '/'
33
+ # @param object [String] Name for manifest object.
34
+ # @param segments [Array<Hash>] Segment data for the object.
35
+ # @param options [Hash] Config headers for +object+.
36
+ #
37
+ # @raise [Fog::Storage::Rackspace::NotFound] HTTP 404
38
+ # @raise [Fog::Storage::Rackspace::BadRequest] HTTP 400
39
+ # @raise [Fog::Storage::Rackspace::InternalServerError] HTTP 500
40
+ # @raise [Fog::Storage::Rackspace::ServiceError]
41
+ # @raise [Excon::Errors::Unauthorized] HTTP 401
42
+ #
43
+ # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/Uploading_the_Manifext-d1e2227.html
44
+ def put_static_obj_manifest(container, object, segments, options = {})
45
+ request(
46
+ :expects => 201,
47
+ :method => 'PUT',
48
+ :headers => options,
49
+ :body => Fog::JSON.encode(segments),
50
+ :path => "#{Fog::Rackspace.escape(container)}/#{Fog::Rackspace.escape(object)}",
51
+ :query => { 'multipart-manifest' => 'put' }
52
+ )
53
+ end
54
+
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+
@@ -26,12 +26,54 @@ module Fog
26
26
  @uri = URI.parse url
27
27
  end
28
28
 
29
- def authenticate(options)
29
+ def authenticate(options={})
30
30
  self.send authentication_method, options
31
31
  end
32
32
 
33
+ def request(params, parse_json = true, &block)
34
+ first_attempt = true
35
+ begin
36
+ response = @connection.request(request_params(params), &block)
37
+ rescue Excon::Errors::Unauthorized => error
38
+ raise error unless first_attempt
39
+ first_attempt = false
40
+ authenticate
41
+ retry
42
+ end
43
+
44
+ process_response(response) if parse_json
45
+ response
46
+ end
47
+
33
48
  private
34
49
 
50
+ def process_response(response)
51
+ if response && response.body && response.body.is_a?(String) && Fog::Rackspace.json_response?(response)
52
+ begin
53
+ response.body = Fog::JSON.decode(response.body)
54
+ rescue MultiJson::DecodeError => e
55
+ Fog::Logger.warning("Error Parsing response json - #{e}")
56
+ response.body = {}
57
+ end
58
+ end
59
+ end
60
+
61
+ def headers(options={})
62
+ h = {
63
+ 'Content-Type' => 'application/json',
64
+ 'Accept' => 'application/json',
65
+ 'X-Auth-Token' => auth_token
66
+ }.merge(options[:headers] || {})
67
+ end
68
+
69
+ def request_params(params)
70
+ params.merge({
71
+ :headers => headers(params),
72
+ :host => endpoint_uri.host,
73
+ :path => "#{endpoint_uri.path}/#{params[:path]}"
74
+ })
75
+ end
76
+
35
77
  def authentication_method
36
78
  if v2_authentication?
37
79
  :authenticate_v2
@@ -25,6 +25,8 @@ module Fog
25
25
  request :copy_object
26
26
  request :delete_container
27
27
  request :delete_object
28
+ request :delete_static_large_object
29
+ request :delete_multiple_objects
28
30
  request :get_container
29
31
  request :get_containers
30
32
  request :get_object
@@ -35,6 +37,8 @@ module Fog
35
37
  request :put_container
36
38
  request :put_object
37
39
  request :put_object_manifest
40
+ request :put_dynamic_obj_manifest
41
+ request :put_static_obj_manifest
38
42
  request :post_set_meta_temp_url_key
39
43
 
40
44
  module Utils
@@ -54,7 +58,7 @@ module Fog
54
58
  end
55
59
  end
56
60
 
57
- end
61
+ end
58
62
 
59
63
  class Mock < Fog::Rackspace::Service
60
64
  include Utils
@@ -107,7 +111,7 @@ module Fog
107
111
  @rackspace_servicenet = options[:rackspace_servicenet]
108
112
  @rackspace_auth_token = options[:rackspace_auth_token]
109
113
  @rackspace_storage_url = options[:rackspace_storage_url]
110
- @rackspace_cdn_url = options[:rackspace_cdn_url]
114
+ @rackspace_cdn_url = options[:rackspace_cdn_url]
111
115
  @rackspace_region = options[:rackspace_region] || :dfw
112
116
  @rackspace_temp_url_key = options[:rackspace_temp_url_key]
113
117
  @rackspace_must_reauthenticate = false
@@ -117,8 +121,8 @@ module Fog
117
121
  @persistent = options[:persistent] || false
118
122
  Excon.defaults[:ssl_verify_peer] = false if service_net?
119
123
  @connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
120
- end
121
-
124
+ end
125
+
122
126
  # Return Account Details
123
127
  # @return [Fog::Storage::Rackspace::Account] account details object
124
128
  def account
@@ -139,43 +143,21 @@ module Fog
139
143
  end
140
144
 
141
145
  def request(params, parse_json = true, &block)
142
- begin
143
- response = @connection.request(params.merge({
144
- :headers => {
145
- 'Content-Type' => 'application/json',
146
- 'Accept' => 'application/json',
147
- 'X-Auth-Token' => auth_token
148
- }.merge!(params[:headers] || {}),
149
- :host => endpoint_uri.host,
150
- :path => "#{endpoint_uri.path}/#{params[:path]}",
151
- }), &block)
152
- rescue Excon::Errors::Unauthorized => error
153
- if error.response.body != 'Bad username or password' # token expiration
154
- @rackspace_must_reauthenticate = true
155
- authenticate
156
- retry
157
- else # bad credentials
158
- raise error
159
- end
160
- rescue Excon::Errors::NotFound => error
161
- raise NotFound.slurp(error, region)
162
- rescue Excon::Errors::BadRequest => error
163
- raise BadRequest.slurp error
164
- rescue Excon::Errors::InternalServerError => error
165
- raise InternalServerError.slurp error
166
- rescue Excon::Errors::HTTPStatusError => error
167
- raise ServiceError.slurp error
168
- end
169
- if !response.body.empty? && parse_json && response.headers['Content-Type'] =~ %r{application/json}
170
- response.body = Fog::JSON.decode(response.body)
171
- end
172
- response
146
+ super(params, parse_json, &block)
147
+ rescue Excon::Errors::NotFound => error
148
+ raise NotFound.slurp(error, region)
149
+ rescue Excon::Errors::BadRequest => error
150
+ raise BadRequest.slurp error
151
+ rescue Excon::Errors::InternalServerError => error
152
+ raise InternalServerError.slurp error
153
+ rescue Excon::Errors::HTTPStatusError => error
154
+ raise ServiceError.slurp error
173
155
  end
174
156
 
175
157
  def service_net?
176
158
  @rackspace_servicenet == true
177
- end
178
-
159
+ end
160
+
179
161
  def authenticate
180
162
  if @rackspace_must_reauthenticate || @rackspace_auth_token.nil?
181
163
  options = {
@@ -183,14 +165,14 @@ module Fog
183
165
  :rackspace_username => @rackspace_username,
184
166
  :rackspace_auth_url => @rackspace_auth_url,
185
167
  :connection_options => @connection_options
186
- }
168
+ }
187
169
  super(options)
188
170
  else
189
171
  @auth_token = @rackspace_auth_token
190
172
  @uri = URI.parse(@rackspace_storage_url)
191
173
  end
192
174
  end
193
-
175
+
194
176
  def service_name
195
177
  :cloudFiles
196
178
  end
@@ -206,15 +188,15 @@ module Fog
206
188
  @uri.host = "snet-#{@uri.host}" if service_net?
207
189
  @uri
208
190
  end
209
-
210
- private
211
-
191
+
192
+ private
193
+
212
194
  def authenticate_v1(options)
213
195
  credentials = Fog::Rackspace.authenticate(options, @connection_options)
214
196
  endpoint_uri credentials['X-Storage-Url']
215
197
  @auth_token = credentials['X-Auth-Token']
216
198
  end
217
-
199
+
218
200
  end
219
201
  end
220
202
  end
@@ -64,7 +64,8 @@ module Fog
64
64
  :aws_secret_access_key => @riakcs_secret_access_key,
65
65
  :host => @host,
66
66
  :port => @port,
67
- :scheme => @scheme
67
+ :scheme => @scheme,
68
+ :connection_options => @connection_options
68
69
  )
69
70
  end
70
71
 
@@ -56,7 +56,8 @@ module Fog
56
56
  :aws_secret_access_key => @riakcs_secret_access_key,
57
57
  :host => @host,
58
58
  :port => @port,
59
- :scheme => @scheme
59
+ :scheme => @scheme,
60
+ :connection_options => @connection_options
60
61
  )
61
62
  end
62
63
  end
@@ -24,7 +24,7 @@ EOF
24
24
  request(
25
25
  :body => body,
26
26
  :expects => 202,
27
- :headers => {'Content-Type' => vm_data[:"vcloud_type"] },
27
+ :headers => { 'Content-Type' => vm_data[:"vcloud_type"] || 'application/vnd.vmware.vcloud.rasdItem+xml' },
28
28
  :method => 'PUT',
29
29
  :uri => "#{edit_uri}",
30
30
  :parse => true
@@ -25,7 +25,7 @@ EOF
25
25
  request(
26
26
  :body => body,
27
27
  :expects => 202,
28
- :headers => {'Content-Type' => vm_data[:"vcloud_type"] },
28
+ :headers => { 'Content-Type' => vm_data[:"vcloud_type"] || 'application/vnd.vmware.vcloud.rasdItem+xml' },
29
29
  :method => 'PUT',
30
30
  :uri => edit_uri,
31
31
  :parse => true
@@ -1,3 +1,3 @@
1
1
  module Fog
2
- VERSION = '1.12.1'
2
+ VERSION = '1.13.0'
3
3
  end
@@ -31,7 +31,7 @@ module Fog
31
31
  dc_root_folder = dc.vmFolder
32
32
  # Filter the root path for this datacenter not to be used."
33
33
  dc_root_folder_path=dc_root_folder.path.map { | id, name | name }.join("/")
34
- paths = path.sub(/^\/?#{Regex.quote(dc_root_folder_path)}\/?/, '').split('/')
34
+ paths = path.sub(/^\/?#{Regexp.quote(dc_root_folder_path)}\/?/, '').split('/')
35
35
 
36
36
  return dc_root_folder if paths.empty?
37
37
  # Walk the tree resetting the folder pointer as we go
@@ -74,6 +74,8 @@ module Fog
74
74
  request :destroy_network
75
75
  request :create_vlan
76
76
  request :destroy_vlan
77
+ request :snapshot_server
78
+ request :snapshot_revert
77
79
 
78
80
  class Real
79
81
 
@@ -50,6 +50,7 @@ module Fog
50
50
  attribute :hvm_boot_policy, :aliases => :HVM_boot_policy
51
51
  attribute :hvm_boot_params, :aliases => :HVM_boot_params
52
52
  attribute :pci_bus, :aliases => :PCI_bus
53
+ attribute :snapshots
53
54
 
54
55
  def initialize(attributes={})
55
56
  super
@@ -198,14 +199,15 @@ module Fog
198
199
  service.provision_server reference
199
200
  end
200
201
 
201
- # def snapshot
202
- # requires :reference, :name_label
203
- # data = service.snapshot_server(@reference, @name_label)
204
- # merge_attributes(data.body)
205
- # true
206
- # end
202
+ def snapshot(name)
203
+ service.snapshot_server(reference, name)
204
+ end
205
+
206
+ def revert(snapshot_ref)
207
+ service.snapshot_revert(snapshot_ref)
208
+ end
207
209
  end
208
210
 
209
211
  end
210
212
  end
211
- end
213
+ end
@@ -0,0 +1,22 @@
1
+ module Fog
2
+ module Compute
3
+ class XenServer
4
+
5
+ class Real
6
+
7
+ def snapshot_revert( snapshot_ref, extra_args = {})
8
+ @connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.revert'}, snapshot_ref)
9
+ end
10
+
11
+ end
12
+
13
+ class Mock
14
+
15
+ def snapshot_revert()
16
+ Fog::Mock.not_implemented
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ module Fog
2
+ module Compute
3
+ class XenServer
4
+
5
+ class Real
6
+
7
+ def snapshot_server( vm_ref , name, extra_args = {})
8
+ @connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.snapshot'}, vm_ref, name)
9
+ end
10
+
11
+ end
12
+
13
+ class Mock
14
+
15
+ def snapshot_server()
16
+ Fog::Mock.not_implemented
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,21 @@
1
+ require "nokogiri"
2
+ require "fog/core/parser"
3
+
4
+ module Fog
5
+
6
+ # @note Extracting XML components out of core is a work in progress.
7
+ #
8
+ # The {XML} module includes functionality that is common between APIs using
9
+ # XML to send and receive data.
10
+ #
11
+ # The intent is to provide common code for provider APIs using XML but not
12
+ # require it for those using JSON.
13
+ #
14
+ # @todo Add +require "fog/xml"+ and/or +include Fog::XML+ to providers using
15
+ # its services
16
+ #
17
+ module XML
18
+ end
19
+ end
20
+
21
+ require "fog/xml/sax_parser_connection"