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
@@ -0,0 +1,32 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/compute/models/linode/server'
3
+
4
+ module Fog
5
+ module Linode
6
+ class Compute
7
+ class Servers < Fog::Collection
8
+ model Fog::Linode::Compute::Server
9
+
10
+ def all
11
+ load servers
12
+ end
13
+
14
+ def get(id)
15
+ new servers(id).first
16
+ rescue Fog::Linode::Compute::NotFound
17
+ nil
18
+ end
19
+
20
+ private
21
+ def servers(id=nil)
22
+ connection.linode_list(id).body['DATA'].map { |server| map_server server }
23
+ end
24
+
25
+ def map_server(server)
26
+ server = server.each_with_object({}) { |(k, v), h| h[k.downcase.to_sym] = v }
27
+ server.merge! :id => server[:linodeid], :name => server[:label]
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,13 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module Linode
5
+ class Compute
6
+ class StackScript < Fog::Model
7
+ attr_accessor :options
8
+ identity :id
9
+ attribute :name
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,32 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/compute/models/linode/stack_script'
3
+
4
+ module Fog
5
+ module Linode
6
+ class Compute
7
+ class StackScripts < Fog::Collection
8
+ model Fog::Linode::Compute::StackScript
9
+
10
+ def all
11
+ load stackscripts
12
+ end
13
+
14
+ def get(id)
15
+ new stackscripts(id).first
16
+ rescue Fog::Linode::Compute::NotFound
17
+ nil
18
+ end
19
+
20
+ private
21
+ def stackscripts(id=nil)
22
+ connection.stackscript_list(id).body['DATA'].map { |script| map_stackscript script }
23
+ end
24
+
25
+ def map_stackscript(script)
26
+ script = script.each_with_object({}) { |(k, v), h| h[k.downcase.to_sym] = v }
27
+ script.merge! :id => script[:stackscriptid], :name => script[:label]
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -16,7 +16,7 @@ module Fog
16
16
  attribute :name
17
17
  attribute :personality
18
18
  attribute :progress
19
- attribute :status
19
+ attribute :state, :aliases => 'status'
20
20
 
21
21
  attr_reader :password
22
22
  attr_writer :private_key, :private_key_path, :public_key, :public_key_path, :username
@@ -75,7 +75,7 @@ module Fog
75
75
  end
76
76
 
77
77
  def ready?
78
- status == 'ACTIVE'
78
+ self.state == 'ACTIVE'
79
79
  end
80
80
 
81
81
  def reboot(type = 'SOFT')
@@ -16,7 +16,7 @@ module Fog
16
16
  attribute :image_id, :aliases => 'image-id'
17
17
  attribute :name
18
18
  attribute :progress
19
- attribute :status
19
+ attribute :state, :aliases => 'status'
20
20
 
21
21
  attr_accessor :password
22
22
  alias_method :'root-password=', :password=
@@ -71,7 +71,7 @@ module Fog
71
71
  end
72
72
 
73
73
  def ready?
74
- status == 'active'
74
+ self.state == 'active'
75
75
  end
76
76
 
77
77
  def reboot(type = 'SOFT')
@@ -32,7 +32,7 @@ module Fog
32
32
  end
33
33
 
34
34
  def ready?
35
- status == 'SUCCEEDED'
35
+ self.state == 'SUCCEEDED'
36
36
  end
37
37
 
38
38
  def private_ip_address
@@ -49,8 +49,8 @@ module Fog
49
49
  true
50
50
  end
51
51
 
52
- def status
53
- @status ||= connection.voxcloud_status(id).body['devices'].first['status']
52
+ def state
53
+ @state ||= connection.voxcloud_status(id).body['devices'].first['status']
54
54
  end
55
55
 
56
56
  def save
@@ -25,6 +25,10 @@ module Fog
25
25
  end
26
26
  end
27
27
 
28
+ def self.reset
29
+ @data = nil
30
+ end
31
+
28
32
  def initialize(options={})
29
33
  unless options.delete(:provider)
30
34
  location = caller.first
@@ -34,12 +38,14 @@ module Fog
34
38
  end
35
39
 
36
40
  @new_server_username = options[:new_servers_username]
37
- @data = self.class.data[@new_server_username]
41
+ end
42
+
43
+ def data
44
+ self.class.data[@new_server_username]
38
45
  end
39
46
 
40
47
  def reset_data
41
48
  self.class.data.delete(@new_server_username)
42
- @data = self.class.data[@new_server_username]
43
49
  end
44
50
 
45
51
  end
@@ -53,6 +53,10 @@ module Fog
53
53
  end
54
54
  end
55
55
 
56
+ def self.reset
57
+ @data = nil
58
+ end
59
+
56
60
  def initialize(options={})
57
61
  unless options.delete(:provider)
58
62
  location = caller.first
@@ -62,12 +66,14 @@ module Fog
62
66
  end
63
67
 
64
68
  @rackspace_username = options[:rackspace_username]
65
- @data = self.class.data[@rackspace_username]
69
+ end
70
+
71
+ def data
72
+ self.class.data[@rackspace_username]
66
73
  end
67
74
 
68
75
  def reset_data
69
76
  self.class.data.delete(@rackspace_username)
70
- @data = self.class.data[@rackspace_username]
71
77
  end
72
78
 
73
79
  end
@@ -12,6 +12,8 @@ module Fog
12
12
  # * body<~Hash>:
13
13
  # * 'publicIp'<~String> - The acquired address
14
14
  # * 'requestId'<~String> - Id of the request
15
+ #
16
+ # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AllocateAddress.html]
15
17
  def allocate_address
16
18
  request(
17
19
  'Action' => 'AllocateAddress',
@@ -25,14 +27,14 @@ module Fog
25
27
 
26
28
  def allocate_address
27
29
  response = Excon::Response.new
28
- if describe_addresses.body['addressesSet'].size < @data[:limits][:addresses]
30
+ if describe_addresses.body['addressesSet'].size < self.data[:limits][:addresses]
29
31
  response.status = 200
30
32
  public_ip = Fog::AWS::Mock.ip_address
31
33
  data ={
32
34
  'instanceId' => nil,
33
35
  'publicIp' => public_ip
34
36
  }
35
- @data[:addresses][public_ip] = data
37
+ self.data[:addresses][public_ip] = data
36
38
  response.body = {
37
39
  'publicIp' => public_ip,
38
40
  'requestId' => Fog::AWS::Mock.request_id
@@ -16,6 +16,8 @@ module Fog
16
16
  # * body<~Hash>:
17
17
  # * 'requestId'<~String> - Id of request
18
18
  # * 'return'<~Boolean> - success?
19
+ #
20
+ # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AssociateAddress.html]
19
21
  def associate_address(instance_id, public_ip)
20
22
  request(
21
23
  'Action' => 'AssociateAddress',
@@ -33,8 +35,8 @@ module Fog
33
35
  def associate_address(instance_id, public_ip)
34
36
  response = Excon::Response.new
35
37
  response.status = 200
36
- instance = @data[:instances][instance_id]
37
- address = @data[:addresses][public_ip]
38
+ instance = self.data[:instances][instance_id]
39
+ address = self.data[:addresses][public_ip]
38
40
  if instance && address
39
41
  address['instanceId'] = instance_id
40
42
  instance['originalIpAddress'] = instance['ipAddress']
@@ -21,6 +21,8 @@ module Fog
21
21
  # * 'requestId'<~String> - Id of request
22
22
  # * 'status'<~String> - Status of volume
23
23
  # * 'volumeId'<~String> - Reference to volume
24
+ #
25
+ # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AttachVolume.html]
24
26
  def attach_volume(instance_id, volume_id, device)
25
27
  request(
26
28
  'Action' => 'AttachVolume',
@@ -40,8 +42,8 @@ module Fog
40
42
  response = Excon::Response.new
41
43
  if instance_id && volume_id && device
42
44
  response.status = 200
43
- instance = @data[:instances][instance_id]
44
- volume = @data[:volumes][volume_id]
45
+ instance = self.data[:instances][instance_id]
46
+ volume = self.data[:volumes][volume_id]
45
47
  if instance && volume
46
48
  unless volume['status'] == 'available'
47
49
  raise Fog::AWS::Compute::Error.new("Client.VolumeInUse => Volume #{volume_id} is unavailable")
@@ -24,6 +24,8 @@ module Fog
24
24
  # * body<~Hash>:
25
25
  # * 'requestId'<~String> - Id of request
26
26
  # * 'return'<~Boolean> - success?
27
+ #
28
+ # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AuthorizeSecurityGroupIngress.html]
27
29
  def authorize_security_group_ingress(group_name, options = {})
28
30
  if group_name.is_a?(Hash)
29
31
  location = caller.first
@@ -56,14 +58,14 @@ module Fog
56
58
  end
57
59
 
58
60
  response = Excon::Response.new
59
- group = @data[:security_groups][group_name]
61
+ group = self.data[:security_groups][group_name]
60
62
 
61
63
  if group
62
64
  group['ipPermissions'] ||= []
63
65
  if group_name && options['SourceSecurityGroupName'] && options['SourceSecurityGroupOwnerId']
64
66
  ['tcp', 'udp'].each do |protocol|
65
67
  group['ipPermissions'] << {
66
- 'groups' => [{'groupName' => group_name, 'userId' => @owner_id}],
68
+ 'groups' => [{'groupName' => group_name, 'userId' => self.data[:owner_id]}],
67
69
  'fromPort' => 1,
68
70
  'ipRanges' => [],
69
71
  'ipProtocol' => protocol,
@@ -71,7 +73,7 @@ module Fog
71
73
  }
72
74
  end
73
75
  group['ipPermissions'] << {
74
- 'groups' => [{'groupName' => group_name, 'userId' => @owner_id}],
76
+ 'groups' => [{'groupName' => group_name, 'userId' => self.data[:owner_id]}],
75
77
  'fromPort' => -1,
76
78
  'ipRanges' => [],
77
79
  'ipProtocol' => 'icmp',
@@ -18,7 +18,8 @@ module Fog
18
18
  # * body<~Hash>:
19
19
  # * 'imageId'<~String> - The ID of the created AMI.
20
20
  # * 'requestId'<~String> - Id of request.
21
-
21
+ #
22
+ # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateImage.html]
22
23
  def create_image(instance_id, name, description, no_reboot = false)
23
24
  request(
24
25
  'Action' => 'CreateImage',
@@ -17,6 +17,8 @@ module Fog
17
17
  # * 'keyMaterial'<~String> - Unencrypted encoded PEM private key
18
18
  # * 'keyName'<~String> - Name of key
19
19
  # * 'requestId'<~String> - Id of request
20
+ #
21
+ # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateKeyPair.html]
20
22
  def create_key_pair(key_name)
21
23
  request(
22
24
  'Action' => 'CreateKeyPair',
@@ -31,14 +33,14 @@ module Fog
31
33
 
32
34
  def create_key_pair(key_name)
33
35
  response = Excon::Response.new
34
- unless @data[:key_pairs][key_name]
36
+ unless self.data[:key_pairs][key_name]
35
37
  response.status = 200
36
38
  data = {
37
39
  'keyFingerprint' => Fog::AWS::Mock.key_fingerprint,
38
40
  'keyMaterial' => Fog::AWS::Mock.key_material,
39
41
  'keyName' => key_name
40
42
  }
41
- @data[:key_pairs][key_name] = data
43
+ self.data[:key_pairs][key_name] = data
42
44
  response.body = {
43
45
  'requestId' => Fog::AWS::Mock.request_id
44
46
  }.merge!(data)
@@ -16,6 +16,8 @@ module Fog
16
16
  # * body<~Hash>:
17
17
  # * 'requestId'<~String> - Id of request
18
18
  # * 'return'<~Boolean> - success?
19
+ #
20
+ # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateSecurityGroup.html]
19
21
  def create_security_group(name, description)
20
22
  request(
21
23
  'Action' => 'CreateSecurityGroup',
@@ -31,14 +33,14 @@ module Fog
31
33
 
32
34
  def create_security_group(name, description)
33
35
  response = Excon::Response.new
34
- unless @data[:security_groups][name]
36
+ unless self.data[:security_groups][name]
35
37
  data = {
36
38
  'groupDescription' => description,
37
39
  'groupName' => name,
38
40
  'ipPermissions' => [],
39
- 'ownerId' => @owner_id
41
+ 'ownerId' => self.data[:owner_id]
40
42
  }
41
- @data[:security_groups][name] = data
43
+ self.data[:security_groups][name] = data
42
44
  response.body = {
43
45
  'requestId' => Fog::AWS::Mock.request_id,
44
46
  'return' => true
@@ -19,6 +19,8 @@ module Fog
19
19
  # * 'startTime'<~Time> - timestamp when snapshot was initiated
20
20
  # * 'status'<~String> - state of snapshot
21
21
  # * 'volumeId'<~String> - id of volume snapshot targets
22
+ #
23
+ # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateSnapshot.html]
22
24
  def create_snapshot(volume_id, description = nil)
23
25
  request(
24
26
  'Action' => 'CreateSnapshot',
@@ -40,12 +42,12 @@ module Fog
40
42
 
41
43
  def create_snapshot(volume_id, description = nil)
42
44
  response = Excon::Response.new
43
- if volume = @data[:volumes][volume_id]
45
+ if volume = self.data[:volumes][volume_id]
44
46
  response.status = 200
45
47
  snapshot_id = Fog::AWS::Mock.snapshot_id
46
48
  data = {
47
49
  'description' => description,
48
- 'ownerId' => @owner_id,
50
+ 'ownerId' => self.data[:owner_id],
49
51
  'progress' => nil,
50
52
  'snapshotId' => snapshot_id,
51
53
  'startTime' => Time.now,
@@ -53,11 +55,11 @@ module Fog
53
55
  'volumeId' => volume_id,
54
56
  'volumeSize' => volume['size']
55
57
  }
56
- @data[:snapshots][snapshot_id] = data
58
+ self.data[:snapshots][snapshot_id] = data
57
59
  response.body = {
58
60
  'requestId' => Fog::AWS::Mock.request_id
59
61
  }.merge!(data)
60
- @data[:snapshots][snapshot_id]['tagSet'] = {}
62
+ self.data[:snapshots][snapshot_id]['tagSet'] = {}
61
63
  else
62
64
  response.status = 400
63
65
  raise(Excon::Errors.status_error({:expects => 200}, response))
@@ -16,6 +16,8 @@ module Fog
16
16
  # * body<~Hash>:
17
17
  # * 'requestId'<~String> - Id of request
18
18
  # * 'return'<~Boolean> - success?
19
+ #
20
+ # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateTags.html]
19
21
  def create_tags(resources, tags)
20
22
  resources = [*resources]
21
23
  for key, value in tags
@@ -51,7 +53,7 @@ module Fog
51
53
  when /^vol\-[a-z0-9]{8}$/i
52
54
  'volume'
53
55
  end
54
- if type && @data[:"#{type}s"][resource_id]
56
+ if type && self.data[:"#{type}s"][resource_id]
55
57
  { 'resourceId' => resource_id, 'resourceType' => type }
56
58
  else
57
59
  raise(Fog::Service::NotFound.new("The #{type} ID '#{resource_id}' does not exist"))
@@ -59,11 +61,11 @@ module Fog
59
61
  end
60
62
 
61
63
  tags.each do |key, value|
62
- @data[:tags][key] ||= {}
63
- @data[:tags][key][value] ||= []
64
- @data[:tags][key][value] = @data[:tags][key][value] & tagged
64
+ self.data[:tags][key] ||= {}
65
+ self.data[:tags][key][value] ||= []
66
+ self.data[:tags][key][value] = self.data[:tags][key][value] & tagged
65
67
 
66
- tagged.each {|resource| @data[:"#{resource['resourceType']}s"][resource['resourceId']]['tagSet'][key] = value}
68
+ tagged.each {|resource| self.data[:"#{resource['resourceType']}s"][resource['resourceId']]['tagSet'][key] = value}
67
69
  end
68
70
 
69
71
  response = Excon::Response.new
@@ -21,6 +21,8 @@ module Fog
21
21
  # * 'snapshotId'<~String> - Snapshot volume was created from, if any
22
22
  # * 'status's<~String> - State of volume
23
23
  # * 'volumeId'<~String> - Reference to volume
24
+ #
25
+ # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateVolume.html]
24
26
  def create_volume(availability_zone, size, snapshot_id = nil)
25
27
  request(
26
28
  'Action' => 'CreateVolume',
@@ -38,7 +40,7 @@ module Fog
38
40
  def create_volume(availability_zone, size, snapshot_id = nil)
39
41
  response = Excon::Response.new
40
42
  if availability_zone && size
41
- if snapshot_id && !@data[:snapshots][snapshot_id]
43
+ if snapshot_id && !self.data[:snapshots][snapshot_id]
42
44
  raise Fog::AWS::Compute::NotFound.new("The snapshot '#{snapshot_id}' does not exist.")
43
45
  end
44
46
 
@@ -54,7 +56,7 @@ module Fog
54
56
  'tagSet' => {},
55
57
  'volumeId' => volume_id
56
58
  }
57
- @data[:volumes][volume_id] = data
59
+ self.data[:volumes][volume_id] = data
58
60
  response.body = {
59
61
  'requestId' => Fog::AWS::Mock.request_id
60
62
  }.merge!(data.reject {|key,value| !['availabilityZone','createTime','size','snapshotId','status','volumeId'].include?(key) })