fog 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. data/Rakefile +106 -17
  2. data/bin/fog +1 -1
  3. data/changelog.txt +17 -0
  4. data/docs/_layouts/default.html +2 -1
  5. data/docs/about/contributing.markdown +1 -1
  6. data/docs/compute/index.markdown +104 -0
  7. data/docs/index.markdown +1 -0
  8. data/docs/storage/index.markdown +17 -0
  9. data/fog.gemspec +3 -2
  10. data/lib/fog.rb +1 -1
  11. data/lib/fog/aws/elb.rb +1 -0
  12. data/lib/fog/aws/iam.rb +1 -0
  13. data/lib/fog/aws/rds.rb +1 -0
  14. data/lib/fog/aws/requests/simpledb/batch_put_attributes.rb +5 -5
  15. data/lib/fog/aws/requests/simpledb/create_domain.rb +1 -1
  16. data/lib/fog/aws/requests/simpledb/delete_attributes.rb +3 -3
  17. data/lib/fog/aws/requests/simpledb/delete_domain.rb +1 -1
  18. data/lib/fog/aws/requests/simpledb/domain_metadata.rb +1 -1
  19. data/lib/fog/aws/requests/simpledb/get_attributes.rb +5 -5
  20. data/lib/fog/aws/requests/simpledb/list_domains.rb +2 -2
  21. data/lib/fog/aws/requests/simpledb/put_attributes.rb +6 -6
  22. data/lib/fog/aws/ses.rb +1 -0
  23. data/lib/fog/aws/simpledb.rb +8 -2
  24. data/lib/fog/bin.rb +2 -2
  25. data/lib/fog/cdn/aws.rb +8 -2
  26. data/lib/fog/cdn/rackspace.rb +8 -2
  27. data/lib/fog/compute/aws.rb +12 -3
  28. data/lib/fog/compute/bluebox.rb +8 -2
  29. data/lib/fog/compute/ecloud.rb +9 -4
  30. data/lib/fog/compute/go_grid.rb +8 -2
  31. data/lib/fog/compute/linode.rb +38 -6
  32. data/lib/fog/compute/models/aws/volumes.rb +4 -4
  33. data/lib/fog/compute/models/bluebox/server.rb +3 -3
  34. data/lib/fog/compute/models/brightbox/server.rb +9 -9
  35. data/lib/fog/compute/models/linode/data_center.rb +12 -0
  36. data/lib/fog/compute/models/linode/data_centers.rb +26 -0
  37. data/lib/fog/compute/models/linode/disk.rb +62 -0
  38. data/lib/fog/compute/models/linode/disks.rb +40 -0
  39. data/lib/fog/compute/models/linode/flavor.rb +23 -0
  40. data/lib/fog/compute/models/linode/flavors.rb +32 -0
  41. data/lib/fog/compute/models/linode/image.rb +14 -0
  42. data/lib/fog/compute/models/linode/images.rb +33 -0
  43. data/lib/fog/compute/models/linode/ip.rb +30 -0
  44. data/lib/fog/compute/models/linode/ips.rb +40 -0
  45. data/lib/fog/compute/models/linode/kernel.rb +12 -0
  46. data/lib/fog/compute/models/linode/kernels.rb +32 -0
  47. data/lib/fog/compute/models/linode/server.rb +88 -0
  48. data/lib/fog/compute/models/linode/servers.rb +32 -0
  49. data/lib/fog/compute/models/linode/stack_script.rb +13 -0
  50. data/lib/fog/compute/models/linode/stack_scripts.rb +32 -0
  51. data/lib/fog/compute/models/rackspace/server.rb +2 -2
  52. data/lib/fog/compute/models/slicehost/server.rb +2 -2
  53. data/lib/fog/compute/models/voxel/server.rb +3 -3
  54. data/lib/fog/compute/new_servers.rb +8 -2
  55. data/lib/fog/compute/rackspace.rb +8 -2
  56. data/lib/fog/compute/requests/aws/allocate_address.rb +4 -2
  57. data/lib/fog/compute/requests/aws/associate_address.rb +4 -2
  58. data/lib/fog/compute/requests/aws/attach_volume.rb +4 -2
  59. data/lib/fog/compute/requests/aws/authorize_security_group_ingress.rb +5 -3
  60. data/lib/fog/compute/requests/aws/create_image.rb +2 -1
  61. data/lib/fog/compute/requests/aws/create_key_pair.rb +4 -2
  62. data/lib/fog/compute/requests/aws/create_security_group.rb +5 -3
  63. data/lib/fog/compute/requests/aws/create_snapshot.rb +6 -4
  64. data/lib/fog/compute/requests/aws/create_tags.rb +7 -5
  65. data/lib/fog/compute/requests/aws/create_volume.rb +4 -2
  66. data/lib/fog/compute/requests/aws/delete_key_pair.rb +3 -1
  67. data/lib/fog/compute/requests/aws/delete_security_group.rb +4 -2
  68. data/lib/fog/compute/requests/aws/delete_snapshot.rb +3 -1
  69. data/lib/fog/compute/requests/aws/delete_tags.rb +5 -3
  70. data/lib/fog/compute/requests/aws/delete_volume.rb +4 -2
  71. data/lib/fog/compute/requests/aws/deregister_image.rb +2 -0
  72. data/lib/fog/compute/requests/aws/describe_addresses.rb +3 -1
  73. data/lib/fog/compute/requests/aws/describe_availability_zones.rb +2 -0
  74. data/lib/fog/compute/requests/aws/describe_images.rb +3 -1
  75. data/lib/fog/compute/requests/aws/describe_instances.rb +12 -10
  76. data/lib/fog/compute/requests/aws/describe_key_pairs.rb +3 -1
  77. data/lib/fog/compute/requests/aws/describe_regions.rb +2 -0
  78. data/lib/fog/compute/requests/aws/describe_reserved_instances.rb +2 -0
  79. data/lib/fog/compute/requests/aws/describe_reserved_instances_offerings.rb +2 -0
  80. data/lib/fog/compute/requests/aws/describe_security_groups.rb +3 -1
  81. data/lib/fog/compute/requests/aws/describe_snapshots.rb +5 -3
  82. data/lib/fog/compute/requests/aws/describe_tags.rb +2 -0
  83. data/lib/fog/compute/requests/aws/describe_volumes.rb +9 -7
  84. data/lib/fog/compute/requests/aws/detach_volume.rb +3 -1
  85. data/lib/fog/compute/requests/aws/disassociate_address.rb +4 -2
  86. data/lib/fog/compute/requests/aws/get_console_output.rb +3 -1
  87. data/lib/fog/compute/requests/aws/get_password_data.rb +15 -1
  88. data/lib/fog/compute/requests/aws/import_key_pair.rb +4 -2
  89. data/lib/fog/compute/requests/aws/modify_image_attributes.rb +4 -0
  90. data/lib/fog/compute/requests/aws/modify_snapshot_attribute.rb +4 -0
  91. data/lib/fog/compute/requests/aws/monitor_instances.rb +3 -1
  92. data/lib/fog/compute/requests/aws/reboot_instances.rb +4 -2
  93. data/lib/fog/compute/requests/aws/register_image.rb +4 -0
  94. data/lib/fog/compute/requests/aws/release_address.rb +3 -1
  95. data/lib/fog/compute/requests/aws/revoke_security_group_ingress.rb +3 -1
  96. data/lib/fog/compute/requests/aws/run_instances.rb +12 -6
  97. data/lib/fog/compute/requests/aws/start_instances.rb +2 -0
  98. data/lib/fog/compute/requests/aws/stop_instances.rb +2 -0
  99. data/lib/fog/compute/requests/aws/terminate_instances.rb +5 -3
  100. data/lib/fog/compute/requests/aws/unmonitor_instances.rb +3 -1
  101. data/lib/fog/compute/requests/go_grid/grid_image_get.rb +1 -1
  102. data/lib/fog/compute/requests/go_grid/grid_image_list.rb +1 -1
  103. data/lib/fog/compute/requests/linode/avail_datacenters.rb +1 -2
  104. data/lib/fog/compute/requests/linode/avail_distributions.rb +1 -2
  105. data/lib/fog/compute/requests/linode/avail_kernels.rb +6 -5
  106. data/lib/fog/compute/requests/linode/avail_linodeplans.rb +9 -3
  107. data/lib/fog/compute/requests/linode/avail_stackscripts.rb +3 -15
  108. data/lib/fog/compute/requests/linode/linode_boot.rb +15 -0
  109. data/lib/fog/compute/requests/linode/linode_config_create.rb +21 -0
  110. data/lib/fog/compute/requests/linode/linode_config_list.rb +18 -0
  111. data/lib/fog/compute/requests/linode/linode_create.rb +3 -4
  112. data/lib/fog/compute/requests/linode/linode_delete.rb +0 -1
  113. data/lib/fog/compute/requests/linode/linode_disk_create.rb +21 -0
  114. data/lib/fog/compute/requests/linode/linode_disk_createfromdistribution.rb +22 -0
  115. data/lib/fog/compute/requests/linode/linode_disk_createfromstackscript.rb +24 -0
  116. data/lib/fog/compute/requests/linode/linode_disk_delete.rb +19 -0
  117. data/lib/fog/compute/requests/linode/linode_disk_list.rb +19 -0
  118. data/lib/fog/compute/requests/linode/linode_ip_addprivate.rb +15 -0
  119. data/lib/fog/compute/requests/linode/linode_ip_list.rb +19 -0
  120. data/lib/fog/compute/requests/linode/linode_list.rb +0 -1
  121. data/lib/fog/compute/requests/linode/linode_reboot.rb +1 -2
  122. data/lib/fog/compute/requests/linode/linode_shutdown.rb +15 -0
  123. data/lib/fog/compute/requests/linode/linode_update.rb +15 -0
  124. data/lib/fog/compute/requests/linode/stackscript_list.rb +31 -0
  125. data/lib/fog/compute/requests/rackspace/confirm_resized_server.rb +3 -3
  126. data/lib/fog/compute/requests/rackspace/create_image.rb +2 -2
  127. data/lib/fog/compute/requests/rackspace/create_server.rb +2 -2
  128. data/lib/fog/compute/requests/rackspace/delete_image.rb +2 -2
  129. data/lib/fog/compute/requests/rackspace/delete_server.rb +2 -2
  130. data/lib/fog/compute/requests/rackspace/list_images_detail.rb +2 -2
  131. data/lib/fog/compute/requests/rackspace/list_servers_detail.rb +2 -2
  132. data/lib/fog/compute/requests/rackspace/resize_server.rb +4 -4
  133. data/lib/fog/compute/requests/rackspace/revert_resized_server.rb +4 -4
  134. data/lib/fog/compute/slicehost.rb +8 -2
  135. data/lib/fog/compute/storm_on_demand.rb +12 -1
  136. data/lib/fog/compute/voxel.rb +8 -2
  137. data/lib/fog/core/mock.rb +14 -1
  138. data/lib/fog/dns/aws.rb +8 -2
  139. data/lib/fog/dns/bluebox.rb +8 -2
  140. data/lib/fog/dns/dnsimple.rb +15 -3
  141. data/lib/fog/dns/linode.rb +8 -2
  142. data/lib/fog/dns/slicehost.rb +8 -2
  143. data/lib/fog/dns/zerigo.rb +8 -2
  144. data/lib/fog/providers/aws.rb +5 -10
  145. data/lib/fog/providers/linode.rb +0 -3
  146. data/lib/fog/storage.rb +6 -4
  147. data/lib/fog/storage/aws.rb +8 -2
  148. data/lib/fog/storage/google.rb +8 -2
  149. data/lib/fog/storage/local.rb +8 -2
  150. data/lib/fog/storage/models/aws/file.rb +0 -1
  151. data/lib/fog/storage/models/google/file.rb +1 -5
  152. data/lib/fog/storage/models/local/file.rb +1 -1
  153. data/lib/fog/storage/models/rackspace/file.rb +1 -5
  154. data/lib/fog/storage/rackspace.rb +8 -2
  155. data/lib/fog/storage/requests/aws/copy_object.rb +2 -2
  156. data/lib/fog/storage/requests/aws/delete_bucket.rb +3 -3
  157. data/lib/fog/storage/requests/aws/delete_object.rb +1 -1
  158. data/lib/fog/storage/requests/aws/get_bucket.rb +1 -1
  159. data/lib/fog/storage/requests/aws/get_bucket_acl.rb +1 -1
  160. data/lib/fog/storage/requests/aws/get_bucket_location.rb +1 -1
  161. data/lib/fog/storage/requests/aws/get_object.rb +1 -1
  162. data/lib/fog/storage/requests/aws/get_object_acl.rb +1 -1
  163. data/lib/fog/storage/requests/aws/get_request_payment.rb +1 -1
  164. data/lib/fog/storage/requests/aws/get_service.rb +1 -1
  165. data/lib/fog/storage/requests/aws/put_bucket.rb +3 -3
  166. data/lib/fog/storage/requests/aws/put_object.rb +3 -3
  167. data/lib/fog/storage/requests/aws/put_request_payment.rb +1 -1
  168. data/lib/fog/storage/requests/google/copy_object.rb +2 -2
  169. data/lib/fog/storage/requests/google/delete_bucket.rb +3 -3
  170. data/lib/fog/storage/requests/google/delete_object.rb +1 -1
  171. data/lib/fog/storage/requests/google/get_bucket.rb +1 -1
  172. data/lib/fog/storage/requests/google/get_bucket_acl.rb +1 -1
  173. data/lib/fog/storage/requests/google/get_object.rb +1 -1
  174. data/lib/fog/storage/requests/google/get_object_acl.rb +1 -1
  175. data/lib/fog/storage/requests/google/get_service.rb +2 -2
  176. data/lib/fog/storage/requests/google/put_bucket.rb +3 -3
  177. data/lib/fog/storage/requests/google/put_object.rb +3 -3
  178. data/lib/fog/terremark/requests/shared/get_network.rb +1 -1
  179. data/lib/fog/terremark/requests/shared/get_organization.rb +1 -1
  180. data/lib/fog/terremark/requests/shared/get_organizations.rb +1 -1
  181. data/lib/fog/terremark/requests/shared/get_public_ips.rb +1 -1
  182. data/lib/fog/terremark/requests/shared/get_vdc.rb +1 -1
  183. data/lib/fog/terremark/shared.rb +4 -0
  184. data/lib/fog/terremark/vcloud.rb +11 -1
  185. data/spec/ecloud/bin_spec.rb +8 -2
  186. data/spec/ecloud/spec_helper.rb +3 -3
  187. data/tests/compute/helper.rb +1 -3
  188. data/tests/compute/models/aws/server_tests.rb +3 -2
  189. data/tests/compute/requests/aws/instance_tests.rb +12 -9
  190. data/tests/compute/requests/aws/key_pair_tests.rb +1 -1
  191. data/tests/compute/requests/aws/volume_tests.rb +2 -2
  192. data/tests/compute/requests/brightbox/helper.rb +3 -0
  193. data/tests/compute/requests/linode/kernel_tests.rb +27 -0
  194. data/tests/compute/requests/linode/linode_tests.rb +62 -4
  195. data/tests/compute/requests/linode/stackscripts_tests.rb +35 -0
  196. data/tests/compute/requests/rackspace/resize_tests.rb +2 -2
  197. data/tests/compute/requests/voxel/server_tests.rb +1 -0
  198. data/tests/core/credential_tests.rb +7 -2
  199. data/tests/core/parser_tests.rb +1 -1
  200. data/tests/helper.rb +1 -1
  201. data/tests/helpers/compute/server_helper.rb +6 -0
  202. data/tests/helpers/formats_helper.rb +2 -0
  203. data/tests/helpers/mock_helper.rb +8 -1
  204. data/tests/helpers/model_helper.rb +1 -3
  205. data/tests/helpers/responds_to_helper.rb +2 -2
  206. data/tests/storage/helper.rb +1 -1
  207. data/tests/storage/models/directories_tests.rb +8 -4
  208. data/tests/storage/models/directory_test.rb +15 -11
  209. data/tests/storage/models/file_tests.rb +6 -6
  210. data/tests/storage/models/files_tests.rb +5 -5
  211. metadata +105 -55
@@ -60,11 +60,7 @@ module Fog
60
60
  options['Content-Type'] = content_type if content_type
61
61
  data = connection.put_object(directory.key, key, body, options)
62
62
  merge_attributes(data.headers)
63
- if body.is_a?(String)
64
- self.content_length = body.size
65
- else
66
- self.content_length = ::File.size(body.path)
67
- end
63
+ self.content_length = Fog::Storage.get_body_size(body)
68
64
  true
69
65
  end
70
66
 
@@ -45,6 +45,10 @@ module Fog
45
45
  end
46
46
  end
47
47
 
48
+ def self.reset
49
+ @data = nil
50
+ end
51
+
48
52
  def initialize(options={})
49
53
  unless options.delete(:provider)
50
54
  location = caller.first
@@ -56,12 +60,14 @@ module Fog
56
60
  require 'mime/types'
57
61
  @rackspace_api_key = options[:rackspace_api_key]
58
62
  @rackspace_username = options[:rackspace_username]
59
- @data = self.class.data[@rackspace_username]
63
+ end
64
+
65
+ def data
66
+ self.class.data[@rackspace_username]
60
67
  end
61
68
 
62
69
  def reset_data
63
70
  self.class.data.delete(@rackspace_username)
64
- @data = self.class.data[@rackspace_username]
65
71
  end
66
72
 
67
73
  end
@@ -47,9 +47,9 @@ module Fog
47
47
 
48
48
  def copy_object(source_bucket_name, source_object_name, target_bucket_name, target_object_name, options = {})
49
49
  response = Excon::Response.new
50
- source_bucket = @data[:buckets][source_bucket_name]
50
+ source_bucket = self.data[:buckets][source_bucket_name]
51
51
  source_object = source_bucket && source_bucket[:objects][source_object_name]
52
- target_bucket = @data[:buckets][target_bucket_name]
52
+ target_bucket = self.data[:buckets][target_bucket_name]
53
53
 
54
54
  if source_object && target_bucket
55
55
  response.status = 200
@@ -30,14 +30,14 @@ module Fog
30
30
 
31
31
  def delete_bucket(bucket_name)
32
32
  response = Excon::Response.new
33
- if @data[:buckets][bucket_name].nil?
33
+ if self.data[:buckets][bucket_name].nil?
34
34
  response.status = 404
35
35
  raise(Excon::Errors.status_error({:expects => 204}, response))
36
- elsif @data[:buckets][bucket_name] && !@data[:buckets][bucket_name][:objects].empty?
36
+ elsif self.data[:buckets][bucket_name] && !self.data[:buckets][bucket_name][:objects].empty?
37
37
  response.status = 409
38
38
  raise(Excon::Errors.status_error({:expects => 204}, response))
39
39
  else
40
- @data[:buckets].delete(bucket_name)
40
+ self.data[:buckets].delete(bucket_name)
41
41
  response.status = 204
42
42
  end
43
43
  response
@@ -33,7 +33,7 @@ module Fog
33
33
 
34
34
  def delete_object(bucket_name, object_name)
35
35
  response = Excon::Response.new
36
- if bucket = @data[:buckets][bucket_name]
36
+ if bucket = self.data[:buckets][bucket_name]
37
37
  response.status = 204
38
38
  bucket[:objects].delete(object_name)
39
39
  else
@@ -67,7 +67,7 @@ module Fog
67
67
  Fog::Mock.not_implemented
68
68
  end
69
69
  response = Excon::Response.new
70
- if bucket = @data[:buckets][bucket_name]
70
+ if bucket = self.data[:buckets][bucket_name]
71
71
  contents = bucket[:objects].values.sort {|x,y| x['Key'] <=> y['Key']}.reject do |object|
72
72
  (options['prefix'] && object['Key'][0...options['prefix'].length] != options['prefix']) ||
73
73
  (options['marker'] && object['Key'] <= options['marker'])
@@ -50,7 +50,7 @@ module Fog
50
50
 
51
51
  def get_bucket_acl(bucket_name)
52
52
  response = Excon::Response.new
53
- if acl = @data[:acls][:bucket][bucket_name]
53
+ if acl = self.data[:acls][:bucket][bucket_name]
54
54
  response.status = 200
55
55
  response.body = acl
56
56
  else
@@ -36,7 +36,7 @@ module Fog
36
36
 
37
37
  def get_bucket_location(bucket_name)
38
38
  response = Excon::Response.new
39
- if bucket = @data[:buckets][bucket_name]
39
+ if bucket = self.data[:buckets][bucket_name]
40
40
  response.status = 200
41
41
  response.body = {'LocationConstraint' => bucket['LocationConstraint'] }
42
42
  else
@@ -65,7 +65,7 @@ module Fog
65
65
  raise ArgumentError.new('object_name is required')
66
66
  end
67
67
  response = Excon::Response.new
68
- if (bucket = @data[:buckets][bucket_name]) && (object = bucket[:objects][object_name])
68
+ if (bucket = self.data[:buckets][bucket_name]) && (object = bucket[:objects][object_name])
69
69
  if options['If-Match'] && options['If-Match'] != object['ETag']
70
70
  response.status = 412
71
71
  elsif options['If-Modified-Since'] && options['If-Modified-Since'] > Time.parse(object['Last-Modified'])
@@ -61,7 +61,7 @@ module Fog
61
61
 
62
62
  def get_object_acl(bucket_name, object_name)
63
63
  response = Excon::Response.new
64
- if acl = @data[:acls][:object][bucket_name] && @data[:acls][:object][bucket_name][object_name]
64
+ if acl = self.data[:acls][:object][bucket_name] && self.data[:acls][:object][bucket_name][object_name]
65
65
  response.status = 200
66
66
  response.body = acl
67
67
  else
@@ -36,7 +36,7 @@ module Fog
36
36
 
37
37
  def get_request_payment(bucket_name)
38
38
  response = Excon::Response.new
39
- if bucket = @data[:buckets][bucket_name]
39
+ if bucket = self.data[:buckets][bucket_name]
40
40
  response.status = 200
41
41
  response.body = { 'Payer' => bucket['Payer'] }
42
42
  else
@@ -39,7 +39,7 @@ module Fog
39
39
  def get_service
40
40
  response = Excon::Response.new
41
41
  response.headers['Status'] = 200
42
- buckets = @data[:buckets].values.map do |bucket|
42
+ buckets = self.data[:buckets].values.map do |bucket|
43
43
  bucket.reject do |key, value|
44
44
  !['CreationDate', 'Name'].include?(key)
45
45
  end
@@ -48,7 +48,7 @@ DATA
48
48
  if !['private', 'public-read', 'public-read-write', 'authenticated-read'].include?(acl)
49
49
  raise Excon::Errors::BadRequest.new('invalid x-amz-acl')
50
50
  else
51
- @data[:acls][:bucket][bucket_name] = self.class.acls(acl)
51
+ self.data[:acls][:bucket][bucket_name] = self.class.acls(acl)
52
52
  end
53
53
 
54
54
  response = Excon::Response.new
@@ -65,8 +65,8 @@ DATA
65
65
  else
66
66
  bucket['LocationConstraint'] = nil
67
67
  end
68
- unless @data[:buckets][bucket_name]
69
- @data[:buckets][bucket_name] = bucket
68
+ unless self.data[:buckets][bucket_name]
69
+ self.data[:buckets][bucket_name] = bucket
70
70
  end
71
71
  response
72
72
  end
@@ -52,8 +52,8 @@ module Fog
52
52
  if !['private', 'public-read', 'public-read-write', 'authenticated-read'].include?(acl)
53
53
  raise Excon::Errors::BadRequest.new('invalid x-amz-acl')
54
54
  else
55
- @data[:acls][:object][bucket_name] ||= {}
56
- @data[:acls][:object][bucket_name][object_name] = self.class.acls(acl)
55
+ self.data[:acls][:object][bucket_name] ||= {}
56
+ self.data[:acls][:object][bucket_name][object_name] = self.class.acls(acl)
57
57
  end
58
58
 
59
59
  data = Fog::Storage.parse_data(data)
@@ -61,7 +61,7 @@ module Fog
61
61
  data[:body] = data[:body].read
62
62
  end
63
63
  response = Excon::Response.new
64
- if (bucket = @data[:buckets][bucket_name])
64
+ if (bucket = self.data[:buckets][bucket_name])
65
65
  response.status = 200
66
66
  object = {
67
67
  :body => data[:body],
@@ -35,7 +35,7 @@ DATA
35
35
 
36
36
  def put_request_payment(bucket_name, payer)
37
37
  response = Excon::Response.new
38
- if bucket = @data[:buckets][bucket_name]
38
+ if bucket = self.data[:buckets][bucket_name]
39
39
  response.status = 200
40
40
  bucket['Payer'] = payer
41
41
  else
@@ -43,9 +43,9 @@ module Fog
43
43
 
44
44
  def copy_object(source_bucket_name, source_object_name, target_bucket_name, target_object_name, options = {})
45
45
  response = Excon::Response.new
46
- source_bucket = @data[:buckets][source_bucket_name]
46
+ source_bucket = self.data[:buckets][source_bucket_name]
47
47
  source_object = source_bucket && source_bucket[:objects][source_object_name]
48
- target_bucket = @data[:buckets][target_bucket_name]
48
+ target_bucket = self.data[:buckets][target_bucket_name]
49
49
 
50
50
  if source_object && target_bucket
51
51
  response.status = 200
@@ -26,14 +26,14 @@ module Fog
26
26
 
27
27
  def delete_bucket(bucket_name)
28
28
  response = Excon::Response.new
29
- if @data[:buckets][bucket_name].nil?
29
+ if self.data[:buckets][bucket_name].nil?
30
30
  response.status = 404
31
31
  raise(Excon::Errors.status_error({:expects => 204}, response))
32
- elsif @data[:buckets][bucket_name] && !@data[:buckets][bucket_name][:objects].empty?
32
+ elsif self.data[:buckets][bucket_name] && !self.data[:buckets][bucket_name][:objects].empty?
33
33
  response.status = 409
34
34
  raise(Excon::Errors.status_error({:expects => 204}, response))
35
35
  else
36
- @data[:buckets].delete(bucket_name)
36
+ self.data[:buckets].delete(bucket_name)
37
37
  response.status = 204
38
38
  end
39
39
  response
@@ -29,7 +29,7 @@ module Fog
29
29
 
30
30
  def delete_object(bucket_name, object_name)
31
31
  response = Excon::Response.new
32
- if bucket = @data[:buckets][bucket_name]
32
+ if bucket = self.data[:buckets][bucket_name]
33
33
  if object = bucket[:objects][object_name]
34
34
  response.status = 204
35
35
  bucket[:objects].delete(object_name)
@@ -64,7 +64,7 @@ module Fog
64
64
  response = Excon::Response.new
65
65
  name = /(\w+\.?)*/.match(bucket_name)
66
66
  if bucket_name == name.to_s
67
- if bucket = @data[:buckets][bucket_name]
67
+ if bucket = self.data[:buckets][bucket_name]
68
68
  contents = bucket[:objects].values.sort {|x,y| x['Key'] <=> y['Key']}.reject do |object|
69
69
  (options['prefix'] && object['Key'][0...options['prefix'].length] != options['prefix']) ||
70
70
  (options['marker'] && object['Key'] <= options['marker'])
@@ -47,7 +47,7 @@ module Fog
47
47
 
48
48
  def get_bucket_acl(bucket_name)
49
49
  response = Excon::Response.new
50
- if acl = @data[:acls][:bucket][bucket_name]
50
+ if acl = self.data[:acls][:bucket][bucket_name]
51
51
  response.status = 200
52
52
  response.body = acl
53
53
  else
@@ -62,7 +62,7 @@ module Fog
62
62
  raise ArgumentError.new('object_name is required')
63
63
  end
64
64
  response = Excon::Response.new
65
- if (bucket = @data[:buckets][bucket_name]) && (object = bucket[:objects][object_name])
65
+ if (bucket = self.data[:buckets][bucket_name]) && (object = bucket[:objects][object_name])
66
66
  if options['If-Match'] && options['If-Match'] != object['ETag']
67
67
  response.status = 412
68
68
  elsif options['If-Modified-Since'] && options['If-Modified-Since'] > Time.parse(object['Last-Modified'])
@@ -58,7 +58,7 @@ module Fog
58
58
 
59
59
  def get_object_acl(bucket_name, object_name)
60
60
  response = Excon::Response.new
61
- if acl = @data[:acls][:object][bucket_name] && @data[:acls][:object][bucket_name][object_name]
61
+ if acl = self.data[:acls][:object][bucket_name] && self.data[:acls][:object][bucket_name][object_name]
62
62
  response.status = 200
63
63
  response.body = acl
64
64
  else
@@ -35,14 +35,14 @@ module Fog
35
35
  def get_service
36
36
  response = Excon::Response.new
37
37
  response.headers['Status'] = 200
38
- buckets = @data[:buckets].values.map do |bucket|
38
+ buckets = self.data[:buckets].values.map do |bucket|
39
39
  bucket.reject do |key, value|
40
40
  !['CreationDate', 'Name'].include?(key)
41
41
  end
42
42
  end
43
43
  response.body = {
44
44
  'Buckets' => buckets,
45
- 'Owner' => { 'DisplayName' => 'owner', 'ID' => 'some_id'}
45
+ 'Owner' => { 'ID' => 'some_id'}
46
46
  }
47
47
  response
48
48
  end
@@ -44,7 +44,7 @@ DATA
44
44
  if !['private', 'public-read', 'public-read-write', 'authenticated-read'].include?(acl)
45
45
  raise Excon::Errors::BadRequest.new('invalid x-goog-acl')
46
46
  else
47
- @data[:acls][:bucket][bucket_name] = self.class.acls(options[acl])
47
+ self.data[:acls][:bucket][bucket_name] = self.class.acls(options[acl])
48
48
  end
49
49
  response = Excon::Response.new
50
50
  response.status = 200
@@ -60,8 +60,8 @@ DATA
60
60
  else
61
61
  bucket['LocationConstraint'] = ''
62
62
  end
63
- if @data[:buckets][bucket_name].nil?
64
- @data[:buckets][bucket_name] = bucket
63
+ if self.data[:buckets][bucket_name].nil?
64
+ self.data[:buckets][bucket_name] = bucket
65
65
  else
66
66
  response.status = 409
67
67
  raise(Excon::Errors.status_error({:expects => 200}, response))
@@ -46,8 +46,8 @@ module Fog
46
46
  if !['private', 'public-read', 'public-read-write', 'authenticated-read'].include?(acl)
47
47
  raise Excon::Errors::BadRequest.new('invalid x-goog-acl')
48
48
  else
49
- @data[:acls][:object][bucket_name] ||= {}
50
- @data[:acls][:object][bucket_name][object_name] = self.class.acls(acl)
49
+ self.data[:acls][:object][bucket_name] ||= {}
50
+ self.data[:acls][:object][bucket_name][object_name] = self.class.acls(acl)
51
51
  end
52
52
 
53
53
  data = Fog::Storage.parse_data(data)
@@ -55,7 +55,7 @@ module Fog
55
55
  data[:body] = data[:body].read
56
56
  end
57
57
  response = Excon::Response.new
58
- if (bucket = @data[:buckets][bucket_name])
58
+ if (bucket = self.data[:buckets][bucket_name])
59
59
  response.status = 200
60
60
  object = {
61
61
  :body => data[:body],
@@ -28,7 +28,7 @@ module Fog
28
28
  def get_network(network_id)
29
29
  network_id = network_id.to_i
30
30
  response = Excon::Response.new
31
- if network = @data[:organizations].map { |org| org[:vdcs].map { |vdc| vdc[:networks] } }.flatten.detect { |network| network[:id] == network_id }
31
+ if network = self.data[:organizations].map { |org| org[:vdcs].map { |vdc| vdc[:networks] } }.flatten.detect { |network| network[:id] == network_id }
32
32
 
33
33
  body = { "links" => [],
34
34
  "type" => "application/vnd.vmware.vcloud.network+xml",
@@ -36,7 +36,7 @@ module Fog
36
36
  organization_id = organization_id.to_i
37
37
  response = Excon::Response.new
38
38
 
39
- if org = @data[:organizations].detect { |org| org[:info][:id] == organization_id }
39
+ if org = self.data[:organizations].detect { |org| org[:info][:id] == organization_id }
40
40
 
41
41
  body = { "name" => org[:info][:name],
42
42
  "href" => "#{@base_url}/org/#{org[:info][:id]}",
@@ -31,7 +31,7 @@ module Fog
31
31
 
32
32
  def get_organizations
33
33
  response = Excon::Response.new
34
- org_list = @data[:organizations].map do |organization|
34
+ org_list = self.data[:organizations].map do |organization|
35
35
  { "name" => organization[:info][:name],
36
36
  "href" => "#{@base_url}/org/#{organization[:info][:id]}",
37
37
  "type" => "application/vnd.vmware.vcloud.org+xml"
@@ -35,7 +35,7 @@ module Fog
35
35
  vdc_id = vdc_id.to_i
36
36
  response = Excon::Response.new
37
37
 
38
- if vdc = @data[:organizations].map { |org| org[:vdcs] }.flatten.detect { |vdc| vdc[:id] == vdc_id }
38
+ if vdc = self.data[:organizations].map { |org| org[:vdcs] }.flatten.detect { |vdc| vdc[:id] == vdc_id }
39
39
  body = { "PublicIpAddresses" => [] }
40
40
  vdc[:public_ips].each do |ip|
41
41
  ip = { "name" => ip[:name],
@@ -37,7 +37,7 @@ module Fog
37
37
  vdc_id = vdc_id.to_i
38
38
  response = Excon::Response.new
39
39
 
40
- if vdc = @data[:organizations].map { |org| org[:vdcs] }.flatten.detect { |vdc| vdc[:id] == vdc_id }
40
+ if vdc = self.data[:organizations].map { |org| org[:vdcs] }.flatten.detect { |vdc| vdc[:id] == vdc_id }
41
41
 
42
42
  body = { "name" => vdc[:name],
43
43
  "href" => "#{@base_url}/vdc/#{vdc[:id]}",
@@ -208,6 +208,10 @@ module Fog
208
208
  end
209
209
  end'
210
210
  self.class.instance_eval '
211
+ def self.reset
212
+ @data = nil
213
+ end
214
+
211
215
  def self.reset_data(keys=data.keys)
212
216
  for key in [*keys]
213
217
  data.delete(key)
@@ -106,8 +106,18 @@ module Fog
106
106
  @base_url = Fog::Terremark::Vcloud::Defaults::SCHEME + "://" +
107
107
  Fog::Terremark::Vcloud::Defaults::HOST +
108
108
  Fog::Terremark::Vcloud::Defaults::PATH
109
- @data = self.class.data[:terremark_vcloud_username]
109
+
110
+ @terremark_username = options[:terremark_vcloud_username]
111
+ end
112
+
113
+ def data
114
+ self.class.data[@terremark_username]
110
115
  end
116
+
117
+ def reset_data
118
+ self.class.data.delete(@terremark_username)
119
+ end
120
+
111
121
  end
112
122
 
113
123
  end
@@ -1,19 +1,25 @@
1
1
  require 'ecloud/spec_helper'
2
2
 
3
3
  describe 'Ecloud' do
4
- it { Ecloud.should be_available }
5
4
 
6
- it { Ecloud.should have_at_least(1).services }
5
+ it do
6
+ pending unless Ecloud.available?
7
+ Ecloud.should have_at_least(1).services
8
+ end
7
9
 
8
10
  describe "when indexing it like an array" do
11
+
12
+
9
13
  describe "with a service that exists" do
10
14
  it "should return something when indexed with a configured service" do
15
+ pending unless Ecloud.available?
11
16
  Ecloud[:compute].should_not be_nil
12
17
  end
13
18
  end
14
19
 
15
20
  describe "with a service that does not exist" do
16
21
  it "should raise an ArgumentError" do
22
+ pending unless Ecloud.available?
17
23
  lambda {Ecloud[:foozle]}.should raise_error(ArgumentError)
18
24
  end
19
25
  end