fog-aws 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/fog/aws/compute.rb +7 -1
- data/lib/fog/aws/parsers/compute/describe_classic_link_instances.rb +60 -0
- data/lib/fog/aws/parsers/compute/describe_vpc_classic_link.rb +47 -0
- data/lib/fog/aws/rds.rb +2 -0
- data/lib/fog/aws/requests/compute/attach_classic_link_vpc.rb +67 -0
- data/lib/fog/aws/requests/compute/create_vpc.rb +2 -1
- data/lib/fog/aws/requests/compute/describe_classic_link_instances.rb +73 -0
- data/lib/fog/aws/requests/compute/describe_vpc_classic_link.rb +63 -0
- data/lib/fog/aws/requests/compute/detach_classic_link_vpc.rb +60 -0
- data/lib/fog/aws/requests/compute/disable_vpc_classic_link.rb +47 -0
- data/lib/fog/aws/requests/compute/enable_vpc_classic_link.rb +47 -0
- data/lib/fog/aws/requests/compute/stop_instances.rb +2 -0
- data/lib/fog/aws/requests/compute/terminate_instances.rb +2 -0
- data/lib/fog/aws/requests/sns/create_topic.rb +1 -1
- data/lib/fog/aws/requests/sns/subscribe.rb +26 -0
- data/lib/fog/aws/sns.rb +6 -1
- data/lib/fog/aws/version.rb +1 -1
- data/tests/requests/compute/vpc_tests.rb +60 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30d84e3705aeee14d91a9c82f15fb312a5f4c639
|
4
|
+
data.tar.gz: c0ad1b0157cdf4f1d5afc87e0db4abc1e1f33e64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43f3f056697c6d3407f6c4f0f7f6bc1ab0b7b50f01118a16fb7e095965da5d04edf044a01b8931c4b3c60c8cb8f00744b53160330ccaa3e190a20a5228e4a4e4
|
7
|
+
data.tar.gz: c5305530afe5c59a43f8cc93cfe9e0ab4cdbd6bdc6037a5b2790deff609ebdeb6a220a7aa1f48eb6c1b7f020e163098bc6ba586160dcb06cb52de2bb353f8dd6
|
data/lib/fog/aws/compute.rb
CHANGED
@@ -53,6 +53,7 @@ module Fog
|
|
53
53
|
request :associate_dhcp_options
|
54
54
|
request :attach_network_interface
|
55
55
|
request :associate_route_table
|
56
|
+
request :attach_classic_link_vpc
|
56
57
|
request :attach_internet_gateway
|
57
58
|
request :attach_volume
|
58
59
|
request :authorize_security_group_ingress
|
@@ -96,6 +97,7 @@ module Fog
|
|
96
97
|
request :describe_account_attributes
|
97
98
|
request :describe_addresses
|
98
99
|
request :describe_availability_zones
|
100
|
+
request :describe_classic_link_instances
|
99
101
|
request :describe_dhcp_options
|
100
102
|
request :describe_images
|
101
103
|
request :describe_instances
|
@@ -121,11 +123,15 @@ module Fog
|
|
121
123
|
request :describe_volume_status
|
122
124
|
request :describe_vpcs
|
123
125
|
request :describe_vpc_attribute
|
126
|
+
request :describe_vpc_classic_link
|
124
127
|
request :detach_network_interface
|
125
128
|
request :detach_internet_gateway
|
126
129
|
request :detach_volume
|
130
|
+
request :detach_classic_link_vpc
|
131
|
+
request :disable_vpc_classic_link
|
127
132
|
request :disassociate_address
|
128
133
|
request :disassociate_route_table
|
134
|
+
request :enable_vpc_classic_link
|
129
135
|
request :get_console_output
|
130
136
|
request :get_password_data
|
131
137
|
request :import_key_pair
|
@@ -454,7 +460,7 @@ module Fog
|
|
454
460
|
@region = options[:region] ||= 'us-east-1'
|
455
461
|
@instrumentor = options[:instrumentor]
|
456
462
|
@instrumentor_name = options[:instrumentor_name] || 'fog.aws.compute'
|
457
|
-
@version = options[:version] || '2014-
|
463
|
+
@version = options[:version] || '2014-10-01'
|
458
464
|
|
459
465
|
@use_iam_profile = options[:use_iam_profile]
|
460
466
|
setup_credentials(options)
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module Compute
|
4
|
+
module AWS
|
5
|
+
class DescribeClassicLinkInstances < Fog::Parsers::Base
|
6
|
+
def reset
|
7
|
+
@instance = { 'tagSet' => {}, 'groups' => [] }
|
8
|
+
@response = { 'instancesSet' => [] }
|
9
|
+
@tag = {}
|
10
|
+
@group = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def start_element(name, attrs = [])
|
14
|
+
super
|
15
|
+
case name
|
16
|
+
when 'groupSet'
|
17
|
+
@in_group_set = true
|
18
|
+
when 'tagSet'
|
19
|
+
@in_tag_set = true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def end_element(name)
|
24
|
+
if @in_tag_set
|
25
|
+
case name
|
26
|
+
when 'item'
|
27
|
+
@instance['tagSet'][@tag['key']] = @tag['value']
|
28
|
+
@tag = {}
|
29
|
+
when 'key', 'value'
|
30
|
+
@tag[name] = value
|
31
|
+
when 'tagSet'
|
32
|
+
@in_tag_set = false
|
33
|
+
end
|
34
|
+
elsif @in_group_set
|
35
|
+
case name
|
36
|
+
when 'item'
|
37
|
+
@instance['groups'] << @group
|
38
|
+
@group = {}
|
39
|
+
when 'groupId', 'groupName'
|
40
|
+
@group[name] = value
|
41
|
+
when 'groupSet'
|
42
|
+
@in_group_set = false
|
43
|
+
end
|
44
|
+
else
|
45
|
+
case name
|
46
|
+
when 'vpcId', 'instanceId'
|
47
|
+
@instance[name] = value
|
48
|
+
when 'item'
|
49
|
+
@response['instancesSet'] << @instance
|
50
|
+
@instance = { 'tagSet' => {}, 'groups' => [] }
|
51
|
+
when 'requestId', 'nextToken'
|
52
|
+
@response[name] = value
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module Compute
|
4
|
+
module AWS
|
5
|
+
class DescribeVpcClassicLink < Fog::Parsers::Base
|
6
|
+
def reset
|
7
|
+
@vpc = { 'tagSet' => {} }
|
8
|
+
@response = { 'vpcSet' => [] }
|
9
|
+
@tag = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def start_element(name, attrs = [])
|
13
|
+
super
|
14
|
+
case name
|
15
|
+
when 'tagSet'
|
16
|
+
@in_tag_set = true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def end_element(name)
|
21
|
+
if @in_tag_set
|
22
|
+
case name
|
23
|
+
when 'item'
|
24
|
+
@vpc['tagSet'][@tag['key']] = @tag['value']
|
25
|
+
@tag = {}
|
26
|
+
when 'key', 'value'
|
27
|
+
@tag[name] = value
|
28
|
+
when 'tagSet'
|
29
|
+
@in_tag_set = false
|
30
|
+
end
|
31
|
+
else
|
32
|
+
case name
|
33
|
+
when 'vpcId', 'classicLinkEnabled'
|
34
|
+
@vpc[name] = value
|
35
|
+
when 'item'
|
36
|
+
@response['vpcSet'] << @vpc
|
37
|
+
@vpc = { 'tagSet' => {} }
|
38
|
+
when 'requestId'
|
39
|
+
@response[name] = value
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/fog/aws/rds.rb
CHANGED
@@ -0,0 +1,67 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class AWS
|
4
|
+
class Real
|
5
|
+
require 'fog/aws/parsers/compute/basic'
|
6
|
+
# Links an EC2-Classic instance to a ClassicLink-enabled VPC through one or more of the VPC's security groups
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# * vpc_id<~String> - The ID of a ClassicLink-enabled VPC.
|
10
|
+
# * instance_id<~String> - The ID of an EC2-Classic instance to link to the ClassicLink-enabled VPC.
|
11
|
+
# * security_group_ids<~String> - The ID of one or more of the VPC's security groups. You cannot specify security groups from a different VPC.
|
12
|
+
# * dry_run<~Boolean> - defaults to false
|
13
|
+
#
|
14
|
+
# === Returns
|
15
|
+
# * response<~Excon::Response>:
|
16
|
+
# * body<~Hash>:
|
17
|
+
# * 'requestId'<~String> - Id of request
|
18
|
+
# * 'return'<~Boolean> - Whether the request succeeded
|
19
|
+
#
|
20
|
+
# (Amazon API Reference)[http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_AttachClassicLinkVpc.html]
|
21
|
+
def attach_classic_link_vpc(instance_id, vpc_id, security_group_ids, dry_run=false)
|
22
|
+
request({
|
23
|
+
'Action' => 'AttachClassicLinkVpc',
|
24
|
+
'VpcId' => vpc_id,
|
25
|
+
'InstanceId'=> instance_id,
|
26
|
+
'DryRun' => dry_run,
|
27
|
+
:parser => Fog::Parsers::Compute::AWS::Basic.new
|
28
|
+
}.merge(Fog::AWS.indexed_param('SecurityGroupId', security_group_ids)))
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
class Mock
|
35
|
+
def attach_classic_link_vpc(instance_id, vpc_id, security_group_ids, dry_run=false)
|
36
|
+
response = Excon::Response.new
|
37
|
+
vpc = self.data[:vpcs].find{ |v| v['vpcId'] == vpc_id }
|
38
|
+
instance = self.data[:instances][instance_id]
|
39
|
+
if vpc && instance
|
40
|
+
if instance['instanceState']['name'] != 'running' || instance['vpcId']
|
41
|
+
raise Fog::Compute::AWS::Error.new("Client.InvalidInstanceID.NotLinkable => Instance #{instance_id} is unlinkable")
|
42
|
+
end
|
43
|
+
if instance['classicLinkVpcId']
|
44
|
+
raise Fog::Compute::AWS::Error.new("Client.InvalidInstanceID.InstanceAlreadyLinked => Instance #{instance_id} is already linked")
|
45
|
+
end
|
46
|
+
|
47
|
+
response.status = 200
|
48
|
+
response.body = {
|
49
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
50
|
+
'return' => true
|
51
|
+
}
|
52
|
+
unless dry_run
|
53
|
+
instance['classicLinkSecurityGroups'] = security_group_ids
|
54
|
+
instance['classicLinkVpcId'] = vpc_id
|
55
|
+
end
|
56
|
+
response
|
57
|
+
elsif !instance
|
58
|
+
raise Fog::Compute::AWS::NotFound.new("The instance ID '#{instance_id}' does not exist.")
|
59
|
+
elsif !vpc
|
60
|
+
raise Fog::Compute::AWS::NotFound.new("The VPC '#{vpc_id}' does not exist.")
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class AWS
|
4
|
+
class Real
|
5
|
+
require 'fog/aws/parsers/compute/describe_classic_link_instances'
|
6
|
+
# Describes one or more of your linked EC2-Classic instances. This request only returns information about EC2-Classic instances linked to a VPC through ClassicLink; you cannot use this request to return information about other instances.
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# * options<~Hash>
|
10
|
+
# * instance_ids<~Array> - An array of instance ids to restruct the results to
|
11
|
+
# * filters<~Hash> - Filters to restrict the results to. Recognises vpc-id, group-id, instance-id in addition
|
12
|
+
# to tag-key, tag-value and tag:key
|
13
|
+
# * max_results
|
14
|
+
# * next_token
|
15
|
+
# === Returns
|
16
|
+
# * response<~Excon::Response>:
|
17
|
+
# * body<~Hash>:
|
18
|
+
# * 'requestId'<~String> - Id of request
|
19
|
+
# * 'instancesSet'<~Array> - array of ClassicLinkInstance
|
20
|
+
# * 'vpcId'<~String>
|
21
|
+
# * 'instanceId'<~String>
|
22
|
+
# * 'tagSet'<~Hash>
|
23
|
+
# * 'groups'<~Array>
|
24
|
+
# * groupId <~String>
|
25
|
+
# * groupName <~String>
|
26
|
+
# (Amazon API Reference)[http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeClassicLinkInstances.html
|
27
|
+
def describe_classic_link_instances(options={})
|
28
|
+
params = {}
|
29
|
+
params['MaxResults'] = options[:max_results] if options[:max_results]
|
30
|
+
params['NextToken'] = options[:next_token] if options[:next_token]
|
31
|
+
params.merge!(Fog::AWS.indexed_param('InstanceId', options[:instance_ids])) if options[:instance_ids]
|
32
|
+
params.merge!(Fog::AWS.indexed_filters(options[:filters])) if options[:filters]
|
33
|
+
request({
|
34
|
+
'Action' => 'DescribeClassicLinkInstances',
|
35
|
+
:parser => Fog::Parsers::Compute::AWS::DescribeClassicLinkInstances.new
|
36
|
+
}.merge(params))
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class Mock
|
41
|
+
def describe_classic_link_instances(options={})
|
42
|
+
response = Excon::Response.new
|
43
|
+
instances = self.data[:instances].values.select {|instance| instance['classicLinkVpcId']}
|
44
|
+
if options[:filters]
|
45
|
+
instances = apply_tag_filters(instances, options[:filters], 'instanceId')
|
46
|
+
instances = instances.select {|instance| instance['classicLinkVpcId'] == options[:filters]['vpc-id']} if options[:filters]['vpc-id']
|
47
|
+
instances = instances.select {|instance| instance['instanceId'] == options[:filters]['instance-id']} if options[:filters]['instance-id']
|
48
|
+
instances = instances.select {|instance| instance['classicLinkSecurityGroups'].include?(options[:filters]['group-id'])} if options[:filters]['group-id']
|
49
|
+
end
|
50
|
+
instances = instances.select {|instance| options[:instance_ids].include?(instance['instanceId'])} if options[:instance_ids]
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
response.status = 200
|
55
|
+
instance_data = instances.collect do |instance|
|
56
|
+
groups = self.data[:security_groups].values.select {|data| instance['classicLinkSecurityGroups'].include?(data['groupId'])}
|
57
|
+
{
|
58
|
+
'instanceId' => instance['instanceId'],
|
59
|
+
'vpcId' => instance['classicLinkVpcId'],
|
60
|
+
'groups' => groups.collect {|group| {'groupId' => group['groupId'], 'groupName' => group['groupName']}},
|
61
|
+
'tagSet' => self.data[:tag_sets][instance['instanceId']] || {}
|
62
|
+
}
|
63
|
+
end
|
64
|
+
response.body = {
|
65
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
66
|
+
'instancesSet' => instance_data
|
67
|
+
}
|
68
|
+
response
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class AWS
|
4
|
+
class Real
|
5
|
+
require 'fog/aws/parsers/compute/describe_vpc_classic_link'
|
6
|
+
# Describes the ClassicLink status of one or more VPCs.
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# * options<~Hash>
|
10
|
+
# * vpc_ids<~Array> - An array of vpc ids to restruct the results to
|
11
|
+
# * filters<~Hash> - Filters to restrict the results to. Recognises is-classic-link-enabled in addition
|
12
|
+
# to tag-key, tag-value and tag:key
|
13
|
+
# === Returns
|
14
|
+
# * response<~Excon::Response>:
|
15
|
+
# * body<~Hash>:
|
16
|
+
# * 'requestId'<~String> - Id of request
|
17
|
+
# * 'vpcSet'<~Array> - array of VpcClassicLink
|
18
|
+
# * 'vpcId'<~String>
|
19
|
+
# * 'classicLinkEnabled'<~Boolean>
|
20
|
+
# * 'tagSet'<~Hash>
|
21
|
+
#
|
22
|
+
# (Amazon API Reference)[http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeVpcClassicLink.html
|
23
|
+
def describe_vpc_classic_link(options={})
|
24
|
+
params = {}
|
25
|
+
params.merge!(Fog::AWS.indexed_param('VpcId', options[:vpc_ids])) if options[:vpc_ids]
|
26
|
+
params.merge!(Fog::AWS.indexed_filters(options[:filters])) if options[:filters]
|
27
|
+
request({
|
28
|
+
'Action' => 'DescribeVpcClassicLink',
|
29
|
+
:parser => Fog::Parsers::Compute::AWS::DescribeVpcClassicLink.new
|
30
|
+
}.merge(params))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class Mock
|
35
|
+
def describe_vpc_classic_link(options={})
|
36
|
+
response = Excon::Response.new
|
37
|
+
vpcs = self.data[:vpcs]
|
38
|
+
if vpc_ids = options[:vpc_ids]
|
39
|
+
vpcs = vpc_ids.collect do |vpc_id|
|
40
|
+
vpc = vpcs.find{ |v| v['vpcId'] == vpc_id }
|
41
|
+
raise Fog::Compute::AWS::NotFound.new("The VPC '#{vpc_id}' does not exist") unless vpc
|
42
|
+
vpc
|
43
|
+
end
|
44
|
+
end
|
45
|
+
vpcs = apply_tag_filters(vpcs, options[:filters], 'vpcId') if options[:filters]
|
46
|
+
|
47
|
+
response.status = 200
|
48
|
+
vpc_data = vpcs.collect do |vpc|
|
49
|
+
{
|
50
|
+
'vpcId' => vpc['vpcId'],
|
51
|
+
'classicLinkEnabled' => vpc['classicLinkEnabled'],
|
52
|
+
'tagSet' => self.data[:tag_sets][vpc['vpcId']] || {}
|
53
|
+
}
|
54
|
+
end
|
55
|
+
response.body = {
|
56
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
57
|
+
'vpcSet' => vpc_data
|
58
|
+
}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class AWS
|
4
|
+
class Real
|
5
|
+
require 'fog/aws/parsers/compute/basic'
|
6
|
+
# Links an EC2-Classic instance to a ClassicLink-enabled VPC through one or more of the VPC's security groups
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# * vpc_id<~String> - The ID of the vpc to which the instance is linkced.
|
10
|
+
# * instance_id<~String> - The ID of an EC2-Classic instance to unlink from the vpc.
|
11
|
+
# * security_group_ids<~String> - The ID of one or more of the VPC's security groups. You cannot specify security groups from a different VPC.
|
12
|
+
# * dry_run<~Boolean> - defaults to false
|
13
|
+
#
|
14
|
+
# === Returns
|
15
|
+
# * response<~Excon::Response>:
|
16
|
+
# * body<~Hash>:
|
17
|
+
# * 'requestId'<~String> - Id of request
|
18
|
+
# * 'return'<~Boolean> - Whether the request succeeded
|
19
|
+
#
|
20
|
+
# (Amazon API Reference)[http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DetachClassicLinkVpc.html]
|
21
|
+
def detach_classic_link_vpc(instance_id, vpc_id, dry_run=false)
|
22
|
+
request(
|
23
|
+
'Action' => 'DetachClassicLinkVpc',
|
24
|
+
'VpcId' => vpc_id,
|
25
|
+
'InstanceId'=> instance_id,
|
26
|
+
'DryRun' => dry_run,
|
27
|
+
:parser => Fog::Parsers::Compute::AWS::Basic.new
|
28
|
+
)
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
class Mock
|
35
|
+
def detach_classic_link_vpc(instance_id, vpc_id, dry_run=false)
|
36
|
+
response = Excon::Response.new
|
37
|
+
vpc = self.data[:vpcs].find{ |v| v['vpcId'] == vpc_id }
|
38
|
+
instance = self.data[:instances][instance_id]
|
39
|
+
if vpc && instance
|
40
|
+
response.status = 200
|
41
|
+
response.body = {
|
42
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
43
|
+
'return' => true
|
44
|
+
}
|
45
|
+
unless dry_run
|
46
|
+
instance['classicLinkSecurityGroups'] = nil
|
47
|
+
instance['classicLinkVpcId'] = nil
|
48
|
+
end
|
49
|
+
response
|
50
|
+
elsif !instance
|
51
|
+
raise Fog::Compute::AWS::NotFound.new("The instance ID '#{instance_id}' does not exist.")
|
52
|
+
elsif !vpc
|
53
|
+
raise Fog::Compute::AWS::NotFound.new("The VPC '#{vpc_id}' does not exist.")
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class AWS
|
4
|
+
class Real
|
5
|
+
require 'fog/aws/parsers/compute/basic'
|
6
|
+
# disavbles classic link for a vpc
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# * vpc_id<~String> - The ID of the VPC you want to describe an attribute of
|
10
|
+
# * dry_run<~Boolean> - defaults to false
|
11
|
+
#
|
12
|
+
# === Returns
|
13
|
+
# * response<~Excon::Response>:
|
14
|
+
# * body<~Hash>:
|
15
|
+
# * 'requestId'<~String> - Id of request
|
16
|
+
# * 'return'<~Boolean> - Whether the request succeeded
|
17
|
+
#
|
18
|
+
# (Amazon API Reference)[http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DisableVpcClassicLink.html]
|
19
|
+
def disable_vpc_classic_link(vpc_id, dry_run=false)
|
20
|
+
request(
|
21
|
+
'Action' => 'DisableVpcClassicLink',
|
22
|
+
'VpcId' => vpc_id,
|
23
|
+
'DryRun' => dry_run,
|
24
|
+
:parser => Fog::Parsers::Compute::AWS::Basic.new
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class Mock
|
30
|
+
def disable_vpc_classic_link(vpc_id, dry_run=false)
|
31
|
+
response = Excon::Response.new
|
32
|
+
if vpc = self.data[:vpcs].find{ |v| v['vpcId'] == vpc_id }
|
33
|
+
response.status = 200
|
34
|
+
response.body = {
|
35
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
36
|
+
'return' => true
|
37
|
+
}
|
38
|
+
vpc['classicLinkEnabled'] = false unless dry_run
|
39
|
+
response
|
40
|
+
else
|
41
|
+
raise Fog::Compute::AWS::NotFound.new("The VPC '#{vpc_id}' does not exist")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class AWS
|
4
|
+
class Real
|
5
|
+
require 'fog/aws/parsers/compute/basic'
|
6
|
+
# enables classic link for a vpc
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# * vpc_id<~String> - The ID of the VPC you want to describe an attribute of
|
10
|
+
# * dry_run<~Boolean> - defaults to false
|
11
|
+
#
|
12
|
+
# === Returns
|
13
|
+
# * response<~Excon::Response>:
|
14
|
+
# * body<~Hash>:
|
15
|
+
# * 'requestId'<~String> - Id of request
|
16
|
+
# * 'return'<~Boolean> - Whether the request succeeded
|
17
|
+
#
|
18
|
+
# (Amazon API Reference)[http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_EnableVpcClassicLink.html]
|
19
|
+
def enable_vpc_classic_link(vpc_id, dry_run=false)
|
20
|
+
request(
|
21
|
+
'Action' => 'EnableVpcClassicLink',
|
22
|
+
'VpcId' => vpc_id,
|
23
|
+
'DryRun' => dry_run,
|
24
|
+
:parser => Fog::Parsers::Compute::AWS::Basic.new
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class Mock
|
30
|
+
def enable_vpc_classic_link(vpc_id, dry_run=false)
|
31
|
+
response = Excon::Response.new
|
32
|
+
if vpc = self.data[:vpcs].find{ |v| v['vpcId'] == vpc_id }
|
33
|
+
response.status = 200
|
34
|
+
response.body = {
|
35
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
36
|
+
'return' => true
|
37
|
+
}
|
38
|
+
vpc['classicLinkEnabled'] = true unless dry_run
|
39
|
+
response
|
40
|
+
else
|
41
|
+
raise Fog::Compute::AWS::NotFound.new("The VPC '#{vpc_id}' does not exist")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -43,6 +43,8 @@ module Fog
|
|
43
43
|
|
44
44
|
response.body = {
|
45
45
|
'instancesSet' => instance_set.reduce([]) do |ia, instance|
|
46
|
+
instance['classicLinkSecurityGroups'] = nil
|
47
|
+
instance['classicLinkVpcId'] = nil
|
46
48
|
ia << {'currentState' => { 'code' => 0, 'name' => 'stopping' },
|
47
49
|
'previousState' => instance['instanceState'],
|
48
50
|
'instanceId' => instance['instanceId'] }
|
@@ -45,6 +45,8 @@ module Fog
|
|
45
45
|
response.status = 200
|
46
46
|
for id in instance_id
|
47
47
|
instance = self.data[:instances][id]
|
48
|
+
instance['classicLinkSecurityGroups'] = nil
|
49
|
+
instance['classicLinkVpcId'] = nil
|
48
50
|
self.data[:deleted_at][id] = Time.now
|
49
51
|
code = case instance['instanceState']['name']
|
50
52
|
when 'pending'
|
@@ -29,7 +29,7 @@ module Fog
|
|
29
29
|
topic_arn = Fog::AWS::Mock.arn(@module, @account_id, name, @region)
|
30
30
|
|
31
31
|
self.data[:topics][topic_arn] = {
|
32
|
-
"Owner" =>
|
32
|
+
"Owner" => @account_id,
|
33
33
|
"SubscriptionsPending" => 0,
|
34
34
|
"SubscriptionsConfirmed" => 0,
|
35
35
|
"SubscriptionsDeleted" => 0,
|
@@ -51,6 +51,32 @@ module Fog
|
|
51
51
|
"Endpoint" => endpoint,
|
52
52
|
}
|
53
53
|
|
54
|
+
mock_data = Fog::AWS::SQS::Mock.data.values.find { |a| a.values.find { |d| d[:queues][endpoint] } }
|
55
|
+
access_key = mock_data && mock_data.keys.first
|
56
|
+
|
57
|
+
if protocol == "sqs" && access_key
|
58
|
+
token = SecureRandom.hex(128)
|
59
|
+
message = "You have chosen to subscribe to the topic #{arn}.\nTo confirm the subscription, visit the SubscribeURL included in this message."
|
60
|
+
signature = Fog::HMAC.new("sha256", token).sign(message)
|
61
|
+
|
62
|
+
Fog::AWS::SQS.new(
|
63
|
+
:region => self.region,
|
64
|
+
:aws_access_key_id => access_key,
|
65
|
+
:aws_secret_access_key => SecureRandom.hex(3)
|
66
|
+
).send_message(endpoint, Fog::JSON.encode(
|
67
|
+
"Type" => "SubscriptionConfirmation",
|
68
|
+
"MessageId" => SecureRandom.uuid,
|
69
|
+
"Token" => token,
|
70
|
+
"TopicArn" => arn,
|
71
|
+
"Message" => message,
|
72
|
+
"SubscribeURL" => "https://sns.#{self.region}.amazonaws.com/?Action=ConfirmSubscription&TopicArn=#{arn}&Token=#{token}",
|
73
|
+
"Timestamp" => Time.now.iso8601,
|
74
|
+
"SignatureVersion" => "1",
|
75
|
+
"Signature" => signature,
|
76
|
+
"SigningCertURL" => "https://sns.#{self.region}.amazonaws.com/SimpleNotificationService-#{SecureRandom.hex(16)}.pem"
|
77
|
+
))
|
78
|
+
end
|
79
|
+
|
54
80
|
response.body = { 'SubscriptionArn' => 'pending confirmation', 'RequestId' => Fog::AWS::Mock.request_id }
|
55
81
|
response
|
56
82
|
end
|
data/lib/fog/aws/sns.rb
CHANGED
@@ -39,10 +39,13 @@ module Fog
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
attr_reader :region
|
43
|
+
attr_writer :account_id
|
44
|
+
|
42
45
|
def initialize(options={})
|
43
46
|
@region = options[:region] || 'us-east-1'
|
44
47
|
@aws_access_key_id = options[:aws_access_key_id]
|
45
|
-
@account_id =
|
48
|
+
@account_id = Fog::AWS::Mock.owner_id
|
46
49
|
@module = "sns"
|
47
50
|
|
48
51
|
unless ['ap-northeast-1', 'ap-southeast-1', 'ap-southeast-2', 'eu-central-1', 'eu-west-1', 'us-east-1', 'us-west-1', 'us-west-2', 'sa-east-1'].include?(@region)
|
@@ -97,6 +100,8 @@ module Fog
|
|
97
100
|
setup_credentials(options)
|
98
101
|
end
|
99
102
|
|
103
|
+
attr_reader :region
|
104
|
+
|
100
105
|
def reload
|
101
106
|
@connection.reset
|
102
107
|
end
|
data/lib/fog/aws/version.rb
CHANGED
@@ -11,6 +11,25 @@ Shindo.tests('Fog::Compute[:aws] | vpc requests', ['aws']) do
|
|
11
11
|
'requestId' => String
|
12
12
|
}
|
13
13
|
|
14
|
+
@describe_vpcs_classic_link_format = {
|
15
|
+
'vpcSet' => [{
|
16
|
+
'vpcId' => String,
|
17
|
+
'tagSet' => Hash,
|
18
|
+
'classicLinkEnabled' => Fog::Boolean
|
19
|
+
}],
|
20
|
+
'requestId' => String
|
21
|
+
}
|
22
|
+
@describe_classic_link_instances = {
|
23
|
+
'instancesSet' => [{
|
24
|
+
'vpcId' => String,
|
25
|
+
'tagSet' => Hash,
|
26
|
+
'instanceId' => String,
|
27
|
+
'groups' => [{'groupId' => String, 'groupName' => String}]
|
28
|
+
}],
|
29
|
+
'requestId' => String,
|
30
|
+
'NextToken' => Fog::Nullable::String
|
31
|
+
}
|
32
|
+
|
14
33
|
@describe_vpcs_format = {
|
15
34
|
'vpcSet' => [{
|
16
35
|
'vpcId' => String,
|
@@ -99,6 +118,47 @@ Shindo.tests('Fog::Compute[:aws] | vpc requests', ['aws']) do
|
|
99
118
|
body
|
100
119
|
end
|
101
120
|
|
121
|
+
tests("describe_vpc_classic_link(:filters => {'tag-key' => 'foo'}").formats(@describe_vpcs_classic_link_format) do
|
122
|
+
body = Fog::Compute[:aws].describe_vpc_classic_link(:filters => {'tag-key' => 'foo'})
|
123
|
+
tests("returns 1 vpc").returns(1) { body['vpcSet'].size }
|
124
|
+
body
|
125
|
+
end
|
126
|
+
|
127
|
+
tests("enable_vpc_classic_link").returns(true) do
|
128
|
+
Fog::Compute[:aws].enable_vpc_classic_link @vpc_id
|
129
|
+
body = Fog::Compute[:aws].describe_vpc_classic_link(:vpc_ids => [@vpc_id])
|
130
|
+
body['vpcSet'].first['classicLinkEnabled']
|
131
|
+
end
|
132
|
+
|
133
|
+
@server = Fog::Compute[:aws].servers.create
|
134
|
+
@server.wait_for {ready?}
|
135
|
+
|
136
|
+
@group = Fog::Compute[:aws].security_groups.create :name => 'test-group', :description => 'vpc security group'
|
137
|
+
|
138
|
+
tests("attach_classic_link_vpc") do
|
139
|
+
Fog::Compute[:aws].attach_classic_link_vpc(@server.id, @vpc_id, [@group])
|
140
|
+
end
|
141
|
+
|
142
|
+
tests('describe_classic_link_instances').formats(@describe_classic_link_instances) do
|
143
|
+
Fog::Compute[:aws].describe_classic_link_instances().body
|
144
|
+
end
|
145
|
+
|
146
|
+
tests("detach_classic_link_vpc").returns([]) do
|
147
|
+
Fog::Compute[:aws].detach_classic_link_vpc(@server.id, @vpc_id)
|
148
|
+
Fog::Compute[:aws].describe_classic_link_instances().body['instancesSet']
|
149
|
+
end
|
150
|
+
|
151
|
+
if !Fog.mocking?
|
152
|
+
@server.destroy
|
153
|
+
@server.wait_for {state == 'terminated'}
|
154
|
+
end
|
155
|
+
|
156
|
+
tests("disable_vpc_classic_link").returns(false) do
|
157
|
+
Fog::Compute[:aws].disable_vpc_classic_link @vpc_id
|
158
|
+
body = Fog::Compute[:aws].describe_vpc_classic_link(:vpc_ids => [@vpc_id])
|
159
|
+
body['vpcSet'].first['classicLinkEnabled']
|
160
|
+
end
|
161
|
+
|
102
162
|
tests("#delete_vpc('#{@vpc_id}')").formats(AWS::Compute::Formats::BASIC) do
|
103
163
|
Fog::Compute[:aws].delete_vpc(@vpc_id).body
|
104
164
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Lane
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-01-
|
12
|
+
date: 2015-01-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -378,6 +378,7 @@ files:
|
|
378
378
|
- lib/fog/aws/parsers/compute/describe_account_attributes.rb
|
379
379
|
- lib/fog/aws/parsers/compute/describe_addresses.rb
|
380
380
|
- lib/fog/aws/parsers/compute/describe_availability_zones.rb
|
381
|
+
- lib/fog/aws/parsers/compute/describe_classic_link_instances.rb
|
381
382
|
- lib/fog/aws/parsers/compute/describe_dhcp_options.rb
|
382
383
|
- lib/fog/aws/parsers/compute/describe_images.rb
|
383
384
|
- lib/fog/aws/parsers/compute/describe_instance_status.rb
|
@@ -400,6 +401,7 @@ files:
|
|
400
401
|
- lib/fog/aws/parsers/compute/describe_volume_status.rb
|
401
402
|
- lib/fog/aws/parsers/compute/describe_volumes.rb
|
402
403
|
- lib/fog/aws/parsers/compute/describe_vpc_attribute.rb
|
404
|
+
- lib/fog/aws/parsers/compute/describe_vpc_classic_link.rb
|
403
405
|
- lib/fog/aws/parsers/compute/describe_vpcs.rb
|
404
406
|
- lib/fog/aws/parsers/compute/detach_volume.rb
|
405
407
|
- lib/fog/aws/parsers/compute/get_console_output.rb
|
@@ -728,6 +730,7 @@ files:
|
|
728
730
|
- lib/fog/aws/requests/compute/associate_address.rb
|
729
731
|
- lib/fog/aws/requests/compute/associate_dhcp_options.rb
|
730
732
|
- lib/fog/aws/requests/compute/associate_route_table.rb
|
733
|
+
- lib/fog/aws/requests/compute/attach_classic_link_vpc.rb
|
731
734
|
- lib/fog/aws/requests/compute/attach_internet_gateway.rb
|
732
735
|
- lib/fog/aws/requests/compute/attach_network_interface.rb
|
733
736
|
- lib/fog/aws/requests/compute/attach_volume.rb
|
@@ -772,6 +775,7 @@ files:
|
|
772
775
|
- lib/fog/aws/requests/compute/describe_account_attributes.rb
|
773
776
|
- lib/fog/aws/requests/compute/describe_addresses.rb
|
774
777
|
- lib/fog/aws/requests/compute/describe_availability_zones.rb
|
778
|
+
- lib/fog/aws/requests/compute/describe_classic_link_instances.rb
|
775
779
|
- lib/fog/aws/requests/compute/describe_dhcp_options.rb
|
776
780
|
- lib/fog/aws/requests/compute/describe_images.rb
|
777
781
|
- lib/fog/aws/requests/compute/describe_instance_status.rb
|
@@ -796,12 +800,16 @@ files:
|
|
796
800
|
- lib/fog/aws/requests/compute/describe_volume_status.rb
|
797
801
|
- lib/fog/aws/requests/compute/describe_volumes.rb
|
798
802
|
- lib/fog/aws/requests/compute/describe_vpc_attribute.rb
|
803
|
+
- lib/fog/aws/requests/compute/describe_vpc_classic_link.rb
|
799
804
|
- lib/fog/aws/requests/compute/describe_vpcs.rb
|
805
|
+
- lib/fog/aws/requests/compute/detach_classic_link_vpc.rb
|
800
806
|
- lib/fog/aws/requests/compute/detach_internet_gateway.rb
|
801
807
|
- lib/fog/aws/requests/compute/detach_network_interface.rb
|
802
808
|
- lib/fog/aws/requests/compute/detach_volume.rb
|
809
|
+
- lib/fog/aws/requests/compute/disable_vpc_classic_link.rb
|
803
810
|
- lib/fog/aws/requests/compute/disassociate_address.rb
|
804
811
|
- lib/fog/aws/requests/compute/disassociate_route_table.rb
|
812
|
+
- lib/fog/aws/requests/compute/enable_vpc_classic_link.rb
|
805
813
|
- lib/fog/aws/requests/compute/get_console_output.rb
|
806
814
|
- lib/fog/aws/requests/compute/get_password_data.rb
|
807
815
|
- lib/fog/aws/requests/compute/import_key_pair.rb
|