fog-aws 1.4.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +9 -8
- data/CHANGELOG.md +40 -2
- data/CONTRIBUTING.md +6 -6
- data/CONTRIBUTORS.md +104 -1
- data/LICENSE.md +1 -1
- data/fog-aws.gemspec +4 -2
- data/lib/fog/aws.rb +1 -0
- data/lib/fog/aws/compute.rb +86 -2
- data/lib/fog/aws/credential_fetcher.rb +4 -2
- data/lib/fog/aws/mock.rb +8 -0
- data/lib/fog/aws/models/compute/flavors.rb +40 -0
- data/lib/fog/aws/models/compute/subnet.rb +1 -0
- data/lib/fog/aws/models/compute/vpc.rb +11 -2
- data/lib/fog/aws/models/iam/access_keys.rb +0 -2
- data/lib/fog/aws/models/rds/instance_option.rb +6 -0
- data/lib/fog/aws/parsers/compute/create_subnet.rb +2 -0
- data/lib/fog/aws/parsers/compute/describe_subnets.rb +1 -1
- data/lib/fog/aws/parsers/compute/describe_vpcs.rb +71 -37
- data/lib/fog/aws/parsers/iam/list_access_keys.rb +1 -1
- data/lib/fog/aws/parsers/rds/describe_orderable_db_instance_options.rb +4 -3
- data/lib/fog/aws/requests/auto_scaling/detach_instances.rb +3 -4
- data/lib/fog/aws/requests/compute/authorize_security_group_egress.rb +8 -6
- data/lib/fog/aws/requests/compute/authorize_security_group_ingress.rb +25 -21
- data/lib/fog/aws/requests/compute/copy_snapshot.rb +22 -9
- data/lib/fog/aws/requests/compute/create_network_interface.rb +2 -2
- data/lib/fog/aws/requests/compute/create_route_table.rb +1 -1
- data/lib/fog/aws/requests/compute/create_security_group.rb +24 -19
- data/lib/fog/aws/requests/compute/create_subnet.rb +14 -10
- data/lib/fog/aws/requests/compute/create_vpc.rb +38 -10
- data/lib/fog/aws/requests/compute/delete_security_group.rb +9 -9
- data/lib/fog/aws/requests/compute/describe_network_interface_attribute.rb +16 -14
- data/lib/fog/aws/requests/compute/describe_security_groups.rb +30 -6
- data/lib/fog/aws/requests/compute/describe_subnets.rb +12 -11
- data/lib/fog/aws/requests/compute/modify_network_interface_attribute.rb +3 -3
- data/lib/fog/aws/requests/compute/revoke_security_group_egress.rb +19 -25
- data/lib/fog/aws/requests/compute/revoke_security_group_ingress.rb +18 -25
- data/lib/fog/aws/requests/compute/run_instances.rb +1 -1
- data/lib/fog/aws/requests/efs/create_mount_target.rb +8 -4
- data/lib/fog/aws/requests/elb/create_load_balancer.rb +6 -37
- data/lib/fog/aws/requests/kinesis/put_record.rb +1 -2
- data/lib/fog/aws/requests/kinesis/put_records.rb +1 -2
- data/lib/fog/aws/requests/lambda/invoke.rb +1 -1
- data/lib/fog/aws/requests/rds/describe_orderable_db_instance_options.rb +12 -6
- data/lib/fog/aws/requests/storage/put_object.rb +0 -1
- data/lib/fog/aws/service_mapper.rb +129 -0
- data/lib/fog/aws/version.rb +1 -1
- data/tests/helpers/collection_helper.rb +0 -6
- data/tests/models/efs/mount_target_tests.rb +3 -1
- data/tests/models/elasticache/subnet_groups_tests.rb +0 -1
- data/tests/models/storage/file_tests.rb +0 -4
- data/tests/models/storage/url_tests.rb +1 -20
- data/tests/models/storage/versions_tests.rb +0 -5
- data/tests/requests/compute/network_interface_tests.rb +2 -13
- data/tests/requests/compute/subnet_tests.rb +3 -1
- data/tests/requests/compute/vpc_tests.rb +8 -6
- data/tests/requests/dns/dns_tests.rb +0 -4
- data/tests/requests/efs/file_system_tests.rb +1 -1
- data/tests/requests/iam/managed_policy_tests.rb +0 -1
- data/tests/requests/iam/versioned_managed_policy_tests.rb +3 -12
- data/tests/requests/lambda/helper.rb +2 -2
- data/tests/requests/rds/helper.rb +7 -2
- data/tests/requests/rds/instance_option_tests.rb +7 -1
- data/tests/requests/storage/object_tests.rb +2 -11
- metadata +9 -10
- data/gemfiles/Gemfile-ruby-1.8.7 +0 -6
- data/gemfiles/Gemfile-ruby-1.9 +0 -7
@@ -18,15 +18,17 @@ module Fog
|
|
18
18
|
# * body<~Hash>:
|
19
19
|
# * 'requestId'<~String> - Id of request
|
20
20
|
# * 'subnet'<~Array>:
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
21
|
+
# * 'subnetId'<~String> - The Subnet's ID
|
22
|
+
# * 'state'<~String> - The current state of the Subnet. ['pending', 'available']
|
23
|
+
# * 'cidrBlock'<~String> - The CIDR block the Subnet covers.
|
24
|
+
# * 'availableIpAddressCount'<~Integer> - The number of unused IP addresses in the subnet (the IP addresses for any stopped
|
25
|
+
# instances are considered unavailable)
|
26
|
+
# * 'availabilityZone'<~String> - The Availability Zone the subnet is in
|
27
|
+
# * 'tagSet'<~Array>: Tags assigned to the resource.
|
28
|
+
# * 'key'<~String> - Tag's key
|
29
|
+
# * 'value'<~String> - Tag's value
|
30
|
+
# * 'mapPublicIpOnLaunch'<~Boolean> - Indicates whether instances launched in this subnet receive a public IPv4 address.
|
31
|
+
# * 'defaultForAz'<~Boolean> - Indicates whether this is the default subnet for the Availability Zone.
|
30
32
|
#
|
31
33
|
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/2011-07-15/APIReference/ApiReference-query-CreateSubnet.html]
|
32
34
|
def create_subnet(vpcId, cidrBlock, options = {})
|
@@ -65,7 +67,9 @@ module Fog
|
|
65
67
|
'cidrBlock' => cidrBlock,
|
66
68
|
'availableIpAddressCount' => "255",
|
67
69
|
'availabilityZone' => av_zone,
|
68
|
-
'tagSet' => {}
|
70
|
+
'tagSet' => {},
|
71
|
+
'mapPublicIpOnLaunch' => true,
|
72
|
+
'defaultForAz' => true
|
69
73
|
}
|
70
74
|
|
71
75
|
# Add this subnet to the default network ACL
|
@@ -43,16 +43,18 @@ module Fog
|
|
43
43
|
response.status = 200
|
44
44
|
vpc_id = Fog::AWS::Mock.vpc_id
|
45
45
|
vpc = {
|
46
|
-
'vpcId'
|
47
|
-
'state'
|
48
|
-
'cidrBlock'
|
49
|
-
'dhcpOptionsId'
|
50
|
-
'tagSet'
|
51
|
-
'enableDnsSupport'
|
52
|
-
'enableDnsHostnames'
|
53
|
-
'mapPublicIpOnLaunch'
|
54
|
-
'classicLinkEnabled'
|
55
|
-
'classicLinkDnsSupport'
|
46
|
+
'vpcId' => vpc_id,
|
47
|
+
'state' => 'pending',
|
48
|
+
'cidrBlock' => cidrBlock,
|
49
|
+
'dhcpOptionsId' => Fog::AWS::Mock.request_id,
|
50
|
+
'tagSet' => {},
|
51
|
+
'enableDnsSupport' => true,
|
52
|
+
'enableDnsHostnames' => false,
|
53
|
+
'mapPublicIpOnLaunch' => false,
|
54
|
+
'classicLinkEnabled' => false,
|
55
|
+
'classicLinkDnsSupport' => false,
|
56
|
+
'cidrBlockAssociationSet' => [{ 'cidrBlock' => cidrBlock, 'state' => 'associated', 'associationId' => "vpc-cidr-assoc-#{vpc_id}" }],
|
57
|
+
'ipv6CidrBlockAssociationSet' => []
|
56
58
|
}
|
57
59
|
self.data[:vpcs].push(vpc)
|
58
60
|
|
@@ -75,6 +77,32 @@ module Fog
|
|
75
77
|
# Manually override since Amazon doesn't let you create a default one
|
76
78
|
self.data[:network_acls][default_nacl.network_acl_id]['default'] = true
|
77
79
|
|
80
|
+
|
81
|
+
# create default security groups
|
82
|
+
default_elb_group_name = "default_elb_#{Fog::Mock.random_hex(6)}"
|
83
|
+
default_elb_group_id = Fog::AWS::Mock.security_group_id
|
84
|
+
|
85
|
+
Fog::Compute::AWS::Mock.data[region][@aws_access_key_id][:security_groups][default_elb_group_id] = {
|
86
|
+
'groupDescription' => 'default_elb security group',
|
87
|
+
'groupName' => default_elb_group_name,
|
88
|
+
'groupId' => default_elb_group_id,
|
89
|
+
'ipPermissions' => [],
|
90
|
+
'ownerId' => self.data[:owner_id],
|
91
|
+
'vpcId' => vpc_id
|
92
|
+
}
|
93
|
+
|
94
|
+
default_group_name = 'default'
|
95
|
+
default_group_id = Fog::AWS::Mock.security_group_id
|
96
|
+
|
97
|
+
Fog::Compute::AWS::Mock.data[region][@aws_access_key_id][:security_groups][default_group_id] = {
|
98
|
+
'groupDescription' => default_group_name,
|
99
|
+
'groupName' => default_group_name,
|
100
|
+
'groupId' => default_group_id,
|
101
|
+
'ipPermissions' => [],
|
102
|
+
'ownerId' => self.data[:owner_id],
|
103
|
+
'vpcId' => vpc_id
|
104
|
+
}
|
105
|
+
|
78
106
|
response.body = {
|
79
107
|
'requestId' => Fog::AWS::Mock.request_id,
|
80
108
|
'vpcSet' => [vpc]
|
@@ -47,12 +47,12 @@ module Fog
|
|
47
47
|
raise Fog::Compute::AWS::Error.new("May not specify both group_name and group_id")
|
48
48
|
end
|
49
49
|
|
50
|
-
if
|
51
|
-
|
50
|
+
if name
|
51
|
+
id, _ = self.data[:security_groups].find { |_,v| v['groupName'] == name }
|
52
52
|
end
|
53
53
|
|
54
|
-
unless self.data[:security_groups][
|
55
|
-
raise Fog::Compute::AWS::NotFound.new("The security group '#{
|
54
|
+
unless self.data[:security_groups][id]
|
55
|
+
raise Fog::Compute::AWS::NotFound.new("The security group '#{id}' does not exist")
|
56
56
|
end
|
57
57
|
|
58
58
|
response = Excon::Response.new
|
@@ -61,14 +61,14 @@ module Fog
|
|
61
61
|
|
62
62
|
# ec2 authorizations
|
63
63
|
self.region_data.each do |_, key_data|
|
64
|
-
key_data[:security_groups].each do |
|
65
|
-
next if group == self.data[:security_groups][
|
64
|
+
key_data[:security_groups].each do |group_id, group|
|
65
|
+
next if group == self.data[:security_groups][group_id]
|
66
66
|
|
67
67
|
group['ipPermissions'].each do |group_ip_permission|
|
68
68
|
group_ip_permission['groups'].each do |group_group_permission|
|
69
|
-
if group_group_permission['
|
69
|
+
if group_group_permission['groupId'] == group_id &&
|
70
70
|
group_group_permission['userId'] == self.data[:owner_id]
|
71
|
-
used_by_groups << "#{key_data[:owner_id]}:#{
|
71
|
+
used_by_groups << "#{key_data[:owner_id]}:#{group['groupName']}"
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
@@ -100,7 +100,7 @@ module Fog
|
|
100
100
|
raise Fog::Compute::AWS::Error.new("InUse => There are active instances using security group '#{name}'")
|
101
101
|
end
|
102
102
|
|
103
|
-
self.data[:security_groups].delete(
|
103
|
+
self.data[:security_groups].delete(id)
|
104
104
|
response.status = 200
|
105
105
|
response.body = {
|
106
106
|
'requestId' => Fog::AWS::Mock.request_id,
|
@@ -42,23 +42,25 @@ module Fog
|
|
42
42
|
class Mock
|
43
43
|
def describe_network_interface_attribute(network_interface_id, attribute)
|
44
44
|
response = Excon::Response.new
|
45
|
-
|
45
|
+
network_interface = self.data[:network_interfaces][network_interface_id]
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
'requestId' => Fog::AWS::Mock.request_id,
|
50
|
-
'networkInterfaceId' => network_interface_id
|
51
|
-
}
|
52
|
-
case attribute
|
53
|
-
when 'description', 'groupSet', 'sourceDestCheck', 'attachment'
|
54
|
-
response.body[attribute] = self.data[:network_interfaces][network_interface_id][attribute]
|
55
|
-
else
|
56
|
-
raise Fog::Compute::AWS::Error.new("Illegal attribute '#{attribute}' specified")
|
57
|
-
end
|
58
|
-
response
|
59
|
-
else
|
47
|
+
|
48
|
+
unless network_interface
|
60
49
|
raise Fog::Compute::AWS::NotFound.new("The network interface '#{network_interface_id}' does not exist")
|
61
50
|
end
|
51
|
+
|
52
|
+
response.status = 200
|
53
|
+
response.body = {
|
54
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
55
|
+
'networkInterfaceId' => network_interface_id
|
56
|
+
}
|
57
|
+
case attribute
|
58
|
+
when 'description', 'groupSet', 'sourceDestCheck', 'attachment'
|
59
|
+
response.body[attribute] = network_interface[attribute]
|
60
|
+
else
|
61
|
+
raise Fog::Compute::AWS::Error.new("Illegal attribute '#{attribute}' specified")
|
62
|
+
end
|
63
|
+
response
|
62
64
|
end
|
63
65
|
end
|
64
66
|
end
|
@@ -66,22 +66,46 @@ module Fog
|
|
66
66
|
'protocol' => 'ipProtocol',
|
67
67
|
'to-port' => 'toPort'
|
68
68
|
}
|
69
|
-
|
69
|
+
|
70
|
+
security_group_groups = lambda do |security_group|
|
71
|
+
(security_group['ipPermissions'] || []).map do |permission|
|
72
|
+
permission['groups']
|
73
|
+
end.flatten.compact.uniq
|
74
|
+
end
|
75
|
+
|
70
76
|
for filter_key, filter_value in filters
|
71
77
|
if permission_key = filter_key.split('ip-permission.')[1]
|
72
78
|
if permission_key == 'group-name'
|
73
|
-
security_group_info = security_group_info.reject
|
79
|
+
security_group_info = security_group_info.reject do |security_group|
|
80
|
+
!security_group_groups.call(security_group).find do |group|
|
81
|
+
[*filter_value].include?(group['groupName'])
|
82
|
+
end
|
83
|
+
end
|
74
84
|
elsif permission_key == 'group-id'
|
75
|
-
security_group_info = security_group_info.reject
|
85
|
+
security_group_info = security_group_info.reject do |security_group|
|
86
|
+
!security_group_groups.call(security_group).find do |group|
|
87
|
+
[*filter_value].include?(group['groupId'])
|
88
|
+
end
|
89
|
+
end
|
76
90
|
elsif permission_key == 'user-id'
|
77
|
-
security_group_info = security_group_info.reject
|
91
|
+
security_group_info = security_group_info.reject do |security_group|
|
92
|
+
!security_group_groups.call(security_group).find do |group|
|
93
|
+
[*filter_value].include?(group['userId'])
|
94
|
+
end
|
95
|
+
end
|
78
96
|
else
|
79
97
|
aliased_key = permission_aliases[filter_key]
|
80
|
-
security_group_info = security_group_info.reject
|
98
|
+
security_group_info = security_group_info.reject do |security_group|
|
99
|
+
!security_group['ipPermissions'].find do |permission|
|
100
|
+
[*filter_value].include?(permission[aliased_key])
|
101
|
+
end
|
102
|
+
end
|
81
103
|
end
|
82
104
|
else
|
83
105
|
aliased_key = aliases[filter_key]
|
84
|
-
security_group_info = security_group_info.reject
|
106
|
+
security_group_info = security_group_info.reject do |security_group|
|
107
|
+
![*filter_value].include?(security_group[aliased_key])
|
108
|
+
end
|
85
109
|
end
|
86
110
|
end
|
87
111
|
|
@@ -14,17 +14,18 @@ module Fog
|
|
14
14
|
# * body<~Hash>:
|
15
15
|
# * 'requestId'<~String> - Id of request
|
16
16
|
# * 'subnetSet'<~Array>:
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
17
|
+
# * 'subnetId'<~String> - The Subnet's ID
|
18
|
+
# * 'state'<~String> - The current state of the Subnet. ['pending', 'available']
|
19
|
+
# * 'vpcId'<~String> - The ID of the VPC the subnet is in
|
20
|
+
# * 'cidrBlock'<~String> - The CIDR block the Subnet covers.
|
21
|
+
# * 'availableIpAddressCount'<~Integer> - The number of unused IP addresses in the subnet (the IP addresses for any
|
22
|
+
# stopped instances are considered unavailable)
|
23
|
+
# * 'availabilityZone'<~String> - The Availability Zone the subnet is in.
|
24
|
+
# * 'tagSet'<~Array>: Tags assigned to the resource.
|
25
|
+
# * 'key'<~String> - Tag's key
|
26
|
+
# * 'value'<~String> - Tag's value
|
27
|
+
# * 'mapPublicIpOnLaunch'<~Boolean> - Indicates whether instances launched in this subnet receive a public IPv4 address.
|
28
|
+
# * 'defaultForAz'<~Boolean> - Indicates whether this is the default subnet for the Availability Zone.
|
28
29
|
#
|
29
30
|
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/2011-07-15/APIReference/index.html?ApiReference-query-DescribeSubnets.html]
|
30
31
|
def describe_subnets(filters = {})
|
@@ -54,11 +54,11 @@ module Fog
|
|
54
54
|
when 'groupSet'
|
55
55
|
groups = {}
|
56
56
|
value.each do |group_id|
|
57
|
-
|
58
|
-
if
|
57
|
+
security_group = self.data[:security_groups][group_id]
|
58
|
+
if security_group.nil?
|
59
59
|
raise Fog::Compute::AWS::Error.new("Unknown security group '#{group_id}' specified")
|
60
60
|
end
|
61
|
-
groups[group_id] =
|
61
|
+
groups[group_id] = security_group['groupName']
|
62
62
|
end
|
63
63
|
nic['groupSet'] = groups
|
64
64
|
when 'sourceDestCheck'
|
@@ -57,40 +57,34 @@ module Fog
|
|
57
57
|
class Mock
|
58
58
|
def revoke_security_group_egress(group_name, options = {})
|
59
59
|
options = Fog::AWS.parse_security_group_options(group_name, options)
|
60
|
-
if options.key?('GroupName')
|
61
|
-
group_name = options['GroupName']
|
62
|
-
else
|
63
|
-
group_name = self.data[:security_groups].reject { |k,v| v['groupId'] != options['GroupId'] } .keys.first
|
64
|
-
end
|
65
60
|
|
61
|
+
group = self.data[:security_groups].values.find { |v| v['groupName'] == group_name }
|
62
|
+
|
63
|
+
group ||
|
64
|
+
raise(Fog::Compute::AWS::NotFound.new("The security group '#{group_name}' does not exist"))
|
66
65
|
response = Excon::Response.new
|
67
|
-
group = self.data[:security_groups][group_name]
|
68
66
|
|
69
|
-
|
70
|
-
verify_permission_options(options, group['vpcId'] != nil)
|
67
|
+
verify_permission_options(options, group['vpcId'] != nil)
|
71
68
|
|
72
|
-
|
69
|
+
normalized_permissions = normalize_permissions(options)
|
73
70
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
71
|
+
normalized_permissions.each do |permission|
|
72
|
+
if matching_permission = find_matching_permission_egress(group, permission)
|
73
|
+
matching_permission['ipRanges'] -= permission['ipRanges']
|
74
|
+
matching_permission['groups'] -= permission['groups']
|
78
75
|
|
79
|
-
|
80
|
-
|
81
|
-
end
|
76
|
+
if matching_permission['ipRanges'].empty? && matching_permission['groups'].empty?
|
77
|
+
group['ipPermissionsEgress'].delete(matching_permission)
|
82
78
|
end
|
83
79
|
end
|
84
|
-
|
85
|
-
response.status = 200
|
86
|
-
response.body = {
|
87
|
-
'requestId' => Fog::AWS::Mock.request_id,
|
88
|
-
'return' => true
|
89
|
-
}
|
90
|
-
response
|
91
|
-
else
|
92
|
-
raise Fog::Compute::AWS::NotFound.new("The security group '#{group_name}' does not exist")
|
93
80
|
end
|
81
|
+
|
82
|
+
response.status = 200
|
83
|
+
response.body = {
|
84
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
85
|
+
'return' => true
|
86
|
+
}
|
87
|
+
response
|
94
88
|
end
|
95
89
|
end
|
96
90
|
end
|
@@ -57,40 +57,33 @@ module Fog
|
|
57
57
|
class Mock
|
58
58
|
def revoke_security_group_ingress(group_name, options = {})
|
59
59
|
options = Fog::AWS.parse_security_group_options(group_name, options)
|
60
|
-
|
61
|
-
group_name = options['GroupName']
|
62
|
-
else
|
63
|
-
group_name = self.data[:security_groups].reject { |k,v| v['groupId'] != options['GroupId'] } .keys.first
|
64
|
-
end
|
60
|
+
group = self.data[:security_groups].values.find { |v| v['groupName'] == group_name }
|
65
61
|
|
62
|
+
group ||
|
63
|
+
raise(Fog::Compute::AWS::NotFound.new("The security group '#{group_name}' does not exist"))
|
66
64
|
response = Excon::Response.new
|
67
|
-
group = self.data[:security_groups][group_name]
|
68
65
|
|
69
|
-
|
70
|
-
verify_permission_options(options, group['vpcId'] != nil)
|
66
|
+
verify_permission_options(options, group['vpcId'] != nil)
|
71
67
|
|
72
|
-
|
68
|
+
normalized_permissions = normalize_permissions(options)
|
73
69
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
70
|
+
normalized_permissions.each do |permission|
|
71
|
+
if matching_permission = find_matching_permission(group, permission)
|
72
|
+
matching_permission['ipRanges'] -= permission['ipRanges']
|
73
|
+
matching_permission['groups'] -= permission['groups']
|
78
74
|
|
79
|
-
|
80
|
-
|
81
|
-
end
|
75
|
+
if matching_permission['ipRanges'].empty? && matching_permission['groups'].empty?
|
76
|
+
group['ipPermissions'].delete(matching_permission)
|
82
77
|
end
|
83
78
|
end
|
84
|
-
|
85
|
-
response.status = 200
|
86
|
-
response.body = {
|
87
|
-
'requestId' => Fog::AWS::Mock.request_id,
|
88
|
-
'return' => true
|
89
|
-
}
|
90
|
-
response
|
91
|
-
else
|
92
|
-
raise Fog::Compute::AWS::NotFound.new("The security group '#{group_name}' does not exist")
|
93
79
|
end
|
80
|
+
|
81
|
+
response.status = 200
|
82
|
+
response.body = {
|
83
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
84
|
+
'return' => true
|
85
|
+
}
|
86
|
+
response
|
94
87
|
end
|
95
88
|
end
|
96
89
|
end
|
@@ -48,7 +48,7 @@ module Fog
|
|
48
48
|
# * 'SecurityGroupId'<~Array> or <~String> - id's of security group(s) for instances, use this or SecurityGroup
|
49
49
|
# * 'InstanceInitiatedShutdownBehaviour'<~String> - specifies whether volumes are stopped or terminated when instance is shutdown, in [stop, terminate]
|
50
50
|
# * 'InstanceType'<~String> - Type of instance to boot. Valid options
|
51
|
-
# in ['t1.micro', 't2.micro', 't2.small', 't2.medium', 'm1.small', 'm1.medium', 'm1.large', 'm1.xlarge', 'c1.medium', 'c1.xlarge', 'c3.large', 'c3.xlarge', 'c3.2xlarge', 'c3.4xlarge', 'c3.8xlarge', 'g2.2xlarge', 'hs1.8xlarge', 'm2.xlarge', 'm2.2xlarge', 'm2.4xlarge', 'cr1.8xlarge', 'm3.xlarge', 'm3.2xlarge', 'hi1.4xlarge', 'cc1.4xlarge', 'cc2.8xlarge', 'cg1.4xlarge', 'i2.xlarge', 'i2.2xlarge', 'i2.4xlarge', 'i2.8xlarge']
|
51
|
+
# in ['t1.micro', 't2.nano', 't2.micro', 't2.small', 't2.medium', 'm1.small', 'm1.medium', 'm1.large', 'm1.xlarge', 'c1.medium', 'c1.xlarge', 'c3.large', 'c3.xlarge', 'c3.2xlarge', 'c3.4xlarge', 'c3.8xlarge', 'g2.2xlarge', 'hs1.8xlarge', 'm2.xlarge', 'm2.2xlarge', 'm2.4xlarge', 'cr1.8xlarge', 'm3.xlarge', 'm3.2xlarge', 'hi1.4xlarge', 'cc1.4xlarge', 'cc2.8xlarge', 'cg1.4xlarge', 'i2.xlarge', 'i2.2xlarge', 'i2.4xlarge', 'i2.8xlarge']
|
52
52
|
# default is 'm1.small'
|
53
53
|
# * 'KernelId'<~String> - Id of kernel with which to launch
|
54
54
|
# * 'KeyName'<~String> - Name of a keypair to add to booting instances
|
@@ -25,8 +25,10 @@ module Fog
|
|
25
25
|
class Mock
|
26
26
|
def create_mount_target(file_system_id, subnet_id, options={})
|
27
27
|
response = Excon::Response.new
|
28
|
-
default_security_group = mock_compute.data[:security_groups]
|
29
|
-
|
28
|
+
default_security_group = mock_compute.data[:security_groups].find do |_, sg|
|
29
|
+
sg['groupDescription'] == 'default_elb security group'
|
30
|
+
end
|
31
|
+
security_groups = options["SecurityGroups"] || [default_security_group.first]
|
30
32
|
|
31
33
|
unless file_system = self.data[:file_systems][file_system_id]
|
32
34
|
raise Fog::AWS::EFS::NotFound.new("invalid file system ID: #{file_system_id}")
|
@@ -41,8 +43,10 @@ module Fog
|
|
41
43
|
raise Fog::AWS::EFS::InvalidSubnet.new("invalid subnet ID: #{subnet_id}")
|
42
44
|
end
|
43
45
|
|
44
|
-
security_groups.each do |
|
45
|
-
|
46
|
+
security_groups.each do |group_id|
|
47
|
+
unless mock_compute.data[:security_groups][group_id]
|
48
|
+
raise Fog::AWS::EFS::NotFound.new("invalid security group ID: #{group_id}")
|
49
|
+
end
|
46
50
|
end
|
47
51
|
|
48
52
|
id = "fsmt-#{Fog::Mock.random_letters(8)}"
|
@@ -111,53 +111,22 @@ module Fog
|
|
111
111
|
when 'EC2-Classic'
|
112
112
|
Fog::Compute::AWS::Mock.data[region][@aws_access_key_id][:security_groups]['amazon-elb-sg']
|
113
113
|
when 'EC2-VPC-Default'
|
114
|
-
# find or create default vpc
|
115
114
|
compute = Fog::Compute::AWS::new(:aws_access_key_id => @aws_access_key_id, :aws_secret_access_key => @aws_secret_access_key)
|
116
|
-
unless vpc = compute.vpcs.all.first
|
117
|
-
vpc = compute.vpcs.create('cidr_block' => '10.0.0.0/24')
|
118
|
-
end
|
119
115
|
|
120
|
-
|
116
|
+
vpc = compute.vpcs.all.first ||
|
117
|
+
compute.vpcs.create('cidr_block' => '10.0.0.0/24')
|
118
|
+
|
119
|
+
Fog::Compute::AWS::Mock.data[region][@aws_access_key_id][:security_groups].values.find { |sg|
|
121
120
|
sg['groupName'] =~ /^default_elb/ &&
|
122
121
|
sg["vpcId"] == vpc.id
|
123
122
|
}
|
124
|
-
|
125
|
-
unless default_sg
|
126
|
-
default_sg = {
|
127
|
-
'groupDescription' => 'default_elb security group',
|
128
|
-
'groupName' => "default_elb_#{Fog::Mock.random_hex(6)}",
|
129
|
-
'groupId' => Fog::AWS::Mock.security_group_id,
|
130
|
-
'ipPermissionsEgress' => [],
|
131
|
-
'ipPermissions' => [],
|
132
|
-
'ownerId' => self.data[:owner_id],
|
133
|
-
'vpcId' => vpc.id
|
134
|
-
}
|
135
|
-
Fog::Compute::AWS::Mock.data[region][@aws_access_key_id][:security_groups]['default'] = default_sg
|
136
|
-
end
|
137
|
-
|
138
|
-
default_sg
|
139
123
|
when 'EC2-VPC'
|
140
|
-
# find or create default vpc security group
|
141
124
|
vpc_id = subnets.first["vpcId"]
|
142
|
-
|
125
|
+
|
126
|
+
Fog::Compute::AWS::Mock.data[region][@aws_access_key_id][:security_groups].values.find { |sg|
|
143
127
|
sg['groupName'] == 'default' &&
|
144
128
|
sg["vpcId"] == vpc_id
|
145
129
|
}
|
146
|
-
|
147
|
-
unless default_sg
|
148
|
-
default_sg = {
|
149
|
-
'groupDescription' => 'default elb security group',
|
150
|
-
'groupName' => 'default',
|
151
|
-
'groupId' => Fog::AWS::Mock.security_group_id,
|
152
|
-
'ipPermissionsEgress' => [],
|
153
|
-
'ipPermissions' => [],
|
154
|
-
'ownerId' => self.data[:owner_id],
|
155
|
-
'vpcId' => vpc_id
|
156
|
-
}
|
157
|
-
Fog::Compute::AWS::Mock.data[region][@aws_access_key_id][:security_groups]['default'] = default_sg
|
158
|
-
end
|
159
|
-
|
160
|
-
default_sg
|
161
130
|
end
|
162
131
|
self.data[:tags] ||= {}
|
163
132
|
self.data[:tags][lb_name] = {}
|