moonshot 2.0.0.beta1 → 2.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d2a30d2ed3a9a3f146a0bcf4972f0bfc9baff41
4
- data.tar.gz: 0087b7d90297d013cffd9b787f88b720dc357212
3
+ metadata.gz: 5cbd23bad6cfc674f3d79a842b49c50fe0de46cb
4
+ data.tar.gz: cbe254ca2d50e6c12e3e916e3d043c054e1a18af
5
5
  SHA512:
6
- metadata.gz: 6c1e1938bd414ec74f03185c824cf45e4c3f101b7b4acbaabbec46d71f17bf018b56600201eb1445c6b8b9c14c9c81223819c428a4667f4f67e69a90ddde5ba2
7
- data.tar.gz: c7262c61bd51cf6febe8f31cee9a8ef64831580aeaacba2b883725b5f36d38389db5337d456ba693c03249c1f24d68df3c29ab9d47cb088930793dd23aa9cfed
6
+ metadata.gz: 1a12347cc5ce9a357b932ca7772695af0d3bf527a1c7dd44dfa02dd2e2b01b8b70c1256e22a94505633af5378a142954c9ffe3c3f8400884e13ee1734e493aab
7
+ data.tar.gz: 6edbc749ab02ff73155d7e738b67661d90b2570651f092666a6cfc20e7f893692ebc1e7fa29a6010c83ad4824c02bfde7ea9919c6d2a6b824cb8e1d255a931dd
@@ -1,4 +1,4 @@
1
- require 'thor'
1
+ require 'optparse'
2
2
 
3
3
  module Moonshot
4
4
  # A Command that is automatically registered with the Moonshot::CommandLine
@@ -16,6 +16,10 @@ class Moonshot::DeploymentMechanism::CodeDeploy # rubocop:disable ClassLength
16
16
  # @param asg [Array, String]
17
17
  # The logical name of the AutoScalingGroup to create and manage a Deployment
18
18
  # Group for in CodeDeploy.
19
+ # @param optional_asg [Array, String]
20
+ # The logical name of the AutoScalingGroup to create and manage a Deployment
21
+ # Group for in CodeDeploy. This ASG doesn't have to exist. If it does, it
22
+ # will be added to the Deployment Group.
19
23
  # @param role [String]
20
24
  # IAM role with AWSCodeDeployRole policy. CodeDeployRole is considered as
21
25
  # default role if its not specified.
@@ -29,13 +33,16 @@ class Moonshot::DeploymentMechanism::CodeDeploy # rubocop:disable ClassLength
29
33
  # @param config_name [String]
30
34
  # Name of the Deployment Config to use for CodeDeploy, By default we use
31
35
  # CodeDeployDefault.OneAtATime.
36
+ # rubocop:disable Metrics/ParameterLists
32
37
  def initialize(
33
38
  asg: [],
39
+ optional_asg: [],
34
40
  role: 'CodeDeployRole',
35
41
  app_name: nil,
36
42
  group_name: nil,
37
43
  config_name: 'CodeDeployDefault.OneAtATime')
38
- @asg_logical_ids = asg.is_a?(Array) ? asg : [asg]
44
+ @asg_logical_ids = Array(asg)
45
+ @optional_asg_logical_ids = Array(optional_asg)
39
46
  @app_name = app_name
40
47
  @group_name = group_name
41
48
  @codedeploy_role = role
@@ -181,6 +188,16 @@ class Moonshot::DeploymentMechanism::CodeDeploy # rubocop:disable ClassLength
181
188
 
182
189
  autoscaling_groups.push(groups.auto_scaling_groups.first)
183
190
  end
191
+ @optional_asg_logical_ids.each do |asg_logical_id|
192
+ asg_name = stack.physical_id_for(asg_logical_id)
193
+ next unless asg_name
194
+ groups = as_client.describe_auto_scaling_groups(
195
+ auto_scaling_group_names: [asg_name]
196
+ )
197
+ unless groups.auto_scaling_groups.empty?
198
+ autoscaling_groups.push(groups.auto_scaling_groups.first)
199
+ end
200
+ end
184
201
  autoscaling_groups
185
202
  end
186
203
 
@@ -1,3 +1,5 @@
1
+ require 'thor'
2
+
1
3
  # Mixin providing the Thor::Shell methods and other shell execution helpers.
2
4
  module Moonshot::Shell
3
5
  # Run a command, returning stdout. Stderr is suppressed unless the command
@@ -14,7 +14,7 @@ module Moonshot
14
14
  Moonshot.config.ssh_config.ssh_identity_file = v
15
15
  end
16
16
 
17
- parser.on('-s', '--instance INSTANCE_ID', 'Specific AWS EC2 ID to connect through') do |v|
17
+ parser.on('-s', '--instance INSTANCE_ID', 'Specific AWS EC2 ID to connect to') do |v|
18
18
  Moonshot.config.ssh_instance = v
19
19
  end
20
20
 
@@ -11,20 +11,20 @@ module Moonshot
11
11
 
12
12
  asg = if groups.count == 1
13
13
  groups.first
14
- elsif asgs.count > 1
14
+ elsif groups.count > 1
15
15
  unless @asg_name
16
16
  raise 'Multiple Auto Scaling Groups found in the stack. Please specify which '\
17
17
  'one to SSH into using the --auto-scaling-group (-g) option.'
18
18
  end
19
- groups.detect { |x| x.logical_resource_id == @config.ssh_auto_scaling_group_name }
19
+ groups.detect { |x| x.logical_resource_id == @asg_name }
20
20
  end
21
21
  raise 'Failed to find the Auto Scaling Group.' unless asg
22
22
 
23
23
  Aws::AutoScaling::Client.new.describe_auto_scaling_groups(
24
24
  auto_scaling_group_names: [asg.physical_resource_id]
25
25
  ).auto_scaling_groups.first.instances.map(&:instance_id).first
26
- rescue
27
- raise 'Failed to find instances in the Auto Scaling Group!'
26
+ rescue => e
27
+ raise "Failed to select an instance from the Auto Scaling Group: #{e.message}"
28
28
  end
29
29
  end
30
30
  end
@@ -111,13 +111,21 @@ module Moonshot
111
111
  end
112
112
 
113
113
  def instance_row(asg_instance, ec2_instance)
114
+ if ec2_instance
115
+ ip_address = ec2_instance.public_ip_address || "#{ec2_instance.private_ip_address} (PRV)"
116
+ uptime = uptime_format(ec2_instance.launch_time)
117
+ else
118
+ # We've seen race conditions where ASG tells us about instances that EC2 is no longer
119
+ # aware of.
120
+ ip_address = 'unknown'
121
+ uptime = 'unknown'
122
+ end
114
123
  [
115
124
  asg_instance.instance_id,
116
- # @todo What about ASGs with only private IPs?
117
- ec2_instance.public_ip_address,
125
+ ip_address,
118
126
  lifecycle_color(asg_instance.lifecycle_state),
119
127
  health_color(asg_instance.health_status),
120
- uptime_format(ec2_instance.launch_time)
128
+ uptime
121
129
  ]
122
130
  end
123
131
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moonshot
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta1
4
+ version: 2.0.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cloud Engineering <engineering@acquia.com>
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-07 00:00:00.000000000 Z
11
+ date: 2017-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk