simple_deploy 0.8.1.beta1 → 0.8.2.beta1
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/.travis.yml +1 -0
- data/CHANGELOG.md +4 -1
- data/lib/simple_deploy/aws/instance_reader.rb +29 -6
- data/lib/simple_deploy/cli/instances.rb +1 -1
- data/lib/simple_deploy/version.rb +1 -1
- data/spec/aws/instance_reader_spec.rb +101 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c432864cff995bd0f3e5b64c571f81833f476410
|
4
|
+
data.tar.gz: b94faf1e112f9b83d06220aef5c2b2c8f0a66c7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff8d95d380fa89690dc6a00234035d1227a7c59ad77fe36568e6e78194a76f4982d9657f764f2b3a982473604f49f20a2e9387c6a7fe5deea4c644966d46e641
|
7
|
+
data.tar.gz: dd8d0c74e36fb84c2d152904d172784d693afafb092b3553dea57cede1bb86b2cc08a2d28ea5c69199c6bad51d907ec10c3296f2fe4fea255ca797399565505b
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -7,15 +7,22 @@ module SimpleDeploy
|
|
7
7
|
|
8
8
|
def list_stack_instances(stack_name)
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
instances = []
|
11
|
+
|
12
|
+
#Nested stack
|
13
|
+
nested_stacks = nested_stacks_names(stack_name)
|
14
|
+
instances = nested_stacks.map {|stack| list_stack_instances stack }.flatten if nested_stacks.any?
|
13
15
|
|
16
|
+
#Auto Scaling Group
|
17
|
+
asg_ids = auto_scaling_group_id(stack_name)
|
14
18
|
asg_instances = asg_ids.map { |asg_id| list_instances asg_id }.flatten
|
15
19
|
|
16
|
-
|
20
|
+
#EC2 instance
|
21
|
+
stack_instances = instance_names(stack_name)
|
22
|
+
|
23
|
+
instances += (describe_instances (asg_instances + stack_instances)) if (asg_instances + stack_instances).any?
|
17
24
|
|
18
|
-
|
25
|
+
instances
|
19
26
|
end
|
20
27
|
|
21
28
|
private
|
@@ -54,7 +61,23 @@ module SimpleDeploy
|
|
54
61
|
asgs = cf_stack_resources.select do |r|
|
55
62
|
r['ResourceType'] == 'AWS::AutoScaling::AutoScalingGroup'
|
56
63
|
end
|
57
|
-
asgs.any? ? asgs.map {|asg| asg['PhysicalResourceId'] } :
|
64
|
+
asgs.any? ? asgs.map {|asg| asg['PhysicalResourceId'] } : []
|
65
|
+
end
|
66
|
+
|
67
|
+
def nested_stacks_names(stack_name)
|
68
|
+
cf_stack_resources = cloud_formation.stack_resources stack_name
|
69
|
+
asgs = cf_stack_resources.select do |r|
|
70
|
+
r['ResourceType'] == 'AWS::CloudFormation::Stack'
|
71
|
+
end
|
72
|
+
asgs.any? ? asgs.map {|asg| asg['PhysicalResourceId'] } : []
|
73
|
+
end
|
74
|
+
|
75
|
+
def instance_names(stack_name)
|
76
|
+
cf_stack_resources = cloud_formation.stack_resources stack_name
|
77
|
+
asgs = cf_stack_resources.select do |r|
|
78
|
+
r['ResourceType'] == 'AWS::EC2::Instance'
|
79
|
+
end
|
80
|
+
asgs.any? ? asgs.map {|asg| asg['PhysicalResourceId'] } : []
|
58
81
|
end
|
59
82
|
|
60
83
|
end
|
@@ -35,6 +35,7 @@ describe SimpleDeploy::AWS::InstanceReader do
|
|
35
35
|
context "with no ASGs" do
|
36
36
|
before do
|
37
37
|
@cloud_formation_mock.should_receive(:stack_resources).
|
38
|
+
exactly(3).times.
|
38
39
|
with('stack').
|
39
40
|
and_return []
|
40
41
|
end
|
@@ -55,6 +56,7 @@ describe SimpleDeploy::AWS::InstanceReader do
|
|
55
56
|
end
|
56
57
|
|
57
58
|
@cloud_formation_mock.should_receive(:stack_resources).
|
59
|
+
exactly(3).times.
|
58
60
|
with('stack').
|
59
61
|
and_return stack_resource_results
|
60
62
|
|
@@ -100,5 +102,104 @@ describe SimpleDeploy::AWS::InstanceReader do
|
|
100
102
|
end
|
101
103
|
end
|
102
104
|
end
|
105
|
+
|
106
|
+
context "with nested stacks and ASGs and EC2 instances" do
|
107
|
+
before do
|
108
|
+
stack_resource_results = []
|
109
|
+
@nested_stacks = ['nested_stack1', 'nested_stack2'].each do |nested_stack|
|
110
|
+
stack_resource_results << { 'StackName' => 'stack',
|
111
|
+
'ResourceType' => 'AWS::CloudFormation::Stack',
|
112
|
+
'PhysicalResourceId' => nested_stack }
|
113
|
+
end
|
114
|
+
@asgs = ['asg1', 'asg2'].each do |asg|
|
115
|
+
stack_resource_results << { 'StackName' => 'stack',
|
116
|
+
'ResourceType' => 'AWS::AutoScaling::AutoScalingGroup',
|
117
|
+
'PhysicalResourceId' => asg }
|
118
|
+
end
|
119
|
+
|
120
|
+
@instances = ['i-instance1', 'i-instance2'].each do |instance|
|
121
|
+
stack_resource_results << { 'StackName' => 'stack',
|
122
|
+
'ResourceType' => 'AWS::EC2::Instance',
|
123
|
+
'PhysicalResourceId' => instance }
|
124
|
+
end
|
125
|
+
|
126
|
+
@cloud_formation_mock.should_receive(:stack_resources).
|
127
|
+
exactly(3).times.
|
128
|
+
with('stack').
|
129
|
+
and_return stack_resource_results
|
130
|
+
|
131
|
+
Fog::AWS::AutoScaling.stub(:new).
|
132
|
+
and_return @auto_scaling_groups_mock
|
133
|
+
end
|
134
|
+
|
135
|
+
context "with running instances in nested stack and ASG and EC2 instances" do
|
136
|
+
it "should return the reservation set for each running instance" do
|
137
|
+
|
138
|
+
|
139
|
+
@cloud_formation_mock.should_receive(:stack_resources).
|
140
|
+
exactly(3).times.
|
141
|
+
with('nested_stack1').
|
142
|
+
and_return []
|
143
|
+
|
144
|
+
nested_stack2_resource_results = []
|
145
|
+
@asgs = ['nested_stack2_asg1', 'nested_stack2_asg2'].each do |nested_stack2_resource_asg|
|
146
|
+
nested_stack2_resource_results << { 'StackName' => 'nested_stack2',
|
147
|
+
'ResourceType' => 'AWS::AutoScaling::AutoScalingGroup',
|
148
|
+
'PhysicalResourceId' => nested_stack2_resource_asg }
|
149
|
+
end
|
150
|
+
|
151
|
+
@cloud_formation_mock.should_receive(:stack_resources).
|
152
|
+
exactly(3).times.
|
153
|
+
with('nested_stack2').
|
154
|
+
and_return nested_stack2_resource_results
|
155
|
+
nested_list_response = stub 'Fog::Response', :body => { 'DescribeAutoScalingGroupsResult' =>
|
156
|
+
{ 'AutoScalingGroups' => ['first',
|
157
|
+
{ 'Instances' => [{ 'InstanceId' => 'i-stack001' },
|
158
|
+
{ 'InstanceId' => 'i-stack002' }] }] } },
|
159
|
+
:any? => true
|
160
|
+
@auto_scaling_groups_mock.should_receive(:describe_auto_scaling_groups).
|
161
|
+
with('AutoScalingGroupNames' => ['nested_stack2_asg1']).
|
162
|
+
and_return(nested_list_response)
|
163
|
+
|
164
|
+
@auto_scaling_groups_mock.should_receive(:describe_auto_scaling_groups).
|
165
|
+
with('AutoScalingGroupNames' => ['nested_stack2_asg2']).
|
166
|
+
and_return(@empty_response)
|
167
|
+
|
168
|
+
|
169
|
+
@auto_scaling_groups_mock.should_receive(:describe_auto_scaling_groups).
|
170
|
+
with('AutoScalingGroupNames' => ['asg1']).
|
171
|
+
and_return(@list_response)
|
172
|
+
@auto_scaling_groups_mock.should_receive(:describe_auto_scaling_groups).
|
173
|
+
with('AutoScalingGroupNames' => ['asg2']).
|
174
|
+
and_return(@empty_response)
|
175
|
+
|
176
|
+
Fog::Compute::AWS.stub(:new).
|
177
|
+
and_return @ec2_mock
|
178
|
+
|
179
|
+
@ec2_mock.should_receive(:describe_instances).
|
180
|
+
with('instance-state-name' => 'running',
|
181
|
+
'instance-id' => ['i-stack001', 'i-stack002']).
|
182
|
+
and_return @describe_response
|
183
|
+
|
184
|
+
@ec2_mock.should_receive(:describe_instances).
|
185
|
+
with('instance-state-name' => 'running',
|
186
|
+
'instance-id' => ['i-000001', 'i-000002','i-instance1', 'i-instance2'] ).
|
187
|
+
and_return @describe_response
|
188
|
+
|
189
|
+
instance_reader = SimpleDeploy::AWS::InstanceReader.new
|
190
|
+
instance_reader.list_stack_instances('stack').should == [{
|
191
|
+
'instanceSet' => [{'instanceState' => {'name' => 'running'}},
|
192
|
+
{'ipAddress' => '54.10.10.1'},
|
193
|
+
{'instanceId' => 'i-123456'},
|
194
|
+
{'privateIpAddress' => '192.168.1.1'}]},
|
195
|
+
{
|
196
|
+
'instanceSet' => [{'instanceState' => {'name' => 'running'}},
|
197
|
+
{'ipAddress' => '54.10.10.1'},
|
198
|
+
{'instanceId' => 'i-123456'},
|
199
|
+
{'privateIpAddress' => '192.168.1.1'}]}]
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
103
204
|
end
|
104
205
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Weaver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fakefs
|