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,7 +8,7 @@ module Fog
|
|
8
8
|
# Describe all or specified instances
|
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>:
|
@@ -50,8 +50,13 @@ module Fog
|
|
50
50
|
# * 'rootDeviceType'<~String> - root device type used by AMI in [ebs, instance-store]
|
51
51
|
# * 'ramdiskId'<~String> - Id of ramdisk used to launch instance
|
52
52
|
# * 'reason'<~String> - reason for most recent state transition, or blank
|
53
|
-
def describe_instances(
|
54
|
-
|
53
|
+
def describe_instances(filters = {})
|
54
|
+
unless filters.is_a?(Hash)
|
55
|
+
Formatador.display_line("[yellow][WARN] describe_instances with #{filters.class} param is deprecated, use describe_instances('instance-id' => []) instead[/] [light_black](#{caller.first})[/]")
|
56
|
+
filters = {'instance-id' => [*filters]}
|
57
|
+
end
|
58
|
+
params = AWS.indexed_filters(filters)
|
59
|
+
|
55
60
|
request({
|
56
61
|
'Action' => 'DescribeInstances',
|
57
62
|
:idempotent => true,
|
@@ -63,64 +68,131 @@ module Fog
|
|
63
68
|
|
64
69
|
class Mock
|
65
70
|
|
66
|
-
def describe_instances(
|
71
|
+
def describe_instances(filters = {})
|
72
|
+
unless filters.is_a?(Hash)
|
73
|
+
Formatador.display_line("[yellow][WARN] describe_instances with #{filters.class} param is deprecated, use describe_instances('instance-id' => []) instead[/] [light_black](#{caller.first})[/]")
|
74
|
+
filters = {'instance-id' => [*filters]}
|
75
|
+
end
|
76
|
+
|
77
|
+
if filters.keys.any? {|key| key =~ /^tag/}
|
78
|
+
Formatador.display_line("[yellow][WARN] describe_instances tag filters are not yet mocked[/] [light_black](#{caller.first})[/]")
|
79
|
+
Fog::Mock.not_implemented
|
80
|
+
end
|
81
|
+
|
67
82
|
response = Excon::Response.new
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
83
|
+
|
84
|
+
instance_set = @data[:instances].values
|
85
|
+
|
86
|
+
aliases = {
|
87
|
+
'architecture' => 'architecture',
|
88
|
+
'availability-zone' => 'availabilityZone',
|
89
|
+
'client-token' => 'clientToken',
|
90
|
+
'dns-token' => 'dnsName',
|
91
|
+
'group-id' => 'groupId',
|
92
|
+
'image-id' => 'imageId',
|
93
|
+
'instance-id' => 'instanceId',
|
94
|
+
'instance-lifecycle' => 'instanceLifecycle',
|
95
|
+
'instance-type' => 'instanceType',
|
96
|
+
'ip-address' => 'ipAddress',
|
97
|
+
'kernel-id' => 'kernelId',
|
98
|
+
'key-name' => 'key-name',
|
99
|
+
'launch-index' => 'launchIndex',
|
100
|
+
'launch-time' => 'launchTime',
|
101
|
+
'monitoring-state' => 'monitoringState',
|
102
|
+
'owner-id' => 'ownerId',
|
103
|
+
'placement-group-name' => 'placementGroupName',
|
104
|
+
'platform' => 'platform',
|
105
|
+
'private-dns-name' => 'privateDnsName',
|
106
|
+
'private-ip-address' => 'privateIpAddress',
|
107
|
+
'product-code' => 'productCode',
|
108
|
+
'ramdisk-id' => 'ramdiskId',
|
109
|
+
'reason' => 'reason',
|
110
|
+
'requester-id' => 'requesterId',
|
111
|
+
'reservation-id' => 'reservationId',
|
112
|
+
'root-device-name' => 'rootDeviceName',
|
113
|
+
'root-device-type' => 'rootDeviceType',
|
114
|
+
'spot-instance-request-id' => 'spotInstanceRequestId',
|
115
|
+
'subnet-id' => 'subnetId',
|
116
|
+
'virtualization-type' => 'virtualizationType',
|
117
|
+
'vpc-id' => 'vpcId'
|
118
|
+
}
|
119
|
+
block_device_mapping_aliases = {
|
120
|
+
'attach-time' => 'attachTime',
|
121
|
+
'delete-on-termination' => 'deleteOnTermination',
|
122
|
+
'device-name' => 'deviceName',
|
123
|
+
'status' => 'status',
|
124
|
+
'volume-id' => 'volumeId',
|
125
|
+
}
|
126
|
+
instance_state_aliases = {
|
127
|
+
'code' => 'code',
|
128
|
+
'name' => 'name'
|
129
|
+
}
|
130
|
+
state_reason_aliases = {
|
131
|
+
'code' => 'code',
|
132
|
+
'message' => 'message'
|
133
|
+
}
|
134
|
+
for filter_key, filter_value in filters
|
135
|
+
if block_device_mapping_key = filter_key.split('block-device-mapping.')[1]
|
136
|
+
aliased_key = block_device_mapping_aliases[block_device_mapping_key]
|
137
|
+
instance_set = instance_set.reject{|instance| !instance['blockDeviceMapping'].detect {|block_device_mapping| [*filter_value].include?(block_device_mapping[aliased_key])}}
|
138
|
+
elsif instance_state_key = filter_key.split('instance-state-')[1]
|
139
|
+
aliased_key = instance_state_aliases[instance_state_key]
|
140
|
+
instance_set = instance_set.reject{|instance| ![*filter_value].include?(instance['instanceState'][aliased_key])}
|
141
|
+
elsif state_reason_key = filter_key.split('state-reason-')[1]
|
142
|
+
aliased_key = state_reason_aliases[state_reason_key]
|
143
|
+
instance_set = instance_set.reject{|instance| ![*filter_value].include?(instance['stateReason'][aliased_key])}
|
144
|
+
else
|
145
|
+
aliased_key = aliases[filter_key]
|
146
|
+
instance_set = instance_set.reject {|instance| ![*filter_value].include?(instance[aliased_key])}
|
147
|
+
end
|
73
148
|
end
|
74
149
|
|
75
|
-
|
76
|
-
|
77
|
-
reservation_set = {}
|
78
|
-
|
79
|
-
instance_set.each do |instance|
|
80
|
-
case instance['instanceState']['name']
|
81
|
-
when 'pending'
|
82
|
-
if Time.now - instance['launchTime'] > Fog::Mock.delay
|
83
|
-
instance['ipAddress'] = Fog::AWS::Mock.ip_address
|
84
|
-
instance['dnsName'] = Fog::AWS::Mock.dns_name_for(instance['ipAddress'])
|
85
|
-
instance['privateIpAddress'] = Fog::AWS::Mock.ip_address
|
86
|
-
instance['privateDnsName'] = Fog::AWS::Mock.private_dns_name_for(instance['privateIpAddress'])
|
87
|
-
instance['instanceState'] = { 'code' => 16, 'name' => 'running' }
|
88
|
-
end
|
89
|
-
when 'rebooting'
|
90
|
-
instance['instanceState'] = { 'code' => 16, 'name' => 'running' }
|
91
|
-
when 'shutting-down'
|
92
|
-
if Time.now - @data[:deleted_at][instance['instanceId']] > Fog::Mock.delay * 2
|
93
|
-
@data[:deleted_at].delete(instance['instanceId'])
|
94
|
-
@data[:instances].delete(instance['instanceId'])
|
95
|
-
elsif Time.now - @data[:deleted_at][instance['instanceId']] > Fog::Mock.delay
|
96
|
-
instance['instanceState'] = { 'code' => 48, 'name' => 'terminating' }
|
97
|
-
end
|
98
|
-
when 'terminating'
|
99
|
-
if Time.now - @data[:deleted_at][instance['instanceId']] > Fog::Mock.delay
|
100
|
-
@data[:deleted_at].delete(instance['instanceId'])
|
101
|
-
@data[:instances].delete(instance['instanceId'])
|
102
|
-
end
|
103
|
-
end
|
150
|
+
response.status = 200
|
151
|
+
reservation_set = {}
|
104
152
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
153
|
+
instance_set.each do |instance|
|
154
|
+
case instance['instanceState']['name']
|
155
|
+
when 'pending'
|
156
|
+
if Time.now - instance['launchTime'] > Fog::Mock.delay
|
157
|
+
instance['ipAddress'] = Fog::AWS::Mock.ip_address
|
158
|
+
instance['dnsName'] = Fog::AWS::Mock.dns_name_for(instance['ipAddress'])
|
159
|
+
instance['privateIpAddress'] = Fog::AWS::Mock.ip_address
|
160
|
+
instance['privateDnsName'] = Fog::AWS::Mock.private_dns_name_for(instance['privateIpAddress'])
|
161
|
+
instance['instanceState'] = { 'code' => 16, 'name' => 'running' }
|
162
|
+
end
|
163
|
+
when 'rebooting'
|
164
|
+
instance['instanceState'] = { 'code' => 16, 'name' => 'running' }
|
165
|
+
when 'shutting-down'
|
166
|
+
if Time.now - @data[:deleted_at][instance['instanceId']] > Fog::Mock.delay * 2
|
167
|
+
@data[:deleted_at].delete(instance['instanceId'])
|
168
|
+
@data[:instances].delete(instance['instanceId'])
|
169
|
+
elsif Time.now - @data[:deleted_at][instance['instanceId']] > Fog::Mock.delay
|
170
|
+
instance['instanceState'] = { 'code' => 48, 'name' => 'terminating' }
|
171
|
+
end
|
172
|
+
when 'terminating'
|
173
|
+
if Time.now - @data[:deleted_at][instance['instanceId']] > Fog::Mock.delay
|
174
|
+
@data[:deleted_at].delete(instance['instanceId'])
|
175
|
+
@data[:instances].delete(instance['instanceId'])
|
113
176
|
end
|
114
177
|
end
|
115
178
|
|
116
|
-
|
117
|
-
|
118
|
-
'
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
179
|
+
if @data[:instances][instance['instanceId']]
|
180
|
+
|
181
|
+
reservation_set[instance['reservationId']] ||= {
|
182
|
+
'groupSet' => instance['groupSet'],
|
183
|
+
'instancesSet' => [],
|
184
|
+
'ownerId' => instance['ownerId'],
|
185
|
+
'reservationId' => instance['reservationId']
|
186
|
+
}
|
187
|
+
reservation_set[instance['reservationId']]['instancesSet'] << instance.reject{|key,value| !['amiLaunchIndex', 'architecture', 'blockDeviceMapping', 'clientToken', 'dnsName', 'imageId', 'instanceId', 'instanceState', 'instanceType', 'ipAddress', 'kernelId', 'keyName', 'launchTime', 'monitoring', 'placement', 'privateDnsName', 'privateIpAddress', 'productCodes', 'ramdiskId', 'reason', 'rootDeviceType', 'stateReason', 'tagSet'].include?(key)}
|
188
|
+
end
|
123
189
|
end
|
190
|
+
|
191
|
+
response.body = {
|
192
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
193
|
+
'reservationSet' => reservation_set.values
|
194
|
+
}
|
195
|
+
response
|
124
196
|
end
|
125
197
|
|
126
198
|
end
|
@@ -8,7 +8,7 @@ module Fog
|
|
8
8
|
# Describe all or specified key pairs
|
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
|
# * 'keySet'<~Array>:
|
18
18
|
# * 'keyName'<~String> - Name of key
|
19
19
|
# * 'keyFingerprint'<~String> - Fingerprint of key
|
20
|
-
def describe_key_pairs(
|
21
|
-
|
20
|
+
def describe_key_pairs(filters = {})
|
21
|
+
unless filters.is_a?(Hash)
|
22
|
+
Formatador.display_line("[yellow][WARN] describe_key_pairs with #{filters.class} param is deprecated, use describe_key_pairs('key-name' => []) instead[/] [light_black](#{caller.first})[/]")
|
23
|
+
filters = {'key-name' => [*filters]}
|
24
|
+
end
|
25
|
+
params = AWS.indexed_filters(filters)
|
22
26
|
request({
|
23
27
|
'Action' => 'DescribeKeyPairs',
|
24
28
|
:idempotent => true,
|
@@ -30,26 +34,30 @@ module Fog
|
|
30
34
|
|
31
35
|
class Mock
|
32
36
|
|
33
|
-
def describe_key_pairs(
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
key_set = @data[:key_pairs].reject {|key, value| !key_name.include?(key)}.values
|
38
|
-
else
|
39
|
-
key_set = @data[:key_pairs].values
|
37
|
+
def describe_key_pairs(filters = {})
|
38
|
+
unless filters.is_a?(Hash)
|
39
|
+
Formatador.display_line("[yellow][WARN] describe_key_pairs with #{filters.class} param is deprecated, use describe_key_pairs('key-name' => []) instead[/] [light_black](#{caller.first})[/]")
|
40
|
+
filters = {'key-name' => [*filters]}
|
40
41
|
end
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
else
|
51
|
-
raise Fog::AWS::Compute::NotFound.new("The key pair #{key_name.inspect} does not exist")
|
42
|
+
|
43
|
+
response = Excon::Response.new
|
44
|
+
|
45
|
+
key_set = @data[:key_pairs].values
|
46
|
+
|
47
|
+
aliases = {'fingerprint' => 'keyFingerprint', 'key-name' => 'keyName'}
|
48
|
+
for filter_key, filter_value in filters
|
49
|
+
aliased_key = aliases[filter_key]
|
50
|
+
key_set = key_set.reject{|key_pair| ![*filter_value].include?(key_pair[aliased_key])}
|
52
51
|
end
|
52
|
+
|
53
|
+
response.status = 200
|
54
|
+
response.body = {
|
55
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
56
|
+
'keySet' => key_set.map do |key_pair|
|
57
|
+
key_pair.reject {|key,value| !['keyFingerprint', 'keyName'].include?(key)}
|
58
|
+
end
|
59
|
+
}
|
60
|
+
response
|
53
61
|
end
|
54
62
|
|
55
63
|
end
|
@@ -8,7 +8,7 @@ module Fog
|
|
8
8
|
# Describe all or specified regions
|
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>:
|
@@ -17,8 +17,12 @@ module Fog
|
|
17
17
|
# * 'regionInfo'<~Array>:
|
18
18
|
# * 'regionName'<~String> - Name of region
|
19
19
|
# * 'regionEndpoint'<~String> - Service endpoint for region
|
20
|
-
def describe_regions(
|
21
|
-
|
20
|
+
def describe_regions(filters = {})
|
21
|
+
unless filters.is_a?(Hash)
|
22
|
+
Formatador.display_line("[yellow][WARN] describe_regions with #{filters.class} param is deprecated, use describe_regions('region-name' => []) instead[/] [light_black](#{caller.first})[/]")
|
23
|
+
filters = {'region-name' => [*filters]}
|
24
|
+
end
|
25
|
+
params = AWS.indexed_filters(filters)
|
22
26
|
request({
|
23
27
|
'Action' => 'DescribeRegions',
|
24
28
|
:idempotent => true,
|
@@ -30,29 +34,30 @@ module Fog
|
|
30
34
|
|
31
35
|
class Mock
|
32
36
|
|
33
|
-
def describe_regions(
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
'eu-west-1' => {"regionName"=>"eu-west-1", "regionEndpoint"=>"eu-west-1.ec2.amazonaws.com"},
|
38
|
-
'us-east-1' => {"regionName"=>"us-east-1", "regionEndpoint"=>"us-east-1.ec2.amazonaws.com"}
|
39
|
-
}
|
40
|
-
if region_name != []
|
41
|
-
region_info = regions.reject {|key, value| !region_name.include?(key)}.values
|
42
|
-
else
|
43
|
-
region_info = regions.values
|
37
|
+
def describe_regions(filters = {})
|
38
|
+
unless filters.is_a?(Hash)
|
39
|
+
Formatador.display_line("[yellow][WARN] describe_regions with #{filters.class} param is deprecated, use describe_regions('region-name' => []) instead[/] [light_black](#{caller.first})[/]")
|
40
|
+
filters = {'region-name' => [*filters]}
|
44
41
|
end
|
45
42
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
43
|
+
response = Excon::Response.new
|
44
|
+
region_info = [
|
45
|
+
{"regionName"=>"eu-west-1", "regionEndpoint"=>"eu-west-1.ec2.amazonaws.com"},
|
46
|
+
{"regionName"=>"us-east-1", "regionEndpoint"=>"us-east-1.ec2.amazonaws.com"}
|
47
|
+
]
|
48
|
+
|
49
|
+
aliases = {'region-name' => 'regionName', 'endpoint' => 'regionEndpoint'}
|
50
|
+
for filter_key, filter_value in filters
|
51
|
+
aliased_key = aliases[filter_key]
|
52
|
+
region_info = region_info.reject{|region| ![*filter_value].include?(region[aliased_key])}
|
55
53
|
end
|
54
|
+
|
55
|
+
response.status = 200
|
56
|
+
response.body = {
|
57
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
58
|
+
'regionInfo' => region_info
|
59
|
+
}
|
60
|
+
response
|
56
61
|
end
|
57
62
|
|
58
63
|
end
|
@@ -8,7 +8,7 @@ module Fog
|
|
8
8
|
# Describe all or specified reserved instances
|
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>:
|
@@ -25,8 +25,12 @@ module Fog
|
|
25
25
|
# * 'start'<~Time> - start time for reservation
|
26
26
|
# * 'state'<~String> - state of reserved instance purchase, in .[pending-payment, active, payment-failed, retired]
|
27
27
|
# * 'usagePrice"<~Float> - usage price of reserved instances, per hour
|
28
|
-
def describe_reserved_instances(
|
29
|
-
|
28
|
+
def describe_reserved_instances(filters = {})
|
29
|
+
unless filters.is_a?(Hash)
|
30
|
+
Formatador.display_line("[yellow][WARN] describe_reserved_instances with #{filters.class} param is deprecated, use describe_reserved_instances('reserved-instances-id' => []) instead[/] [light_black](#{caller.first})[/]")
|
31
|
+
filters = {'reserved-instances-id' => [*filters]}
|
32
|
+
end
|
33
|
+
params = AWS.indexed_filters(filters)
|
30
34
|
request({
|
31
35
|
'Action' => 'DescribeReservedInstances',
|
32
36
|
:idempotent => true,
|
@@ -38,7 +42,7 @@ module Fog
|
|
38
42
|
|
39
43
|
class Mock
|
40
44
|
|
41
|
-
def describe_reserved_instances(
|
45
|
+
def describe_reserved_instances(filters = {})
|
42
46
|
Fog::Mock.not_implemented
|
43
47
|
end
|
44
48
|
|
@@ -8,7 +8,7 @@ module Fog
|
|
8
8
|
# Describe all or specified security groups
|
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>:
|
@@ -27,8 +27,12 @@ module Fog
|
|
27
27
|
# * 'cidrIp'<~String> - CIDR range
|
28
28
|
# * 'toPort'<~Integer> - End of port range (or -1 for ICMP wildcard)
|
29
29
|
# * 'ownerId'<~String> - AWS Access Key Id of the owner of the security group
|
30
|
-
def describe_security_groups(
|
31
|
-
|
30
|
+
def describe_security_groups(filters = {})
|
31
|
+
unless filters.is_a?(Hash)
|
32
|
+
Formatador.display_line("[yellow][WARN] describe_security_groups with #{filters.class} param is deprecated, use describe_security_groups('group-name' => []) instead[/] [light_black](#{caller.first})[/]")
|
33
|
+
filters = {'group-name' => [*filters]}
|
34
|
+
end
|
35
|
+
params = AWS.indexed_filters(filters)
|
32
36
|
request({
|
33
37
|
'Action' => 'DescribeSecurityGroups',
|
34
38
|
:idempotent => true,
|
@@ -40,24 +44,49 @@ module Fog
|
|
40
44
|
|
41
45
|
class Mock
|
42
46
|
|
43
|
-
def describe_security_groups(
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
security_group_info = @data[:security_groups].reject {|key, value| !group_name.include?(key)}.values
|
48
|
-
else
|
49
|
-
security_group_info = @data[:security_groups].values
|
47
|
+
def describe_security_groups(filters = {})
|
48
|
+
unless filters.is_a?(Hash)
|
49
|
+
Formatador.display_line("[yellow][WARN] describe_security_groups with #{filters.class} param is deprecated, use describe_security_groups('group-name' => []) instead[/] [light_black](#{caller.first})[/]")
|
50
|
+
filters = {'group-name' => [*filters]}
|
50
51
|
end
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
52
|
+
|
53
|
+
response = Excon::Response.new
|
54
|
+
|
55
|
+
security_group_info = @data[:security_groups].values
|
56
|
+
|
57
|
+
aliases = {
|
58
|
+
'description' => 'groupDescription',
|
59
|
+
'group-name' => 'groupName',
|
60
|
+
'owner-id' => 'ownerId'
|
61
|
+
}
|
62
|
+
permission_aliases = {
|
63
|
+
'cidr' => 'cidrIp',
|
64
|
+
'from-port' => 'fromPort',
|
65
|
+
'protocol' => 'ipProtocol',
|
66
|
+
'to-port' => 'toPort'
|
67
|
+
}
|
68
|
+
for filter_key, filter_value in filters
|
69
|
+
if permission_key = filter_key.split('ip-permission.')[1]
|
70
|
+
if permission_key == 'group-name'
|
71
|
+
security_group_info = security_group_info.reject{|security_group| !security_group['ipPermissions']['groups'].detect {|group| [*filter_value].include?(group['groupName'])}}
|
72
|
+
elsif permission_key == 'user-id'
|
73
|
+
security_group_info = security_group_info.reject{|security_group| !security_group['ipPermissions']['groups'].detect {|group| [*filter_value].include?(group['userId'])}}
|
74
|
+
else
|
75
|
+
aliased_key = permission_aliases[filter_key]
|
76
|
+
security_group_info = security_group_info.reject{|security_group| !security_group['ipPermissions'].detect {|permission| [*filter_value].include?(permission[aliased_key])}}
|
77
|
+
end
|
78
|
+
else
|
79
|
+
aliased_key = aliases[filter_key]
|
80
|
+
security_group_info = security_group_info.reject{|security_group| ![*filter_value].include?(security_group[aliased_key])}
|
81
|
+
end
|
60
82
|
end
|
83
|
+
|
84
|
+
response.status = 200
|
85
|
+
response.body = {
|
86
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
87
|
+
'securityGroupInfo' => security_group_info
|
88
|
+
}
|
89
|
+
response
|
61
90
|
end
|
62
91
|
|
63
92
|
end
|