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
@@ -0,0 +1,30 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module AWS
|
4
|
+
module Compute
|
5
|
+
|
6
|
+
class DescribeTags < Fog::Parsers::Base
|
7
|
+
|
8
|
+
def reset
|
9
|
+
@tag = {}
|
10
|
+
@response = { 'tagSet' => [] }
|
11
|
+
end
|
12
|
+
|
13
|
+
def end_element(name)
|
14
|
+
case name
|
15
|
+
when 'resourceId', 'resourceType', 'key', 'value'
|
16
|
+
@tag[name] = @value
|
17
|
+
when 'item'
|
18
|
+
@response['tagSet'] << @tag
|
19
|
+
@tag = {}
|
20
|
+
when 'requestId'
|
21
|
+
@response[name] = @value
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -9,13 +9,17 @@ module Fog
|
|
9
9
|
@attachment = {}
|
10
10
|
@in_attachment_set = false
|
11
11
|
@response = { 'volumeSet' => [] }
|
12
|
-
@
|
12
|
+
@tag = {}
|
13
|
+
@volume = { 'attachmentSet' => [], 'tagSet' => {} }
|
13
14
|
end
|
14
15
|
|
15
16
|
def start_element(name, attrs = [])
|
16
17
|
super
|
17
|
-
|
18
|
+
case name
|
19
|
+
when 'attachmentSet'
|
18
20
|
@in_attachment_set = true
|
21
|
+
when 'tagSet'
|
22
|
+
@in_tag_set = true
|
19
23
|
end
|
20
24
|
end
|
21
25
|
|
@@ -32,6 +36,16 @@ module Fog
|
|
32
36
|
@volume['attachmentSet'] << @attachment
|
33
37
|
@attachment = {}
|
34
38
|
end
|
39
|
+
elsif @in_tag_set
|
40
|
+
case name
|
41
|
+
when 'key', 'value'
|
42
|
+
@tag[name] = @value
|
43
|
+
when 'item'
|
44
|
+
@volume['tagSet'][@tag['key']] = @tag['value']
|
45
|
+
@tag = {}
|
46
|
+
when 'tagSet'
|
47
|
+
@in_tag_set = false
|
48
|
+
end
|
35
49
|
else
|
36
50
|
case name
|
37
51
|
when 'availabilityZone', 'snapshotId', 'status', 'volumeId'
|
@@ -40,7 +54,7 @@ module Fog
|
|
40
54
|
@volume[name] = Time.parse(@value)
|
41
55
|
when 'item'
|
42
56
|
@response['volumeSet'] << @volume
|
43
|
-
@volume = { 'attachmentSet' => [] }
|
57
|
+
@volume = { 'attachmentSet' => [], 'tagSet' => {} }
|
44
58
|
when 'requestId'
|
45
59
|
@response[name] = @value
|
46
60
|
when 'size'
|
@@ -27,10 +27,10 @@ module Fog
|
|
27
27
|
case name
|
28
28
|
when 'amiLaunchIndex'
|
29
29
|
@instance[name] = @value.to_i
|
30
|
-
when 'architecture', '
|
31
|
-
'
|
32
|
-
'
|
33
|
-
'rootDeviceType'
|
30
|
+
when 'architecture', 'clientToken', 'dnsName', 'imageId',
|
31
|
+
'instanceId', 'instanceType', 'ipAddress', 'kernelId',
|
32
|
+
'keyName', 'privateDnsName', 'privateIpAddress', 'ramdiskId',
|
33
|
+
'reason', 'rootDeviceType'
|
34
34
|
@instance[name] = @value
|
35
35
|
when 'availabilityZone'
|
36
36
|
@instance['placement'][name] = @value
|
@@ -65,17 +65,17 @@ module Fog
|
|
65
65
|
elsif @in_version
|
66
66
|
@version
|
67
67
|
end['LastModified'] = Time.parse(@value)
|
68
|
-
when 'KeyMarker', 'Name', 'Prefix', 'VersionIdMarker'
|
69
|
-
@response[name] = @value
|
70
68
|
when 'MaxKeys'
|
71
69
|
@response['MaxKeys'] = @value.to_i
|
72
70
|
when 'Size'
|
73
71
|
@version['Size'] = @value.to_i
|
74
|
-
when 'Key', 'Name', 'StorageClass', 'VersionId'
|
72
|
+
when 'Key', 'KeyMarker', 'Name', 'Prefix', 'StorageClass', 'VersionId', 'VersionIdMarker'
|
75
73
|
if @in_delete_marker
|
76
74
|
@delete_marker
|
77
75
|
elsif @in_version
|
78
76
|
@version
|
77
|
+
else
|
78
|
+
@response
|
79
79
|
end[name] = @value
|
80
80
|
end
|
81
81
|
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
|
6
|
+
# Adds tags to resources
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# * resources<~String> - One or more resources to tag
|
10
|
+
# * tags<~String> - hash of key value tag pairs to assign
|
11
|
+
#
|
12
|
+
# ==== Returns
|
13
|
+
# * response<~Excon::Response>:
|
14
|
+
# * body<~Hash>:
|
15
|
+
# * 'requestId'<~String> - Id of request
|
16
|
+
# * 'return'<~Boolean> - success?
|
17
|
+
def create_tags(resources, tags)
|
18
|
+
resources = [*resources]
|
19
|
+
for key, value in tags
|
20
|
+
if value.nil?
|
21
|
+
tags[key] = ''
|
22
|
+
end
|
23
|
+
end
|
24
|
+
params = {}
|
25
|
+
params.merge!(AWS.indexed_param('ResourceId', resources))
|
26
|
+
params.merge!(AWS.indexed_param('Tag.%d.Key', tags.keys))
|
27
|
+
params.merge!(AWS.indexed_param('Tag.%d.Value', tags.values))
|
28
|
+
request({
|
29
|
+
'Action' => 'CreateTags',
|
30
|
+
:parser => Fog::Parsers::AWS::Compute::Basic.new
|
31
|
+
}.merge!(params))
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
class Mock
|
37
|
+
|
38
|
+
def create_tags(resources, tags)
|
39
|
+
resources = [*resources]
|
40
|
+
|
41
|
+
tagged = resources.map do |resource_id|
|
42
|
+
type = case resource_id
|
43
|
+
when /^ami\-[a-z0-9]{8}$/i
|
44
|
+
'image'
|
45
|
+
when /^i\-[a-z0-9]{8}$/i
|
46
|
+
'instance'
|
47
|
+
when /^snap\-[a-z0-9]{8}$/i
|
48
|
+
'snapshot'
|
49
|
+
when /^vol\-[a-z0-9]{8}$/i
|
50
|
+
'volume'
|
51
|
+
end
|
52
|
+
if type && @data[:"#{type}s"][resource_id]
|
53
|
+
{ 'resourceId' => resource_id, 'resourceType' => type }
|
54
|
+
else
|
55
|
+
raise(Fog::Service::NotFound.new("The #{type} ID '#{resource_id}' does not exist"))
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
tags.each do |key, value|
|
60
|
+
@data[:tags][key] ||= {}
|
61
|
+
@data[:tags][key][value] ||= []
|
62
|
+
@data[:tags][key][value] = @data[:tags][key][value] & tagged
|
63
|
+
end
|
64
|
+
|
65
|
+
response = Excon::Response.new
|
66
|
+
response.status = 200
|
67
|
+
response.body = {
|
68
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
69
|
+
'return' => true
|
70
|
+
}
|
71
|
+
response
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
|
6
|
+
# Remove tags from resources
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# * resources<~String> - One or more resources to tag
|
10
|
+
# * tags<~String> - hash of key value tag pairs to assign
|
11
|
+
#
|
12
|
+
# ==== Returns
|
13
|
+
# * response<~Excon::Response>:
|
14
|
+
# * body<~Hash>:
|
15
|
+
# * 'requestId'<~String> - Id of request
|
16
|
+
# * 'return'<~Boolean> - success?
|
17
|
+
def delete_tags(resources, tags)
|
18
|
+
resources = [*resources]
|
19
|
+
for key, value in tags
|
20
|
+
if value.nil?
|
21
|
+
tags[key] = ''
|
22
|
+
end
|
23
|
+
end
|
24
|
+
params = {}
|
25
|
+
params.merge!(AWS.indexed_param('ResourceId', resources))
|
26
|
+
params.merge!(AWS.indexed_param('Tag.%d.Key', tags.keys))
|
27
|
+
params.merge!(AWS.indexed_param('Tag.%d.Value', tags.values))
|
28
|
+
request({
|
29
|
+
'Action' => 'CreateTags',
|
30
|
+
:parser => Fog::Parsers::AWS::Compute::Basic.new
|
31
|
+
}.merge!(params))
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
class Mock
|
37
|
+
|
38
|
+
def delete_tags(resources, tags)
|
39
|
+
Fog::Mock.not_implemented
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -8,7 +8,7 @@ module Fog
|
|
8
8
|
# Describe all or specified IP addresses.
|
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>:
|
@@ -17,8 +17,12 @@ module Fog
|
|
17
17
|
# * 'addressesSet'<~Array>:
|
18
18
|
# * 'instanceId'<~String> - instance for ip address
|
19
19
|
# * 'publicIp'<~String> - ip address for instance
|
20
|
-
def describe_addresses(
|
21
|
-
|
20
|
+
def describe_addresses(filters = {})
|
21
|
+
unless filters.is_a?(Hash)
|
22
|
+
Formatador.display_line("[yellow][WARN] describe_addresses with #{filters.class} param is deprecated, use describe_addresses('public-ip' => []) instead[/] [light_black](#{caller.first})[/]")
|
23
|
+
filters = {'public-ip' => [*filters]}
|
24
|
+
end
|
25
|
+
params = AWS.indexed_filters(filters)
|
22
26
|
request({
|
23
27
|
'Action' => 'DescribeAddresses',
|
24
28
|
:idempotent => true,
|
@@ -30,24 +34,28 @@ module Fog
|
|
30
34
|
|
31
35
|
class Mock
|
32
36
|
|
33
|
-
def describe_addresses(
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
addresses_set = @data[:addresses].reject {|key, value| !public_ip.include?(key)}.values
|
38
|
-
else
|
39
|
-
addresses_set = @data[:addresses].values
|
37
|
+
def describe_addresses(filters = {})
|
38
|
+
unless filters.is_a?(Hash)
|
39
|
+
Formatador.display_line("[yellow][WARN] describe_addresses with #{filters.class} param is deprecated, use describe_addresses('public-ip' => []) instead[/] [light_black](#{caller.first})[/]")
|
40
|
+
filters = {'public-ip' => [*filters]}
|
40
41
|
end
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
42
|
+
|
43
|
+
response = Excon::Response.new
|
44
|
+
|
45
|
+
addresses_set = @data[:addresses].values
|
46
|
+
|
47
|
+
aliases = {'public-ip' => 'publicIp', 'instance-id' => 'instanceId'}
|
48
|
+
for filter_key, filter_value in filters
|
49
|
+
aliased_key = aliases[filter_key]
|
50
|
+
addresses_set = addresses_set.reject{|address| ![*filter_value].include?(address[aliased_key])}
|
50
51
|
end
|
52
|
+
|
53
|
+
response.status = 200
|
54
|
+
response.body = {
|
55
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
56
|
+
'addressesSet' => addresses_set
|
57
|
+
}
|
58
|
+
response
|
51
59
|
end
|
52
60
|
|
53
61
|
end
|
@@ -8,7 +8,7 @@ module Fog
|
|
8
8
|
# Describe all or specified availability zones
|
9
9
|
#
|
10
10
|
# ==== Params
|
11
|
-
# *
|
11
|
+
# * filters<~Hash> - List of filters to limit results with
|
12
12
|
#
|
13
13
|
# ==== Returns
|
14
14
|
# * response<~Excon::Response>:
|
@@ -18,8 +18,12 @@ module Fog
|
|
18
18
|
# * 'regionName'<~String> - Name of region
|
19
19
|
# * 'zoneName'<~String> - Name of zone
|
20
20
|
# * 'zoneState'<~String> - State of zone
|
21
|
-
def describe_availability_zones(
|
22
|
-
|
21
|
+
def describe_availability_zones(filters = {})
|
22
|
+
unless filters.is_a?(Hash)
|
23
|
+
Formatador.display_line("[yellow][WARN] describe_availability_zones with #{filters.class} param is deprecated, use describe_availability_zones('zone-name' => []) instead[/] [light_black](#{caller.first})[/]")
|
24
|
+
filters = {'public-ip' => [*filters]}
|
25
|
+
end
|
26
|
+
params = AWS.indexed_filters(filters)
|
23
27
|
request({
|
24
28
|
'Action' => 'DescribeAvailabilityZones',
|
25
29
|
:idempotent => true,
|
@@ -31,31 +35,33 @@ module Fog
|
|
31
35
|
|
32
36
|
class Mock
|
33
37
|
|
34
|
-
def describe_availability_zones(
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
'us-east-1a' => {"zoneName"=>"us-east-1a", "regionName"=>"us-east-1", "zoneState"=>"available"},
|
39
|
-
'us-east-1b' => {"zoneName"=>"us-east-1b", "regionName"=>"us-east-1", "zoneState"=>"available"},
|
40
|
-
'us-east-1c' => {"zoneName"=>"us-east-1c", "regionName"=>"us-east-1", "zoneState"=>"available"},
|
41
|
-
'us-east-1d' => {"zoneName"=>"us-east-1d", "regionName"=>"us-east-1", "zoneState"=>"available"}
|
42
|
-
}
|
43
|
-
if zone_name != []
|
44
|
-
availability_zone_info = zones.reject {|key, value| !zone_name.include?(key)}.values
|
45
|
-
else
|
46
|
-
availability_zone_info = zones.values
|
38
|
+
def describe_availability_zones(filters = {})
|
39
|
+
unless filters.is_a?(Hash)
|
40
|
+
Formatador.display_line("[yellow][WARN] describe_availability_zones with #{filters.class} param is deprecated, use describe_availability_zones('zone-name' => []) instead[/] [light_black](#{caller.first})[/]")
|
41
|
+
filters = {'public-ip' => [*filters]}
|
47
42
|
end
|
48
43
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
}
|
55
|
-
|
56
|
-
|
57
|
-
|
44
|
+
response = Excon::Response.new
|
45
|
+
|
46
|
+
availability_zone_info = [
|
47
|
+
{"messageSet" => [], "regionName" => "us-east-1", "zoneName" => "us-east-1a", "zoneState" => "available"},
|
48
|
+
{"messageSet" => [], "regionName" => "us-east-1", "zoneName" => "us-east-1b", "zoneState" => "available"},
|
49
|
+
{"messageSet" => [], "regionName" => "us-east-1", "zoneName" => "us-east-1c", "zoneState" => "available"},
|
50
|
+
{"messageSet" => [], "regionName" => "us-east-1", "zoneName" => "us-east-1d", "zoneState" => "available"},
|
51
|
+
]
|
52
|
+
|
53
|
+
aliases = {'region-name' => 'regionName', 'zone-name' => 'zoneName', 'state' => 'zoneState'}
|
54
|
+
for filter_key, filter_value in filters
|
55
|
+
aliased_key = aliases[filter_key]
|
56
|
+
availability_zone_info = availability_zone_info.reject{|availability_zone| ![*filter_value].include?(availability_zone[aliased_key])}
|
58
57
|
end
|
58
|
+
|
59
|
+
response.status = 200
|
60
|
+
response.body = {
|
61
|
+
'availabilityZoneInfo' => availability_zone_info,
|
62
|
+
'requestId' => Fog::AWS::Mock.request_id
|
63
|
+
}
|
64
|
+
response
|
59
65
|
end
|
60
66
|
|
61
67
|
end
|
@@ -8,7 +8,8 @@ module Fog
|
|
8
8
|
# Describe all or specified images.
|
9
9
|
#
|
10
10
|
# ==== Params
|
11
|
-
# *
|
11
|
+
# * filters<~Hash> - List of filters to limit results with
|
12
|
+
# * filters and/or the following
|
12
13
|
# * 'ExecutableBy'<~String> - Only return images that the executable_by
|
13
14
|
# user has explicit permission to launch
|
14
15
|
# * 'ImageId'<~Array> - Ids of images to describe
|
@@ -33,10 +34,14 @@ module Fog
|
|
33
34
|
# * 'ramdiskId'<~String> - Ramdisk id associated with image, if any
|
34
35
|
# * 'rootDeviceName'<~String> - Root device name, e.g. /dev/sda1
|
35
36
|
# * 'rootDeviceType'<~String> - Root device type, ebs or instance-store
|
36
|
-
def describe_images(
|
37
|
-
|
38
|
-
|
37
|
+
def describe_images(filters = {})
|
38
|
+
options = {}
|
39
|
+
for key in ['ExecutableBy', 'ImageId', 'Owner']
|
40
|
+
if filters.is_a?(Hash) && filters.key?(key)
|
41
|
+
options[key] = filters[key]
|
42
|
+
end
|
39
43
|
end
|
44
|
+
params = AWS.indexed_filters(filters).merge!(options)
|
40
45
|
request({
|
41
46
|
'Action' => 'DescribeImages',
|
42
47
|
:idempotent => true,
|
@@ -48,20 +53,8 @@ module Fog
|
|
48
53
|
|
49
54
|
class Mock
|
50
55
|
|
51
|
-
def describe_images(
|
52
|
-
|
53
|
-
images = []
|
54
|
-
|
55
|
-
(rand(101 + 100)).times do
|
56
|
-
images << Fog::AWS::Mock.image
|
57
|
-
end
|
58
|
-
|
59
|
-
response.status = 200
|
60
|
-
response.body = {
|
61
|
-
'requestId' => Fog::AWS::Mock.request_id,
|
62
|
-
'imagesSet' => images
|
63
|
-
}
|
64
|
-
response
|
56
|
+
def describe_images(filters = {})
|
57
|
+
Fog::Mock.not_implemented
|
65
58
|
end
|
66
59
|
|
67
60
|
end
|