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
@@ -56,6 +56,10 @@ module Fog
56
56
  end
57
57
  end
58
58
 
59
+ def self.reset
60
+ @data = nil
61
+ end
62
+
59
63
  def self.reset_data(keys=data.keys)
60
64
  for key in [*keys]
61
65
  data.delete(key)
@@ -64,7 +68,14 @@ module Fog
64
68
 
65
69
  def initialize(options={})
66
70
  @storm_on_demand_username = options[:storm_on_demand_username]
67
- @data = self.class.data[@storm_on_demand_username]
71
+ end
72
+
73
+ def data
74
+ self.class.data[@storm_on_demand_username]
75
+ end
76
+
77
+ def reset_data
78
+ self.class.data.delete(@storm_on_demand_username)
68
79
  end
69
80
 
70
81
  end
@@ -48,14 +48,20 @@ module Fog
48
48
  end
49
49
  end
50
50
 
51
+ def self.reset
52
+ @data = nil
53
+ end
54
+
51
55
  def initialize(options={})
52
56
  @voxel_api_key = options[:voxel_api_key]
53
- @data = self.class.data[@voxel_api_key]
57
+ end
58
+
59
+ def data
60
+ self.class.data[@voxel_api_key]
54
61
  end
55
62
 
56
63
  def reset_data
57
64
  self.class.data.delete(@voxel_api_key)
58
- @data = self.class.data[@voxel_api_key]
59
65
  end
60
66
 
61
67
  end
@@ -63,6 +63,19 @@ module Fog
63
63
  selection
64
64
  end
65
65
 
66
+ def self.reset
67
+ providers = Fog.providers.map {|p| Fog.const_get(p) }
68
+ possible_service_constants = providers.map {|p| p.constants.map {|c| p.const_get(c) } }.flatten
69
+ # c.to_sym is 1.8.7 / 1.9.2 compat
70
+ services = possible_service_constants.select {|s| s.constants.map {|c| c.to_sym }.include?(:Mock) }
71
+ service_mocks = services.map {|s| s.const_get(:Mock) }
72
+
73
+ service_mocks.each do |service_mock|
74
+ next unless service_mock.respond_to?(:reset)
75
+ service_mock.reset
76
+ end
77
+ end
78
+
66
79
  end
67
80
 
68
- end
81
+ end
@@ -33,6 +33,10 @@ module Fog
33
33
  end
34
34
  end
35
35
 
36
+ def self.reset
37
+ @data = nil
38
+ end
39
+
36
40
  def initialize(options={})
37
41
  unless options.delete(:provider)
38
42
  location = caller.first
@@ -44,12 +48,14 @@ module Fog
44
48
  require 'mime/types'
45
49
  @aws_access_key_id = options[:aws_access_key_id]
46
50
  @region = options[:region]
47
- @data = self.class.data[@region][@aws_access_key_id]
51
+ end
52
+
53
+ def data
54
+ self.class.data[@region][@aws_access_key_id]
48
55
  end
49
56
 
50
57
  def reset_data
51
58
  self.class.data[@region].delete(@aws_access_key_id)
52
- @data = self.class.data[@region][@aws_access_key_id]
53
59
  end
54
60
 
55
61
  def signature(params)
@@ -30,6 +30,10 @@ module Fog
30
30
  end
31
31
  end
32
32
 
33
+ def self.reset
34
+ @data = nil
35
+ end
36
+
33
37
  def initialize(options={})
34
38
  unless options.delete(:provider)
35
39
  location = caller.first
@@ -40,12 +44,14 @@ module Fog
40
44
 
41
45
  @bluebox_customer_id = options[:bluebox_customer_id]
42
46
  @bluebox_api_key = options[:bluebox_api_key]
43
- @data = self.class.data[@bluebox_customer_id]
47
+ end
48
+
49
+ def data
50
+ self.class.data[@bluebox_customer_id]
44
51
  end
45
52
 
46
53
  def reset_data
47
54
  self.class.data.delete(@bluebox_customer_id)
48
- @data = self.class.data[@bluebox_customer_id]
49
55
  end
50
56
  end
51
57
 
@@ -3,7 +3,7 @@ module Fog
3
3
  class DNS < Fog::Service
4
4
 
5
5
  requires :dnsimple_email, :dnsimple_password
6
- recognizes :host, :path, :port, :scheme, :persistent
6
+ recognizes :dnsimple_url, :host, :path, :port, :scheme, :persistent
7
7
  recognizes :provider # remove post deprecation
8
8
 
9
9
  model_path 'fog/dns/models/dnsimple'
@@ -31,6 +31,10 @@ module Fog
31
31
  end
32
32
  end
33
33
 
34
+ def self.reset
35
+ @data = nil
36
+ end
37
+
34
38
  def initialize(options={})
35
39
  unless options.delete(:provider)
36
40
  location = caller.first
@@ -41,12 +45,14 @@ module Fog
41
45
 
42
46
  @dnsimple_email = options[:dnsimple_email]
43
47
  @dnsimple_password = options[:dnsimple_password]
44
- @data = self.class.data[@dnsimple_email]
48
+ end
49
+
50
+ def data
51
+ self.class.data[@dnsimple_email]
45
52
  end
46
53
 
47
54
  def reset_data
48
55
  self.class.data.delete(@dnsimple_email)
49
- @data = self.class.data[@dnsimple_email]
50
56
  end
51
57
 
52
58
  end
@@ -65,6 +71,12 @@ module Fog
65
71
 
66
72
  @dnsimple_email = options[:dnsimple_email]
67
73
  @dnsimple_password = options[:dnsimple_password]
74
+ if options[:dnsimple_url]
75
+ uri = URI.parse(options[:dnsimple_url])
76
+ options[:host] = uri.host
77
+ options[:port] = uri.port
78
+ options[:scheme] = uri.scheme
79
+ end
68
80
  @host = options[:host] || "dnsimple.com"
69
81
  @port = options[:port] || 443
70
82
  @scheme = options[:scheme] || 'https'
@@ -30,6 +30,10 @@ module Fog
30
30
  end
31
31
  end
32
32
 
33
+ def self.reset
34
+ @data = nil
35
+ end
36
+
33
37
  def initialize(options={})
34
38
  unless options.delete(:provider)
35
39
  location = caller.first
@@ -39,12 +43,14 @@ module Fog
39
43
  end
40
44
 
41
45
  @linode_api_key = options[:linode_api_key]
42
- @data = self.class.data[@linode_api_key]
46
+ end
47
+
48
+ def data
49
+ self.class.data[@linode_api_key]
43
50
  end
44
51
 
45
52
  def reset_data
46
53
  self.class.data.delete(@linode_api_key)
47
- @data = self.class.data[@linode_api_key]
48
54
  end
49
55
 
50
56
  end
@@ -30,6 +30,10 @@ module Fog
30
30
  end
31
31
  end
32
32
 
33
+ def self.reset
34
+ @data = nil
35
+ end
36
+
33
37
  def initialize(options={})
34
38
  unless options.delete(:provider)
35
39
  location = caller.first
@@ -39,12 +43,14 @@ module Fog
39
43
  end
40
44
 
41
45
  @slicehost_password = options[:slicehost_password]
42
- @data = self.class.data[@slicehost_password]
46
+ end
47
+
48
+ def data
49
+ self.class.data[@slicehost_password]
43
50
  end
44
51
 
45
52
  def reset_data
46
53
  self.class.data.delete(@slicehost_password)
47
- @data = self.class.data[@slicehost_password]
48
54
  end
49
55
 
50
56
  end
@@ -36,6 +36,10 @@ module Fog
36
36
  end
37
37
  end
38
38
 
39
+ def self.reset
40
+ @data = nil
41
+ end
42
+
39
43
  def initialize(options={})
40
44
  unless options.delete(:provider)
41
45
  location = caller.first
@@ -46,12 +50,14 @@ module Fog
46
50
 
47
51
  @zerigo_email = options[:zerigo_email]
48
52
  @zerigo_token = options[:zerigo_token]
49
- @data = self.class.data[@zerigo_email]
53
+ end
54
+
55
+ def data
56
+ self.class.data[@zerigo_email]
50
57
  end
51
58
 
52
59
  def reset_data
53
60
  self.class.data.delete(@zerigo_email)
54
- @data = self.class.data[@zerigo_email]
55
61
  end
56
62
 
57
63
  end
@@ -1,5 +1,6 @@
1
1
  require 'fog/core'
2
2
  require 'fog/core/parser'
3
+ require 'openssl' # For RSA key pairs
3
4
 
4
5
  module Fog
5
6
  module AWS
@@ -44,7 +45,7 @@ module Fog
44
45
  def self.escape(string)
45
46
  string.gsub( /([^-a-zA-Z0-9_.~]+)/n ) { |match| '%' + match.unpack( 'H2' * match.size ).join( '%' ).upcase }
46
47
  end
47
-
48
+
48
49
  def self.signed_params(params, options = {})
49
50
  params.merge!({
50
51
  'AWSAccessKeyId' => options[:aws_access_key_id],
@@ -69,8 +70,8 @@ module Fog
69
70
 
70
71
  class Mock
71
72
 
72
- def self.availability_zone
73
- "us-east-1" << Fog::Mock.random_selection('abcd', 1)
73
+ def self.availability_zone(region)
74
+ "#{region}#{Fog::Mock.random_selection('abcd', 1)}"
74
75
  end
75
76
 
76
77
  def self.box_usage
@@ -140,13 +141,7 @@ module Fog
140
141
  end
141
142
 
142
143
  def self.key_material
143
- key_material = ['-----BEGIN RSA PRIVATE KEY-----']
144
- 20.times do
145
- key_material << Fog::Mock.random_base64(76)
146
- end
147
- key_material << Fog::Mock.random_base64(67) + '='
148
- key_material << '-----END RSA PRIVATE KEY-----'
149
- key_material.join("\n")
144
+ OpenSSL::PKey::RSA.generate(1024).to_s
150
145
  end
151
146
 
152
147
  def self.owner_id
@@ -2,12 +2,9 @@ require 'fog/core'
2
2
 
3
3
  module Fog
4
4
  module Linode
5
-
6
5
  extend Fog::Provider
7
-
8
6
  service(:compute, 'compute/linode')
9
7
  service(:dns, 'dns/linode')
10
-
11
8
  end
12
9
  end
13
10
 
@@ -22,12 +22,14 @@ module Fog
22
22
  end
23
23
 
24
24
  def self.get_body_size(body)
25
- case
26
- when body.respond_to?(:bytesize)
25
+ if body.respond_to?(:force_encoding)
26
+ body.force_encoding('BINARY')
27
+ end
28
+ if body.respond_to?(:bytesize)
27
29
  body.bytesize
28
- when body.respond_to?(:size)
30
+ elsif body.respond_to?(:size)
29
31
  body.size
30
- when body.respond_to?(:stat)
32
+ elsif body.respond_to?(:stat)
31
33
  body.stat.size
32
34
  else
33
35
  0
@@ -148,6 +148,10 @@ module Fog
148
148
  end
149
149
  end
150
150
 
151
+ def self.reset
152
+ @data = nil
153
+ end
154
+
151
155
  def initialize(options={})
152
156
  unless options.delete(:provider)
153
157
  location = caller.first
@@ -175,12 +179,14 @@ module Fog
175
179
  raise ArgumentError, "Unknown region: #{options[:region].inspect}"
176
180
  end
177
181
  @region = options[:region]
178
- @data = self.class.data[@region][@aws_access_key_id]
182
+ end
183
+
184
+ def data
185
+ self.class.data[@region][@aws_access_key_id]
179
186
  end
180
187
 
181
188
  def reset_data
182
189
  self.class.data[@region].delete(@aws_access_key_id)
183
- @data = self.class.data[@region][@aws_access_key_id]
184
190
  end
185
191
 
186
192
  def signature(params)
@@ -119,6 +119,10 @@ module Fog
119
119
  end
120
120
  end
121
121
 
122
+ def self.reset
123
+ @data = nil
124
+ end
125
+
122
126
  def initialize(options={})
123
127
  unless options.delete(:provider)
124
128
  location = caller.first
@@ -129,12 +133,14 @@ module Fog
129
133
 
130
134
  require 'mime/types'
131
135
  @google_storage_access_key_id = options[:google_storage_access_key_id]
132
- @data = self.class.data[@google_storage_access_key_id]
136
+ end
137
+
138
+ def data
139
+ self.class.data[@google_storage_access_key_id]
133
140
  end
134
141
 
135
142
  def reset_data
136
143
  self.class.data.delete(@google_storage_access_key_id)
137
- @data = self.class.data[@google_storage_access_key_id]
138
144
  end
139
145
 
140
146
  def signature(params)
@@ -19,6 +19,10 @@ module Fog
19
19
  end
20
20
  end
21
21
 
22
+ def self.reset
23
+ @data = nil
24
+ end
25
+
22
26
  def initialize(options={})
23
27
  Fog::Mock.not_implemented
24
28
 
@@ -31,7 +35,10 @@ module Fog
31
35
  end
32
36
 
33
37
  @local_root = ::File.expand_path(options[:local_root])
34
- @data = self.class.data[@local_root]
38
+ end
39
+
40
+ def data
41
+ self.class.data[@local_root]
35
42
  end
36
43
 
37
44
  def local_root
@@ -44,7 +51,6 @@ module Fog
44
51
 
45
52
  def reset_data
46
53
  self.class.data.delete(@local_root)
47
- @data = self.class.data[@local_root]
48
54
  end
49
55
 
50
56
  end
@@ -117,7 +117,6 @@ module Fog
117
117
  options['x-amz-storage-class'] = storage_class if storage_class
118
118
 
119
119
  data = connection.put_object(directory.key, key, body, options)
120
- data.headers.delete('Content-Length')
121
120
  data.headers['ETag'].gsub!('"','')
122
121
  merge_attributes(data.headers)
123
122
  self.content_length = Fog::Storage.get_body_size(body)
@@ -119,11 +119,7 @@ module Fog
119
119
 
120
120
  data = connection.put_object(directory.key, key, body, options)
121
121
  merge_attributes(data.headers)
122
- if body.is_a?(String)
123
- self.content_length = body.size
124
- else
125
- self.content_length = ::File.size(body.path)
126
- end
122
+ self.content_length = Fog::Storage.get_body_size(body)
127
123
  true
128
124
  end
129
125
 
@@ -88,7 +88,7 @@ module Fog
88
88
  end
89
89
  file.close
90
90
  merge_attributes(
91
- :content_length => ::File.size(path),
91
+ :content_length => Fog::Storage.get_body_size(body),
92
92
  :last_modified => ::File.mtime(path)
93
93
  )
94
94
  true