fog 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +6 -6
- data/README.rdoc +7 -1
- data/bin/fog +4 -3
- data/fog.gemspec +39 -24
- data/lib/fog.rb +4 -12
- data/lib/fog/aws.rb +14 -5
- data/lib/fog/aws/compute.rb +26 -9
- data/lib/fog/aws/elb.rb +3 -2
- data/lib/fog/aws/models/compute/address.rb +2 -1
- data/lib/fog/aws/models/compute/addresses.rb +11 -9
- data/lib/fog/aws/models/compute/flavor.rb +1 -1
- data/lib/fog/aws/models/compute/flavors.rb +13 -11
- data/lib/fog/aws/models/compute/image.rb +2 -1
- data/lib/fog/aws/models/compute/images.rb +7 -9
- data/lib/fog/aws/models/compute/key_pair.rb +1 -1
- data/lib/fog/aws/models/compute/key_pairs.rb +10 -8
- data/lib/fog/aws/models/compute/security_group.rb +1 -1
- data/lib/fog/aws/models/compute/security_groups.rb +11 -9
- data/lib/fog/aws/models/compute/server.rb +10 -3
- data/lib/fog/aws/models/compute/servers.rb +14 -8
- data/lib/fog/aws/models/compute/snapshot.rb +3 -2
- data/lib/fog/aws/models/compute/snapshots.rb +11 -16
- data/lib/fog/aws/models/compute/tag.rb +36 -0
- data/lib/fog/aws/models/compute/tags.rb +34 -0
- data/lib/fog/aws/models/compute/volume.rb +11 -10
- data/lib/fog/aws/models/compute/volumes.rb +11 -9
- data/lib/fog/aws/models/storage/directories.rb +1 -1
- data/lib/fog/aws/models/storage/directory.rb +1 -1
- data/lib/fog/aws/models/storage/file.rb +3 -2
- data/lib/fog/aws/models/storage/files.rb +1 -7
- data/lib/fog/aws/parsers/compute/describe_availability_zones.rb +4 -2
- data/lib/fog/aws/parsers/compute/describe_images.rb +23 -13
- data/lib/fog/aws/parsers/compute/describe_instances.rb +34 -8
- data/lib/fog/aws/parsers/compute/describe_security_groups.rb +4 -3
- data/lib/fog/aws/parsers/compute/describe_snapshots.rb +33 -13
- data/lib/fog/aws/parsers/compute/describe_tags.rb +30 -0
- data/lib/fog/aws/parsers/compute/describe_volumes.rb +17 -3
- data/lib/fog/aws/parsers/compute/run_instances.rb +4 -4
- data/lib/fog/aws/parsers/storage/get_bucket.rb +1 -1
- data/lib/fog/aws/parsers/storage/get_bucket_logging.rb +1 -1
- data/lib/fog/aws/parsers/storage/get_bucket_object_versions.rb +3 -3
- data/lib/fog/aws/requests/compute/create_snapshot.rb +1 -0
- data/lib/fog/aws/requests/compute/create_tags.rb +78 -0
- data/lib/fog/aws/requests/compute/delete_tags.rb +45 -0
- data/lib/fog/aws/requests/compute/describe_addresses.rb +27 -19
- data/lib/fog/aws/requests/compute/describe_availability_zones.rb +31 -25
- data/lib/fog/aws/requests/compute/describe_images.rb +11 -18
- data/lib/fog/aws/requests/compute/describe_instances.rb +125 -53
- data/lib/fog/aws/requests/compute/describe_key_pairs.rb +29 -21
- data/lib/fog/aws/requests/compute/describe_regions.rb +28 -23
- data/lib/fog/aws/requests/compute/describe_reserved_instances.rb +8 -4
- data/lib/fog/aws/requests/compute/describe_security_groups.rb +48 -19
- data/lib/fog/aws/requests/compute/describe_snapshots.rb +72 -35
- data/lib/fog/aws/requests/compute/describe_tags.rb +42 -0
- data/lib/fog/aws/requests/compute/describe_volumes.rb +67 -36
- data/lib/fog/aws/requests/compute/run_instances.rb +10 -3
- data/lib/fog/aws/simpledb.rb +3 -1
- data/lib/fog/aws/storage.rb +17 -8
- data/lib/fog/bluebox/models/compute/flavor.rb +1 -1
- data/lib/fog/bluebox/models/compute/flavors.rb +1 -1
- data/lib/fog/bluebox/models/compute/image.rb +1 -1
- data/lib/fog/bluebox/models/compute/images.rb +1 -1
- data/lib/fog/bluebox/models/compute/server.rb +8 -6
- data/lib/fog/bluebox/models/compute/servers.rb +1 -1
- data/lib/fog/bluebox/requests/compute/get_blocks.rb +1 -1
- data/lib/fog/core.rb +11 -0
- data/lib/fog/{attributes.rb → core/attributes.rb} +0 -0
- data/lib/fog/{bin.rb → core/bin.rb} +1 -1
- data/lib/fog/{collection.rb → core/collection.rb} +4 -0
- data/lib/fog/{connection.rb → core/connection.rb} +0 -0
- data/lib/fog/{credentials.rb → core/credentials.rb} +2 -0
- data/lib/fog/{deprecation.rb → core/deprecation.rb} +0 -0
- data/lib/fog/{errors.rb → core/errors.rb} +0 -0
- data/lib/fog/{hmac.rb → core/hmac.rb} +0 -0
- data/lib/fog/{model.rb → core/model.rb} +0 -0
- data/lib/fog/{parser.rb → core/parser.rb} +0 -0
- data/lib/fog/{provider.rb → core/provider.rb} +0 -0
- data/lib/fog/{service.rb → core/service.rb} +1 -0
- data/lib/fog/{ssh.rb → core/ssh.rb} +7 -7
- data/lib/fog/go_grid.rb +1 -1
- data/lib/fog/go_grid/compute.rb +6 -1
- data/lib/fog/go_grid/models/compute/image.rb +60 -0
- data/lib/fog/go_grid/models/compute/images.rb +33 -0
- data/lib/fog/go_grid/models/compute/server.rb +56 -0
- data/lib/fog/go_grid/models/compute/servers.rb +35 -0
- data/lib/fog/go_grid/requests/compute/grid_image_get.rb +41 -0
- data/lib/fog/go_grid/requests/compute/grid_image_list.rb +6 -1
- data/lib/fog/go_grid/requests/compute/grid_server_power.rb +2 -2
- data/lib/fog/google/models/storage/directories.rb +1 -1
- data/lib/fog/google/models/storage/directory.rb +1 -1
- data/lib/fog/google/models/storage/file.rb +3 -2
- data/lib/fog/google/models/storage/files.rb +1 -7
- data/lib/fog/google/parsers/storage/get_bucket.rb +1 -1
- data/lib/fog/linode/requests/compute/avail_linodeplans.rb +2 -2
- data/lib/fog/local/models/storage/directories.rb +1 -1
- data/lib/fog/local/models/storage/directory.rb +1 -1
- data/lib/fog/local/models/storage/file.rb +2 -2
- data/lib/fog/local/models/storage/files.rb +2 -5
- data/lib/fog/local/storage.rb +1 -1
- data/lib/fog/new_servers/compute.rb +1 -1
- data/lib/fog/rackspace/models/compute/flavor.rb +1 -3
- data/lib/fog/rackspace/models/compute/flavors.rb +1 -1
- data/lib/fog/rackspace/models/compute/image.rb +2 -1
- data/lib/fog/rackspace/models/compute/images.rb +1 -1
- data/lib/fog/rackspace/models/compute/server.rb +12 -11
- data/lib/fog/rackspace/models/compute/servers.rb +1 -1
- data/lib/fog/rackspace/models/storage/directories.rb +1 -1
- data/lib/fog/rackspace/models/storage/directory.rb +1 -1
- data/lib/fog/rackspace/models/storage/file.rb +4 -4
- data/lib/fog/rackspace/models/storage/files.rb +1 -1
- data/lib/fog/rackspace/requests/compute/create_image.rb +2 -2
- data/lib/fog/rackspace/requests/compute/delete_image.rb +1 -1
- data/lib/fog/rackspace/requests/compute/delete_server.rb +1 -1
- data/lib/fog/rackspace/requests/compute/get_server_details.rb +1 -1
- data/lib/fog/rackspace/requests/compute/list_addresses.rb +1 -1
- data/lib/fog/rackspace/requests/compute/list_images_detail.rb +2 -2
- data/lib/fog/rackspace/requests/compute/list_private_addresses.rb +1 -1
- data/lib/fog/rackspace/requests/compute/list_public_addresses.rb +1 -1
- data/lib/fog/rackspace/requests/compute/update_server.rb +1 -1
- data/lib/fog/rackspace/requests/storage/put_object.rb +4 -3
- data/lib/fog/slicehost/models/compute/flavor.rb +1 -1
- data/lib/fog/slicehost/models/compute/flavors.rb +1 -1
- data/lib/fog/slicehost/models/compute/image.rb +1 -1
- data/lib/fog/slicehost/models/compute/images.rb +1 -1
- data/lib/fog/slicehost/models/compute/server.rb +3 -1
- data/lib/fog/slicehost/models/compute/servers.rb +1 -1
- data/lib/fog/terremark/ecloud.rb +34 -33
- data/lib/fog/terremark/models/shared/address.rb +1 -1
- data/lib/fog/terremark/models/shared/network.rb +1 -1
- data/lib/fog/terremark/models/shared/server.rb +1 -1
- data/lib/fog/terremark/models/shared/servers.rb +1 -1
- data/lib/fog/terremark/models/shared/task.rb +1 -1
- data/lib/fog/terremark/models/shared/tasks.rb +1 -1
- data/lib/fog/terremark/models/shared/vdc.rb +1 -1
- data/lib/fog/terremark/parser.rb +1 -0
- data/lib/fog/terremark/vcloud.rb +4 -4
- data/lib/fog/vcloud.rb +15 -7
- data/lib/fog/vcloud/terremark/ecloud.rb +15 -3
- data/lib/fog/vcloud/terremark/ecloud/models/firewall_acls.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/ips.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/networks.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/nodes.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/public_ips.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/servers.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/tasks.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/vdcs.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +55 -49
- data/lib/fog/vcloud/terremark/ecloud/requests/add_node.rb +19 -15
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +8 -1
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_node.rb +17 -12
- data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb +29 -1
- data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog_item.rb +38 -2
- data/lib/fog/vcloud/terremark/ecloud/requests/get_customization_options.rb +8 -2
- data/lib/fog/vcloud/terremark/ecloud/requests/instantiate_vapp_template.rb +46 -4
- data/spec/aws/models/compute/server_spec.rb +2 -0
- data/spec/aws/requests/simpledb/select_spec.rb +1 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/vcloud/spec_helper.rb +1 -1
- data/spec/vcloud/terremark/ecloud/requests/get_catalog_item_spec.rb +62 -0
- data/spec/vcloud/terremark/ecloud/requests/get_catalog_spec.rb +44 -0
- data/spec/vcloud/terremark/ecloud/requests/get_customization_options_spec.rb +39 -0
- data/spec/vcloud/terremark/ecloud/requests/instantiate_vapp_template_spec.rb +73 -0
- data/tests/aws/requests/compute/address_tests.rb +2 -6
- data/tests/aws/requests/compute/availability_zone_tests.rb +3 -10
- data/tests/aws/requests/compute/image_tests.rb +4 -9
- data/tests/aws/requests/compute/instance_tests.rb +7 -8
- data/tests/aws/requests/compute/key_pair_tests.rb +2 -6
- data/tests/aws/requests/compute/region_tests.rb +2 -9
- data/tests/aws/requests/compute/security_group_tests.rb +3 -7
- data/tests/aws/requests/compute/snapshot_tests.rb +4 -7
- data/tests/aws/requests/compute/tag_tests.rb +49 -0
- data/tests/aws/requests/compute/volume_tests.rb +2 -6
- data/tests/aws/requests/storage/bucket_tests.rb +48 -0
- data/tests/aws/requests/storage/object_tests.rb +63 -0
- data/tests/bluebox/requests/compute/block_tests.rb +24 -11
- data/tests/bluebox/requests/compute/product_tests.rb +3 -0
- data/tests/bluebox/requests/compute/template_tests.rb +3 -0
- data/tests/go_grid/helper.rb +0 -0
- data/tests/go_grid/requests/compute/image_tests.rb +0 -0
- data/tests/helper.rb +5 -1
- data/tests/linode/requests/compute/datacenter_tests.rb +1 -0
- data/tests/linode/requests/compute/distribution_tests.rb +2 -0
- data/tests/linode/requests/compute/linode_tests.rb +6 -0
- data/tests/linode/requests/compute/linodeplans_tests.rb +2 -0
- data/tests/lorem.txt +1 -0
- data/tests/rackspace/requests/compute/flavor_tests.rb +4 -0
- data/tests/rackspace/requests/compute/image_tests.rb +12 -4
- data/tests/rackspace/requests/compute/server_tests.rb +9 -0
- data/tests/slicehost/requests/compute/backup_tests.rb +1 -0
- data/tests/slicehost/requests/compute/flavor_tests.rb +3 -0
- data/tests/slicehost/requests/compute/image_tests.rb +3 -0
- data/tests/slicehost/requests/compute/slice_tests.rb +14 -2
- metadata +42 -27
- data/spec/aws/requests/storage/delete_bucket_spec.rb +0 -35
- data/spec/aws/requests/storage/delete_object_spec.rb +0 -36
- data/spec/aws/requests/storage/get_object_spec.rb +0 -58
- data/spec/aws/requests/storage/get_service_spec.rb +0 -32
- data/spec/aws/requests/storage/head_object_spec.rb +0 -26
- data/spec/aws/requests/storage/put_bucket_spec.rb +0 -19
- 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
|
-
# *
|
12
|
-
# * options<~
|
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(
|
27
|
-
|
28
|
-
|
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!(
|
46
|
+
}.merge!(params))
|
34
47
|
end
|
35
48
|
|
36
49
|
end
|
37
50
|
|
38
51
|
class Mock
|
39
52
|
|
40
|
-
def describe_snapshots(
|
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
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
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
|
-
# *
|
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(
|
30
|
-
|
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(
|
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
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
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 =
|
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 = {
|
data/lib/fog/aws/simpledb.rb
CHANGED
@@ -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
|
)
|
data/lib/fog/aws/storage.rb
CHANGED
@@ -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 |
|
79
|
-
|
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[:
|
142
|
-
|
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
|
-
|
155
|
-
|
156
|
-
|
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
|