simple_deploy 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ ## v0.5.4
2
+
3
+ * Added support for internal networking to the deploy and instances commands
4
+ * Added backoff functionality to deployments so they work better with the force option
5
+
1
6
  ## v0.5.3
2
7
 
3
8
  * Added a clone command that clones a stack
@@ -0,0 +1,9 @@
1
+ module SimpleDeploy
2
+ class Backoff
3
+ def self.exp_periods(num_periods = 3)
4
+ (1..num_periods).each do |n|
5
+ yield (1.0/2.0 * (2.0**n - 1.0)).ceil
6
+ end
7
+ end
8
+ end
9
+ end
@@ -27,6 +27,13 @@ export SIMPLE_DEPLOY_SSH_USER=fred
27
27
  export SIMPLE_DEPLOY_SSH_KEY=$HOME/.ssh/id_dsa
28
28
  simple_deploy deploy -n STACK_NAME -n STACK_NAME -e ENVIRONMENT
29
29
 
30
+ Using Internal IP for SSH:
31
+
32
+ Simple deploy defaults to using the public IP when ssh'ng to stacks. This option instructs it
33
+ to use the private IP, which is needed when ssh'ng from one stack to another.
34
+
35
+ simple_deploy deploy -n STACK_NAME -n STACK_NAME -e ENVIRONMENT -i
36
+
30
37
  EOS
31
38
  opt :help, "Display Help"
32
39
  opt :attributes, "= seperated attribute and it's value", :type => :string,
@@ -38,6 +45,7 @@ EOS
38
45
  opt :name, "Stack name(s) of stack to deploy", :type => :string,
39
46
  :multi => true
40
47
  opt :quiet, "Quiet, do not send notifications"
48
+ opt :internal, "Use internal IP for ssh commands"
41
49
  end
42
50
 
43
51
  CLI::Shared.valid_options? :provided => opts,
@@ -54,7 +62,8 @@ EOS
54
62
 
55
63
  stack = Stack.new :environment => opts[:environment],
56
64
  :name => name,
57
- :logger => logger
65
+ :logger => logger,
66
+ :internal => opts[:internal]
58
67
 
59
68
  stack.update :force => opts[:force], :attributes => new_attributes if new_attributes.any?
60
69
 
@@ -16,6 +16,7 @@ EOS
16
16
  opt :help, "Display Help"
17
17
  opt :environment, "Set the target environment", :type => :string
18
18
  opt :name, "Stack name to manage", :type => :string
19
+ opt :internal, "Use internal IP for ssh commands"
19
20
  end
20
21
 
21
22
  CLI::Shared.valid_options? :provided => opts,
@@ -28,7 +29,8 @@ EOS
28
29
  stack = Stack.new :environment => opts[:environment],
29
30
  :name => opts[:name],
30
31
  :config => config,
31
- :logger => logger
32
+ :logger => logger,
33
+ :internal => opts[:internal]
32
34
 
33
35
  instances = stack.instances
34
36
  if instances.nil? || instances.empty?
@@ -38,6 +38,11 @@ module SimpleDeploy
38
38
  def execute(force = false)
39
39
  if !clear_for_deployment? && force
40
40
  clear_deployment_lock true
41
+
42
+ Backoff.exp_periods do |p|
43
+ sleep p
44
+ break if clear_for_deployment?
45
+ end
41
46
  end
42
47
 
43
48
  if clear_for_deployment?
@@ -10,6 +10,8 @@ module SimpleDeploy
10
10
  @name = args[:name]
11
11
  @config = Config.new :logger => args[:logger]
12
12
  @logger = @config.logger
13
+
14
+ @use_internal_ips = !!args[:internal]
13
15
  end
14
16
 
15
17
  def create(args)
@@ -66,7 +68,12 @@ module SimpleDeploy
66
68
  def instances
67
69
  stack.instances.map do |instance|
68
70
  info = instance['instancesSet'].first
69
- info['vpcId'] ? info['privateIpAddress'] : info['ipAddress']
71
+
72
+ if info['vpcId'] || @use_internal_ips
73
+ info['privateIpAddress']
74
+ else
75
+ info['ipAddress']
76
+ end
70
77
  end
71
78
  end
72
79
 
@@ -1,3 +1,3 @@
1
1
  module SimpleDeploy
2
- VERSION = "0.5.3"
2
+ VERSION = "0.5.4"
3
3
  end
data/lib/simple_deploy.rb CHANGED
@@ -4,3 +4,4 @@ require 'simple_deploy/stack'
4
4
  require 'simple_deploy/notifier'
5
5
  require 'simple_deploy/logger'
6
6
  require 'simple_deploy/version'
7
+ require 'simple_deploy/backoff'
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe SimpleDeploy::Backoff do
4
+ describe 'exp_periods' do
5
+ it 'should yield each period' do
6
+ expected_periods = [1, 2, 4]
7
+
8
+ i = 0
9
+ SimpleDeploy::Backoff.exp_periods do |p|
10
+ expected_periods[i].should == p
11
+ i += 1
12
+ end
13
+ end
14
+
15
+ it 'should generate and yield a specified number of periods' do
16
+ expected_periods = [1, 2]
17
+
18
+ i = 0
19
+ SimpleDeploy::Backoff.exp_periods(2) do |p|
20
+ expected_periods[i].should == p
21
+ i += 1
22
+ end
23
+ end
24
+ end
25
+ end
@@ -19,6 +19,7 @@ describe SimpleDeploy::CLI::Deploy do
19
19
  :log_level => 'debug',
20
20
  :name => ['my_stack'],
21
21
  :force => true,
22
+ :internal => false,
22
23
  :attributes => [] }
23
24
 
24
25
  SimpleDeploy::CLI::Shared.should_receive(:valid_options?).
@@ -35,7 +36,8 @@ describe SimpleDeploy::CLI::Deploy do
35
36
  SimpleDeploy::Stack.should_receive(:new).
36
37
  with(:environment => 'my_env',
37
38
  :logger => @logger,
38
- :name => 'my_stack').
39
+ :name => 'my_stack',
40
+ :internal => false).
39
41
  and_return(@stack)
40
42
 
41
43
  @stack.should_receive(:deploy).with(true).and_return(true)
@@ -50,6 +52,7 @@ describe SimpleDeploy::CLI::Deploy do
50
52
  :log_level => 'debug',
51
53
  :name => ['my_stack'],
52
54
  :force => true,
55
+ :internal => false,
53
56
  :attributes => [] }
54
57
 
55
58
  SimpleDeploy::CLI::Shared.should_receive(:valid_options?).
@@ -66,7 +69,8 @@ describe SimpleDeploy::CLI::Deploy do
66
69
  SimpleDeploy::Stack.should_receive(:new).
67
70
  with(:environment => 'my_env',
68
71
  :logger => @logger,
69
- :name => 'my_stack').
72
+ :name => 'my_stack',
73
+ :internal => false).
70
74
  and_return(@stack)
71
75
 
72
76
  @stack.should_receive(:deploy).with(true).and_return(false)
@@ -83,6 +87,7 @@ describe SimpleDeploy::CLI::Deploy do
83
87
  :log_level => 'debug',
84
88
  :name => ['my_stack'],
85
89
  :force => true,
90
+ :internal => false,
86
91
  :attributes => ['foo=bah'] }
87
92
 
88
93
  SimpleDeploy::CLI::Shared.should_receive(:valid_options?).
@@ -99,7 +104,8 @@ describe SimpleDeploy::CLI::Deploy do
99
104
  SimpleDeploy::Stack.should_receive(:new).
100
105
  with(:environment => 'my_env',
101
106
  :logger => @logger,
102
- :name => 'my_stack').
107
+ :name => 'my_stack',
108
+ :internal => false).
103
109
  and_return(@stack)
104
110
 
105
111
  @stack.should_receive(:update).with(hash_including(:force => true, :attributes => [{'foo' => 'bah'}]))
@@ -103,7 +103,7 @@ describe SimpleDeploy do
103
103
  status_mock = mock 'status mock'
104
104
  SimpleDeploy::Stack::Deployment::Status.should_receive(:new).
105
105
  and_return status_mock
106
- status_mock.should_receive(:clear_for_deployment?).and_return false, true
106
+ status_mock.should_receive(:clear_for_deployment?).and_return false, true, true
107
107
  status_mock.should_receive(:clear_deployment_lock).with(true)
108
108
  status_mock.should_receive(:set_deployment_in_progress)
109
109
  @deployment_mock.should_receive(:simpledeploy)
data/spec/stack_spec.rb CHANGED
@@ -12,6 +12,7 @@ describe SimpleDeploy do
12
12
  @config_stub.stub(:artifact_cloud_formation_url).and_return('CookBooksURL')
13
13
 
14
14
  SimpleDeploy::Config.should_receive(:new).
15
+ at_least(:once).
15
16
  with(:logger => 'my-logger').
16
17
  and_return @config_stub
17
18
  @stack = SimpleDeploy::Stack.new :environment => 'test-env',
@@ -157,4 +158,49 @@ describe SimpleDeploy do
157
158
  @stack.destroy.should be_true
158
159
  end
159
160
  end
161
+
162
+ describe 'instances' do
163
+ before do
164
+ @instances = [{ 'instancesSet' => [{ 'ipAddress' => '50.40.30.20', 'privateIpAddress' => '10.1.2.3' }] }]
165
+ @environment_config_mock.stub(:[])
166
+ end
167
+
168
+ it 'should use the private IP when vpc' do
169
+ stack = SimpleDeploy::Stack.new :environment => 'test-env',
170
+ :name => 'test-stack',
171
+ :logger => 'my-logger',
172
+ :config => @config_stub,
173
+ :internal => false
174
+ stack.stub(:stack) { @stack_mock }
175
+
176
+ @instances.first['instancesSet'].first['vpcId'] = 'my-vpc'
177
+ @stack_mock.stub(:instances).and_return(@instances)
178
+
179
+ stack.send(:instances).should == ['10.1.2.3']
180
+ end
181
+
182
+ it 'should use the private IP when internal' do
183
+ stack = SimpleDeploy::Stack.new :environment => 'test-env',
184
+ :name => 'test-stack',
185
+ :logger => 'my-logger',
186
+ :config => @config_stub,
187
+ :internal => true
188
+ stack.stub(:stack) { @stack_mock }
189
+ @stack_mock.stub(:instances).and_return(@instances)
190
+
191
+ stack.send(:instances).should == ['10.1.2.3']
192
+ end
193
+
194
+ it 'should use the public IP when not vpc and not internal' do
195
+ stack = SimpleDeploy::Stack.new :environment => 'test-env',
196
+ :name => 'test-stack',
197
+ :logger => 'my-logger',
198
+ :config => @config_stub,
199
+ :internal => false
200
+ stack.stub(:stack) { @stack_mock }
201
+ @stack_mock.stub(:instances).and_return(@instances)
202
+
203
+ stack.send(:instances).should == ['50.40.30.20']
204
+ end
205
+ end
160
206
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-11 00:00:00.000000000 Z
12
+ date: 2012-10-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -109,6 +109,7 @@ files:
109
109
  - bin/simple_deploy
110
110
  - lib/simple_deploy.rb
111
111
  - lib/simple_deploy/artifact.rb
112
+ - lib/simple_deploy/backoff.rb
112
113
  - lib/simple_deploy/cli.rb
113
114
  - lib/simple_deploy/cli/attributes.rb
114
115
  - lib/simple_deploy/cli/clone.rb
@@ -139,6 +140,7 @@ files:
139
140
  - script/ci_setup
140
141
  - simple_deploy.gemspec
141
142
  - spec/artifact_spec.rb
143
+ - spec/backoff_spec.rb
142
144
  - spec/cli/attributes_spec.rb
143
145
  - spec/cli/clone_spec.rb
144
146
  - spec/cli/deploy_spec.rb
@@ -181,6 +183,7 @@ specification_version: 3
181
183
  summary: I help with deployments
182
184
  test_files:
183
185
  - spec/artifact_spec.rb
186
+ - spec/backoff_spec.rb
184
187
  - spec/cli/attributes_spec.rb
185
188
  - spec/cli/clone_spec.rb
186
189
  - spec/cli/deploy_spec.rb