fog 0.3.7 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (201) hide show
  1. data/Gemfile.lock +6 -6
  2. data/README.rdoc +7 -1
  3. data/bin/fog +4 -3
  4. data/fog.gemspec +39 -24
  5. data/lib/fog.rb +4 -12
  6. data/lib/fog/aws.rb +14 -5
  7. data/lib/fog/aws/compute.rb +26 -9
  8. data/lib/fog/aws/elb.rb +3 -2
  9. data/lib/fog/aws/models/compute/address.rb +2 -1
  10. data/lib/fog/aws/models/compute/addresses.rb +11 -9
  11. data/lib/fog/aws/models/compute/flavor.rb +1 -1
  12. data/lib/fog/aws/models/compute/flavors.rb +13 -11
  13. data/lib/fog/aws/models/compute/image.rb +2 -1
  14. data/lib/fog/aws/models/compute/images.rb +7 -9
  15. data/lib/fog/aws/models/compute/key_pair.rb +1 -1
  16. data/lib/fog/aws/models/compute/key_pairs.rb +10 -8
  17. data/lib/fog/aws/models/compute/security_group.rb +1 -1
  18. data/lib/fog/aws/models/compute/security_groups.rb +11 -9
  19. data/lib/fog/aws/models/compute/server.rb +10 -3
  20. data/lib/fog/aws/models/compute/servers.rb +14 -8
  21. data/lib/fog/aws/models/compute/snapshot.rb +3 -2
  22. data/lib/fog/aws/models/compute/snapshots.rb +11 -16
  23. data/lib/fog/aws/models/compute/tag.rb +36 -0
  24. data/lib/fog/aws/models/compute/tags.rb +34 -0
  25. data/lib/fog/aws/models/compute/volume.rb +11 -10
  26. data/lib/fog/aws/models/compute/volumes.rb +11 -9
  27. data/lib/fog/aws/models/storage/directories.rb +1 -1
  28. data/lib/fog/aws/models/storage/directory.rb +1 -1
  29. data/lib/fog/aws/models/storage/file.rb +3 -2
  30. data/lib/fog/aws/models/storage/files.rb +1 -7
  31. data/lib/fog/aws/parsers/compute/describe_availability_zones.rb +4 -2
  32. data/lib/fog/aws/parsers/compute/describe_images.rb +23 -13
  33. data/lib/fog/aws/parsers/compute/describe_instances.rb +34 -8
  34. data/lib/fog/aws/parsers/compute/describe_security_groups.rb +4 -3
  35. data/lib/fog/aws/parsers/compute/describe_snapshots.rb +33 -13
  36. data/lib/fog/aws/parsers/compute/describe_tags.rb +30 -0
  37. data/lib/fog/aws/parsers/compute/describe_volumes.rb +17 -3
  38. data/lib/fog/aws/parsers/compute/run_instances.rb +4 -4
  39. data/lib/fog/aws/parsers/storage/get_bucket.rb +1 -1
  40. data/lib/fog/aws/parsers/storage/get_bucket_logging.rb +1 -1
  41. data/lib/fog/aws/parsers/storage/get_bucket_object_versions.rb +3 -3
  42. data/lib/fog/aws/requests/compute/create_snapshot.rb +1 -0
  43. data/lib/fog/aws/requests/compute/create_tags.rb +78 -0
  44. data/lib/fog/aws/requests/compute/delete_tags.rb +45 -0
  45. data/lib/fog/aws/requests/compute/describe_addresses.rb +27 -19
  46. data/lib/fog/aws/requests/compute/describe_availability_zones.rb +31 -25
  47. data/lib/fog/aws/requests/compute/describe_images.rb +11 -18
  48. data/lib/fog/aws/requests/compute/describe_instances.rb +125 -53
  49. data/lib/fog/aws/requests/compute/describe_key_pairs.rb +29 -21
  50. data/lib/fog/aws/requests/compute/describe_regions.rb +28 -23
  51. data/lib/fog/aws/requests/compute/describe_reserved_instances.rb +8 -4
  52. data/lib/fog/aws/requests/compute/describe_security_groups.rb +48 -19
  53. data/lib/fog/aws/requests/compute/describe_snapshots.rb +72 -35
  54. data/lib/fog/aws/requests/compute/describe_tags.rb +42 -0
  55. data/lib/fog/aws/requests/compute/describe_volumes.rb +67 -36
  56. data/lib/fog/aws/requests/compute/run_instances.rb +10 -3
  57. data/lib/fog/aws/simpledb.rb +3 -1
  58. data/lib/fog/aws/storage.rb +17 -8
  59. data/lib/fog/bluebox/models/compute/flavor.rb +1 -1
  60. data/lib/fog/bluebox/models/compute/flavors.rb +1 -1
  61. data/lib/fog/bluebox/models/compute/image.rb +1 -1
  62. data/lib/fog/bluebox/models/compute/images.rb +1 -1
  63. data/lib/fog/bluebox/models/compute/server.rb +8 -6
  64. data/lib/fog/bluebox/models/compute/servers.rb +1 -1
  65. data/lib/fog/bluebox/requests/compute/get_blocks.rb +1 -1
  66. data/lib/fog/core.rb +11 -0
  67. data/lib/fog/{attributes.rb → core/attributes.rb} +0 -0
  68. data/lib/fog/{bin.rb → core/bin.rb} +1 -1
  69. data/lib/fog/{collection.rb → core/collection.rb} +4 -0
  70. data/lib/fog/{connection.rb → core/connection.rb} +0 -0
  71. data/lib/fog/{credentials.rb → core/credentials.rb} +2 -0
  72. data/lib/fog/{deprecation.rb → core/deprecation.rb} +0 -0
  73. data/lib/fog/{errors.rb → core/errors.rb} +0 -0
  74. data/lib/fog/{hmac.rb → core/hmac.rb} +0 -0
  75. data/lib/fog/{model.rb → core/model.rb} +0 -0
  76. data/lib/fog/{parser.rb → core/parser.rb} +0 -0
  77. data/lib/fog/{provider.rb → core/provider.rb} +0 -0
  78. data/lib/fog/{service.rb → core/service.rb} +1 -0
  79. data/lib/fog/{ssh.rb → core/ssh.rb} +7 -7
  80. data/lib/fog/go_grid.rb +1 -1
  81. data/lib/fog/go_grid/compute.rb +6 -1
  82. data/lib/fog/go_grid/models/compute/image.rb +60 -0
  83. data/lib/fog/go_grid/models/compute/images.rb +33 -0
  84. data/lib/fog/go_grid/models/compute/server.rb +56 -0
  85. data/lib/fog/go_grid/models/compute/servers.rb +35 -0
  86. data/lib/fog/go_grid/requests/compute/grid_image_get.rb +41 -0
  87. data/lib/fog/go_grid/requests/compute/grid_image_list.rb +6 -1
  88. data/lib/fog/go_grid/requests/compute/grid_server_power.rb +2 -2
  89. data/lib/fog/google/models/storage/directories.rb +1 -1
  90. data/lib/fog/google/models/storage/directory.rb +1 -1
  91. data/lib/fog/google/models/storage/file.rb +3 -2
  92. data/lib/fog/google/models/storage/files.rb +1 -7
  93. data/lib/fog/google/parsers/storage/get_bucket.rb +1 -1
  94. data/lib/fog/linode/requests/compute/avail_linodeplans.rb +2 -2
  95. data/lib/fog/local/models/storage/directories.rb +1 -1
  96. data/lib/fog/local/models/storage/directory.rb +1 -1
  97. data/lib/fog/local/models/storage/file.rb +2 -2
  98. data/lib/fog/local/models/storage/files.rb +2 -5
  99. data/lib/fog/local/storage.rb +1 -1
  100. data/lib/fog/new_servers/compute.rb +1 -1
  101. data/lib/fog/rackspace/models/compute/flavor.rb +1 -3
  102. data/lib/fog/rackspace/models/compute/flavors.rb +1 -1
  103. data/lib/fog/rackspace/models/compute/image.rb +2 -1
  104. data/lib/fog/rackspace/models/compute/images.rb +1 -1
  105. data/lib/fog/rackspace/models/compute/server.rb +12 -11
  106. data/lib/fog/rackspace/models/compute/servers.rb +1 -1
  107. data/lib/fog/rackspace/models/storage/directories.rb +1 -1
  108. data/lib/fog/rackspace/models/storage/directory.rb +1 -1
  109. data/lib/fog/rackspace/models/storage/file.rb +4 -4
  110. data/lib/fog/rackspace/models/storage/files.rb +1 -1
  111. data/lib/fog/rackspace/requests/compute/create_image.rb +2 -2
  112. data/lib/fog/rackspace/requests/compute/delete_image.rb +1 -1
  113. data/lib/fog/rackspace/requests/compute/delete_server.rb +1 -1
  114. data/lib/fog/rackspace/requests/compute/get_server_details.rb +1 -1
  115. data/lib/fog/rackspace/requests/compute/list_addresses.rb +1 -1
  116. data/lib/fog/rackspace/requests/compute/list_images_detail.rb +2 -2
  117. data/lib/fog/rackspace/requests/compute/list_private_addresses.rb +1 -1
  118. data/lib/fog/rackspace/requests/compute/list_public_addresses.rb +1 -1
  119. data/lib/fog/rackspace/requests/compute/update_server.rb +1 -1
  120. data/lib/fog/rackspace/requests/storage/put_object.rb +4 -3
  121. data/lib/fog/slicehost/models/compute/flavor.rb +1 -1
  122. data/lib/fog/slicehost/models/compute/flavors.rb +1 -1
  123. data/lib/fog/slicehost/models/compute/image.rb +1 -1
  124. data/lib/fog/slicehost/models/compute/images.rb +1 -1
  125. data/lib/fog/slicehost/models/compute/server.rb +3 -1
  126. data/lib/fog/slicehost/models/compute/servers.rb +1 -1
  127. data/lib/fog/terremark/ecloud.rb +34 -33
  128. data/lib/fog/terremark/models/shared/address.rb +1 -1
  129. data/lib/fog/terremark/models/shared/network.rb +1 -1
  130. data/lib/fog/terremark/models/shared/server.rb +1 -1
  131. data/lib/fog/terremark/models/shared/servers.rb +1 -1
  132. data/lib/fog/terremark/models/shared/task.rb +1 -1
  133. data/lib/fog/terremark/models/shared/tasks.rb +1 -1
  134. data/lib/fog/terremark/models/shared/vdc.rb +1 -1
  135. data/lib/fog/terremark/parser.rb +1 -0
  136. data/lib/fog/terremark/vcloud.rb +4 -4
  137. data/lib/fog/vcloud.rb +15 -7
  138. data/lib/fog/vcloud/terremark/ecloud.rb +15 -3
  139. data/lib/fog/vcloud/terremark/ecloud/models/firewall_acls.rb +1 -1
  140. data/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb +1 -1
  141. data/lib/fog/vcloud/terremark/ecloud/models/ips.rb +1 -1
  142. data/lib/fog/vcloud/terremark/ecloud/models/networks.rb +1 -1
  143. data/lib/fog/vcloud/terremark/ecloud/models/nodes.rb +1 -1
  144. data/lib/fog/vcloud/terremark/ecloud/models/public_ips.rb +1 -1
  145. data/lib/fog/vcloud/terremark/ecloud/models/servers.rb +1 -1
  146. data/lib/fog/vcloud/terremark/ecloud/models/tasks.rb +1 -1
  147. data/lib/fog/vcloud/terremark/ecloud/models/vdcs.rb +1 -1
  148. data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +55 -49
  149. data/lib/fog/vcloud/terremark/ecloud/requests/add_node.rb +19 -15
  150. data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +8 -1
  151. data/lib/fog/vcloud/terremark/ecloud/requests/configure_node.rb +17 -12
  152. data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb +29 -1
  153. data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog_item.rb +38 -2
  154. data/lib/fog/vcloud/terremark/ecloud/requests/get_customization_options.rb +8 -2
  155. data/lib/fog/vcloud/terremark/ecloud/requests/instantiate_vapp_template.rb +46 -4
  156. data/spec/aws/models/compute/server_spec.rb +2 -0
  157. data/spec/aws/requests/simpledb/select_spec.rb +1 -0
  158. data/spec/spec_helper.rb +1 -1
  159. data/spec/vcloud/spec_helper.rb +1 -1
  160. data/spec/vcloud/terremark/ecloud/requests/get_catalog_item_spec.rb +62 -0
  161. data/spec/vcloud/terremark/ecloud/requests/get_catalog_spec.rb +44 -0
  162. data/spec/vcloud/terremark/ecloud/requests/get_customization_options_spec.rb +39 -0
  163. data/spec/vcloud/terremark/ecloud/requests/instantiate_vapp_template_spec.rb +73 -0
  164. data/tests/aws/requests/compute/address_tests.rb +2 -6
  165. data/tests/aws/requests/compute/availability_zone_tests.rb +3 -10
  166. data/tests/aws/requests/compute/image_tests.rb +4 -9
  167. data/tests/aws/requests/compute/instance_tests.rb +7 -8
  168. data/tests/aws/requests/compute/key_pair_tests.rb +2 -6
  169. data/tests/aws/requests/compute/region_tests.rb +2 -9
  170. data/tests/aws/requests/compute/security_group_tests.rb +3 -7
  171. data/tests/aws/requests/compute/snapshot_tests.rb +4 -7
  172. data/tests/aws/requests/compute/tag_tests.rb +49 -0
  173. data/tests/aws/requests/compute/volume_tests.rb +2 -6
  174. data/tests/aws/requests/storage/bucket_tests.rb +48 -0
  175. data/tests/aws/requests/storage/object_tests.rb +63 -0
  176. data/tests/bluebox/requests/compute/block_tests.rb +24 -11
  177. data/tests/bluebox/requests/compute/product_tests.rb +3 -0
  178. data/tests/bluebox/requests/compute/template_tests.rb +3 -0
  179. data/tests/go_grid/helper.rb +0 -0
  180. data/tests/go_grid/requests/compute/image_tests.rb +0 -0
  181. data/tests/helper.rb +5 -1
  182. data/tests/linode/requests/compute/datacenter_tests.rb +1 -0
  183. data/tests/linode/requests/compute/distribution_tests.rb +2 -0
  184. data/tests/linode/requests/compute/linode_tests.rb +6 -0
  185. data/tests/linode/requests/compute/linodeplans_tests.rb +2 -0
  186. data/tests/lorem.txt +1 -0
  187. data/tests/rackspace/requests/compute/flavor_tests.rb +4 -0
  188. data/tests/rackspace/requests/compute/image_tests.rb +12 -4
  189. data/tests/rackspace/requests/compute/server_tests.rb +9 -0
  190. data/tests/slicehost/requests/compute/backup_tests.rb +1 -0
  191. data/tests/slicehost/requests/compute/flavor_tests.rb +3 -0
  192. data/tests/slicehost/requests/compute/image_tests.rb +3 -0
  193. data/tests/slicehost/requests/compute/slice_tests.rb +14 -2
  194. metadata +42 -27
  195. data/spec/aws/requests/storage/delete_bucket_spec.rb +0 -35
  196. data/spec/aws/requests/storage/delete_object_spec.rb +0 -36
  197. data/spec/aws/requests/storage/get_object_spec.rb +0 -58
  198. data/spec/aws/requests/storage/get_service_spec.rb +0 -32
  199. data/spec/aws/requests/storage/head_object_spec.rb +0 -26
  200. data/spec/aws/requests/storage/put_bucket_spec.rb +0 -19
  201. data/spec/aws/requests/storage/put_object_spec.rb +0 -43
@@ -8,8 +8,8 @@ module Fog
8
8
  # Describe all or specified snapshots
9
9
  #
10
10
  # ==== Parameters
11
- # * snapshot_id<~Array> - List of snapshots to describe, defaults to all
12
- # * options<~Array>:
11
+ # * filters<~Hash> - List of filters to limit results with
12
+ # * options<~Hash>:
13
13
  # * 'Owner'<~String> - Owner of snapshot in ['self', 'amazon', account_id]
14
14
  # * 'RestorableBy'<~String> - Account id of user who can create volumes from this snapshot
15
15
  #
@@ -23,55 +23,92 @@ module Fog
23
23
  # * 'startTime'<~Time>: Timestamp of when snapshot was initiated
24
24
  # * 'status'<~String>: Snapshot state, in ['pending', 'completed']
25
25
  # * 'volumeId'<~String>: Id of volume that snapshot contains
26
- def describe_snapshots(snapshot_id = [], options = {})
27
- options['Owner'] ||= 'self'
28
- options.merge!(AWS.indexed_param('SnapshotId', snapshot_id))
26
+ def describe_snapshots(filters = {}, options = {})
27
+ unless filters.is_a?(Hash)
28
+ Formatador.display_line("[yellow][WARN] describe_snapshots with #{filters.class} param is deprecated, use describe_snapshots('snapshot-id' => []) instead[/] [light_black](#{caller.first})[/]")
29
+ filters = {'snapshot-id' => [*filters]}
30
+ end
31
+ unless options.empty?
32
+ Formatador.display_line("[yellow][WARN] describe_snapshots with a second param is deprecated, use describe_snapshots(options) instead[/] [light_black](#{caller.first})[/]")
33
+ end
34
+
35
+ for key in ['ExecutableBy', 'ImageId', 'Owner', 'RestorableBy']
36
+ if filters.has_key?(key)
37
+ options[key] = filters.delete(key)
38
+ end
39
+ end
40
+ options['RestorableBy'] ||= 'self'
41
+ params = AWS.indexed_filters(filters).merge!(options)
29
42
  request({
30
43
  'Action' => 'DescribeSnapshots',
31
44
  :idempotent => true,
32
45
  :parser => Fog::Parsers::AWS::Compute::DescribeSnapshots.new
33
- }.merge!(options))
46
+ }.merge!(params))
34
47
  end
35
48
 
36
49
  end
37
50
 
38
51
  class Mock
39
52
 
40
- def describe_snapshots(snapshot_id = [])
53
+ def describe_snapshots(filters = {}, options = {})
54
+ unless filters.is_a?(Hash)
55
+ Formatador.display_line("[yellow][WARN] describe_snapshots with #{filters.class} param is deprecated, use describe_snapshots('snapshot-id' => []) instead[/] [light_black](#{caller.first})[/]")
56
+ filters = {'snapshot-id' => [*filters]}
57
+ end
58
+ unless options.empty?
59
+ Formatador.display_line("[yellow][WARN] describe_snapshots with a second param is deprecated, use describe_snapshots(options) instead[/] [light_black](#{caller.first})[/]")
60
+ end
61
+
62
+ if filters.keys.any? {|key| key =~ /^tag/}
63
+ Formatador.display_line("[yellow][WARN] describe_snapshots tag filters are not yet mocked[/] [light_black](#{caller.first})[/]")
64
+ Fog::Mock.not_implemented
65
+ end
66
+
41
67
  response = Excon::Response.new
42
- snapshot_id = [*snapshot_id]
43
- if snapshot_id != []
44
- snapshot_set = @data[:snapshots].reject {|key,value| !snapshot_id.include?(key)}.values
45
- else
46
- snapshot_set = @data[:snapshots].values
68
+
69
+ snapshot_set = @data[:snapshots].values
70
+
71
+ if filters.delete('owner-alias')
72
+ Formatador.display_line("[yellow][WARN] describe_snapshots with owner-alias is not mocked[/] [light_black](#{caller.first})[/]")
47
73
  end
48
74
 
49
- if snapshot_id.length == 0 || snapshot_id.length == snapshot_set.length
50
- snapshot_set.each do |snapshot|
51
- case snapshot['status']
52
- when 'in progress', 'pending'
53
- if Time.now - snapshot['startTime'] > Fog::Mock.delay * 2
54
- snapshot['progress'] = '100%'
55
- snapshot['status'] = 'completed'
56
- elsif Time.now - snapshot['startTime'] > Fog::Mock.delay
57
- snapshot['progress'] = '50%'
58
- snapshot['status'] = 'in progress'
59
- else
60
- snapshot['progress'] = '0%'
61
- snapshot['status'] = 'in progress'
62
- end
75
+ aliases = {
76
+ 'description' => 'description',
77
+ 'owner-id' => 'ownerId',
78
+ 'progress' => 'progress',
79
+ 'snapshot-id' => 'snapshotId',
80
+ 'start-time' => 'startTime',
81
+ 'status' => 'status',
82
+ 'volume-id' => 'volumeId',
83
+ 'volume-size' => 'volumeSize'
84
+ }
85
+ for filter_key, filter_value in filters
86
+ aliased_key = aliases[filter_key]
87
+ snapshot_set = snapshot_set.reject{|snapshot| ![*filter_value].include?(snapshot[aliased_key])}
88
+ end
89
+
90
+ snapshot_set.each do |snapshot|
91
+ case snapshot['status']
92
+ when 'in progress', 'pending'
93
+ if Time.now - snapshot['startTime'] > Fog::Mock.delay * 2
94
+ snapshot['progress'] = '100%'
95
+ snapshot['status'] = 'completed'
96
+ elsif Time.now - snapshot['startTime'] > Fog::Mock.delay
97
+ snapshot['progress'] = '50%'
98
+ snapshot['status'] = 'in progress'
99
+ else
100
+ snapshot['progress'] = '0%'
101
+ snapshot['status'] = 'in progress'
63
102
  end
64
103
  end
65
-
66
- response.status = 200
67
- response.body = {
68
- 'requestId' => Fog::AWS::Mock.request_id,
69
- 'snapshotSet' => snapshot_set
70
- }
71
- response
72
- else
73
- raise Fog::AWS::Compute::NotFound.new("The snapshot #{snapshot_id.inspect} does not exist.")
74
104
  end
105
+
106
+ response.status = 200
107
+ response.body = {
108
+ 'requestId' => Fog::AWS::Mock.request_id,
109
+ 'snapshotSet' => snapshot_set
110
+ }
111
+ response
75
112
  end
76
113
 
77
114
  end
@@ -0,0 +1,42 @@
1
+ module Fog
2
+ module AWS
3
+ class Compute
4
+ class Real
5
+
6
+ require 'fog/aws/parsers/compute/describe_tags'
7
+
8
+ # Describe all or specified tags
9
+ #
10
+ # ==== Parameters
11
+ # * filters<~Hash> - List of filters to limit results with
12
+ #
13
+ # === Returns
14
+ # * response<~Excon::Response>:
15
+ # * body<~Hash>:
16
+ # * 'requestId'<~String> - Id of request
17
+ # * 'tagSet'<~Array>:
18
+ # * 'resourceId'<~String> - id of resource tag belongs to
19
+ # * 'resourceType'<~String> - type of resource tag belongs to
20
+ # * 'key'<~String> - Tag's key
21
+ # * 'value'<~String> - Tag's value
22
+ def describe_tags(filters = {})
23
+ params = AWS.indexed_filters(filters)
24
+ request({
25
+ 'Action' => 'DescribeTags',
26
+ :idempotent => true,
27
+ :parser => Fog::Parsers::AWS::Compute::DescribeTags.new
28
+ }.merge!(params))
29
+ end
30
+
31
+ end
32
+
33
+ class Mock
34
+
35
+ def describe_tags(filters = {})
36
+ Fog::Mock.not_implemented
37
+ end
38
+
39
+ end
40
+ end
41
+ end
42
+ end
@@ -8,7 +8,7 @@ module Fog
8
8
  # Describe all or specified volumes.
9
9
  #
10
10
  # ==== Parameters
11
- # * volume_id<~Array> - List of volumes to describe, defaults to all
11
+ # * filters<~Hash> - List of filters to limit results with
12
12
  #
13
13
  # ==== Returns
14
14
  # * response<~Excon::Response>:
@@ -26,8 +26,12 @@ module Fog
26
26
  # * 'instanceId'<~String> - Reference to attached instance
27
27
  # * 'status'<~String> - Attachment state
28
28
  # * 'volumeId'<~String> - Reference to volume
29
- def describe_volumes(volume_id = [])
30
- params = AWS.indexed_param('VolumeId', volume_id)
29
+ def describe_volumes(filters = {})
30
+ unless filters.is_a?(Hash)
31
+ Formatador.display_line("[yellow][WARN] describe_volumes with #{filters.class} param is deprecated, use describe_volumes('volume-id' => []) instead[/] [light_black](#{caller.first})[/]")
32
+ filters = {'volume-id' => [*filters]}
33
+ end
34
+ params = AWS.indexed_filters(filters)
31
35
  request({
32
36
  'Action' => 'DescribeVolumes',
33
37
  :idempotent => true,
@@ -39,45 +43,72 @@ module Fog
39
43
 
40
44
  class Mock
41
45
 
42
- def describe_volumes(volume_id = [])
46
+ def describe_volumes(filters = {})
47
+ unless filters.is_a?(Hash)
48
+ Formatador.display_line("[yellow][WARN] describe_volumes with #{filters.class} param is deprecated, use describe_volumes('volume-id' => []) instead[/] [light_black](#{caller.first})[/]")
49
+ filters = {'volume-id' => [*filters]}
50
+ end
51
+
52
+ if filters.keys.any? {|key| key =~ /^tag/}
53
+ Formatador.display_line("[yellow][WARN] describe_volumes tag filters are not yet mocked[/] [light_black](#{caller.first})[/]")
54
+ Fog::Mock.not_implemented
55
+ end
56
+
43
57
  response = Excon::Response.new
44
- volume_id = [*volume_id]
45
- if volume_id != []
46
- volume_set = @data[:volumes].reject {|key,value| !volume_id.include?(key)}.values
47
- else
48
- volume_set = @data[:volumes].values
58
+
59
+ volume_set = @data[:volumes].values
60
+
61
+ aliases = {
62
+ 'availability-zone' => 'availabilityZone',
63
+ 'create-time' => 'createTime',
64
+ 'size' => 'size',
65
+ 'snapshot-id' => 'snapshotId',
66
+ 'status' => 'status',
67
+ 'volume-id' => 'volumeId'
68
+ }
69
+ attachment_aliases = {
70
+ 'attach-time' => 'attachTime',
71
+ 'delete-on-termination' => 'deleteOnTermination',
72
+ 'device' => 'device',
73
+ 'instance-id' => 'instanceId',
74
+ 'status' => 'status'
75
+ }
76
+ for filter_key, filter_value in filters
77
+ if attachment_key = filter_key.split('attachment.')[1]
78
+ aliased_key = permission_aliases[filter_key]
79
+ volume_set = volume_set.reject{|volume| !volume['attachmentSet'].detect {|attachment| [*filter_value].include?(attachment[aliased_key])}}
80
+ else
81
+ aliased_key = aliases[filter_key]
82
+ volume_set = volume_set.reject{|volume| ![*filter_value].include?(volume[aliased_key])}
83
+ end
49
84
  end
50
85
 
51
- if volume_id.length == 0 || volume_id.length == volume_set.length
52
- volume_set.each do |volume|
53
- case volume['status']
54
- when 'attaching'
55
- if Time.now - volume['attachmentSet'].first['attachTime'] > Fog::Mock.delay
56
- volume['attachmentSet'].first['status'] = 'in-use'
57
- volume['status'] = 'in-use'
58
- end
59
- when 'creating'
60
- if Time.now - volume['createTime'] > Fog::Mock.delay
61
- volume['status'] = 'available'
62
- end
63
- when 'deleting'
64
- if Time.now - @data[:deleted_at][volume['volumeId']] > Fog::Mock.delay
65
- @data[:deleted_at].delete(volume['volumeId'])
66
- @data[:volumes].delete(volume['volumeId'])
67
- end
86
+ volume_set.each do |volume|
87
+ case volume['status']
88
+ when 'attaching'
89
+ if Time.now - volume['attachmentSet'].first['attachTime'] > Fog::Mock.delay
90
+ volume['attachmentSet'].first['status'] = 'in-use'
91
+ volume['status'] = 'in-use'
92
+ end
93
+ when 'creating'
94
+ if Time.now - volume['createTime'] > Fog::Mock.delay
95
+ volume['status'] = 'available'
96
+ end
97
+ when 'deleting'
98
+ if Time.now - @data[:deleted_at][volume['volumeId']] > Fog::Mock.delay
99
+ @data[:deleted_at].delete(volume['volumeId'])
100
+ @data[:volumes].delete(volume['volumeId'])
68
101
  end
69
102
  end
70
-
71
- volume_set = volume_set.reject {|volume| !@data[:volumes][volume['volumeId']]}
72
- response.status = 200
73
- response.body = {
74
- 'requestId' => Fog::AWS::Mock.request_id,
75
- 'volumeSet' => volume_set
76
- }
77
- response
78
- else
79
- raise Fog::AWS::Compute::NotFound.new("The volume #{volume_id.inspect} does not exist.")
80
103
  end
104
+ volume_set = volume_set.reject {|volume| !@data[:volumes][volume['volumeId']]}
105
+
106
+ response.status = 200
107
+ response.body = {
108
+ 'requestId' => Fog::AWS::Mock.request_id,
109
+ 'volumeSet' => volume_set
110
+ }
111
+ response
81
112
  end
82
113
 
83
114
  end
@@ -34,7 +34,7 @@ module Fog
34
34
  # default is 'm1.small'
35
35
  # * 'KernelId'<~String> - Id of kernel with which to launch
36
36
  # * 'KeyName'<~String> - Name of a keypair to add to booting instances
37
- # * 'Monitoring.Enabled'<~Boolean> - Enables monitoring, defaults to
37
+ # * 'Monitoring.Enabled'<~Boolean> - Enables monitoring, defaults to
38
38
  # disabled
39
39
  # * 'RamdiskId'<~String> - Id of ramdisk with which to launch
40
40
  # * 'UserData'<~String> - Additional data to provide to booting instances
@@ -87,17 +87,21 @@ module Fog
87
87
  end
88
88
  end
89
89
  end
90
- if security_groups = [*options.delete('SecurityGroup')]
91
- options.merge!(AWS.indexed_param('SecurityGroup', security_groups))
90
+ if security_groups = options.delete('SecurityGroup')
91
+ options.merge!(AWS.indexed_param('SecurityGroup', [*security_groups]))
92
92
  end
93
93
  if options['UserData']
94
94
  options['UserData'] = Base64.encode64(options['UserData'])
95
95
  end
96
+
97
+ idempotent = !(options['ClientToken'].nil? || options['ClientToken'].empty?)
98
+
96
99
  request({
97
100
  'Action' => 'RunInstances',
98
101
  'ImageId' => image_id,
99
102
  'MinCount' => min_count,
100
103
  'MaxCount' => max_count,
104
+ :idempotent => idempotent,
101
105
  :parser => Fog::Parsers::AWS::Compute::RunInstances.new
102
106
  }.merge!(options))
103
107
  end
@@ -119,6 +123,7 @@ module Fog
119
123
  instance = {
120
124
  'amiLaunchIndex' => i,
121
125
  'blockDeviceMapping' => [],
126
+ 'clientToken' => options['clientToken'],
122
127
  'dnsName' => nil,
123
128
  'imageId' => image_id,
124
129
  'instanceId' => instance_id,
@@ -142,6 +147,8 @@ module Fog
142
147
  'ownerId' => @owner_id,
143
148
  'privateIpAddress' => nil,
144
149
  'reservationId' => reservation_id,
150
+ 'stateReason' => {},
151
+ 'tagSet' => {}
145
152
  })
146
153
  end
147
154
  response.body = {
@@ -63,9 +63,10 @@ module Fog
63
63
  @hmac = Fog::HMAC.new('sha256', @aws_secret_access_key)
64
64
  @host = options[:host] || 'sdb.amazonaws.com'
65
65
  @nil_string = options[:nil_string]|| 'nil'
66
+ @path = options[:path] || '/'
66
67
  @port = options[:port] || 443
67
68
  @scheme = options[:scheme] || 'https'
68
- @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
69
+ @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent])
69
70
  end
70
71
 
71
72
  private
@@ -137,6 +138,7 @@ module Fog
137
138
  :aws_access_key_id => @aws_access_key_id,
138
139
  :hmac => @hmac,
139
140
  :host => @host,
141
+ :path => @path,
140
142
  :version => '2009-04-15'
141
143
  }
142
144
  )
@@ -75,8 +75,8 @@ module Fog
75
75
 
76
76
  def self.data
77
77
  @data ||= Hash.new do |hash, region|
78
- hash[region] = Hash.new do |hash, key|
79
- hash[key] = {
78
+ hash[region] = Hash.new do |region_hash, key|
79
+ region_hash[key] = {
80
80
  :buckets => {}
81
81
  }
82
82
  end
@@ -138,8 +138,15 @@ module Fog
138
138
  @aws_access_key_id = options[:aws_access_key_id]
139
139
  @aws_secret_access_key = options[:aws_secret_access_key]
140
140
  @hmac = Fog::HMAC.new('sha1', @aws_secret_access_key)
141
- options[:region] ||= 'us-east-1'
142
- @host = options[:host] || case options[:region]
141
+ if @endpoint = options[:endpoint]
142
+ endpoint = URI.parse(@endpoint)
143
+ @host = endpoint.host
144
+ @path = endpoint.path
145
+ @port = endpoint.port
146
+ @scheme = endpoint.scheme
147
+ else
148
+ options[:region] ||= 'us-east-1'
149
+ @host = options[:host] || case options[:region]
143
150
  when 'eu-west-1'
144
151
  's3-eu-west-1.amazonaws.com'
145
152
  when 'us-east-1'
@@ -151,9 +158,11 @@ module Fog
151
158
  else
152
159
  raise ArgumentError, "Unknown region: #{options[:region].inspect}"
153
160
  end
154
- @port = options[:port] || 443
155
- @scheme = options[:scheme] || 'https'
156
- @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent] || true)
161
+ @path = options[:path] || '/'
162
+ @port = options[:port] || 443
163
+ @scheme = options[:scheme] || 'https'
164
+ end
165
+ @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent] || true)
157
166
  end
158
167
 
159
168
  def reload
@@ -213,7 +222,7 @@ DATA
213
222
  subdomain = nil
214
223
  end
215
224
 
216
- canonical_resource = "/"
225
+ canonical_resource = @path.dup
217
226
  unless subdomain.nil? || subdomain == @host
218
227
  canonical_resource << "#{CGI.escape(subdomain).downcase}/"
219
228
  end
@@ -1,4 +1,4 @@
1
- require 'fog/model'
1
+ require 'fog/core/model'
2
2
 
3
3
  module Fog
4
4
  module Bluebox
@@ -1,4 +1,4 @@
1
- require 'fog/collection'
1
+ require 'fog/core/collection'
2
2
  require 'fog/bluebox/models/compute/flavor'
3
3
 
4
4
  module Fog
@@ -1,4 +1,4 @@
1
- require 'fog/model'
1
+ require 'fog/core/model'
2
2
 
3
3
  module Fog
4
4
  module Bluebox