awful 0.0.154 → 0.0.155
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/awful/auto_scaling.rb +31 -13
- data/lib/awful/version.rb +1 -1
- 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: 3066108e8af44c4e49963df6e3939454cd62cd70
|
4
|
+
data.tar.gz: a9f3bec7a08eef96b2b72d9c795c682b565cc436
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 915ff6520f33673d422daa38275626cbfeabc6eeae7b739ed49730a5c33703138bb5a1e7f7bf8f2da23767905f7a57e06e94d2016e5e5a64ba123e7b1b378e99
|
7
|
+
data.tar.gz: ab8d2e34eaae205dcc563990b9a50222e208f8ee2058fc8ca4b66d75508239604e1e22a3bfe8dff246329a7821e92ed9cbd5691629568c09dbf410185993a4d2
|
data/lib/awful/auto_scaling.rb
CHANGED
@@ -38,6 +38,17 @@ module Awful
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
## return instances for named ASGs
|
42
|
+
def asg_instances(*names)
|
43
|
+
autoscaling.describe_auto_scaling_groups(auto_scaling_group_names: names).auto_scaling_groups.map(&:instances).flatten
|
44
|
+
end
|
45
|
+
|
46
|
+
## lookup ec2 details for instances in named ASGs
|
47
|
+
def asg_instance_details(*names)
|
48
|
+
ids = asg_instances(*names).map(&:instance_id)
|
49
|
+
ec2.describe_instances(instance_ids: ids).map(&:reservations).flatten.map(&:instances).flatten.sort_by(&:launch_time)
|
50
|
+
end
|
51
|
+
|
41
52
|
def instance_lifecycle_state(*instance_ids)
|
42
53
|
autoscaling.describe_auto_scaling_instances(instance_ids: instance_ids).auto_scaling_instances.map(&:lifecycle_state)
|
43
54
|
end
|
@@ -76,7 +87,7 @@ module Awful
|
|
76
87
|
method_option :long, aliases: '-l', type: :boolean, default: false, desc: 'long listing'
|
77
88
|
method_option :describe, aliases: '-d', type: :boolean, default: false, desc: 'make extra call to get ASG name for each instance'
|
78
89
|
def instances(*names)
|
79
|
-
instances =
|
90
|
+
instances = asg_instances(*names)
|
80
91
|
|
81
92
|
## make extra call to get asg name as part of object
|
82
93
|
if options[:describe]
|
@@ -101,14 +112,10 @@ module Awful
|
|
101
112
|
end
|
102
113
|
end
|
103
114
|
|
104
|
-
desc 'ips
|
115
|
+
desc 'ips NAMES', 'list IPs for instances in named groups'
|
105
116
|
method_option :long, aliases: '-l', default: false, desc: 'Long listing'
|
106
|
-
def ips(
|
107
|
-
|
108
|
-
ids = all_matching_asgs(name).map(&:instances).flatten.map(&:instance_id)
|
109
|
-
|
110
|
-
## get instance details for these IDs
|
111
|
-
ec2.describe_instances(instance_ids: ids).map(&:reservations).flatten.map(&:instances).flatten.sort_by(&:launch_time).output do |instances|
|
117
|
+
def ips(*names)
|
118
|
+
asg_instance_details(*names).output do |instances|
|
112
119
|
if options[:long]
|
113
120
|
print_table instances.map { |i|
|
114
121
|
[ i.public_ip_address, i.private_ip_address, i.instance_id, i.image_id, i.instance_type, i.placement.availability_zone, color(i.state.name), i.launch_time ]
|
@@ -117,18 +124,29 @@ module Awful
|
|
117
124
|
puts instances.map(&:public_ip_address)
|
118
125
|
end
|
119
126
|
end
|
120
|
-
|
121
127
|
end
|
122
128
|
|
123
129
|
desc 'ssh NAME [ARGS]', 'ssh to an instance for this autoscaling group'
|
124
|
-
method_option :all, aliases: '-a', default: false, desc: 'ssh to all instances'
|
125
|
-
method_option :number, aliases: '-n', default: 1, desc: 'number of instances to ssh'
|
126
|
-
method_option :login_name, aliases: '-l', default: nil, desc: 'login name to pass to ssh'
|
130
|
+
method_option :all, aliases: '-a', type: :boolean, default: false, desc: 'ssh to all instances'
|
131
|
+
method_option :number, aliases: '-n', type: :numeric, default: 1, desc: 'number of instances to ssh'
|
132
|
+
method_option :login_name, aliases: '-l', type: :string, default: nil, desc: 'login name to pass to ssh'
|
133
|
+
method_option :instances, aliases: '-i', type: :array, default: nil, desc: 'list of partial instance IDs to filter'
|
134
|
+
method_option :verbose, aliases: '-v', type: :boolean, default: false, desc: 'show IPs before running ssh'
|
127
135
|
def ssh(name, *args)
|
128
|
-
|
136
|
+
instances = asg_instance_details(name)
|
137
|
+
|
138
|
+
## filter by list of instance id patterns
|
139
|
+
if options[:instances]
|
140
|
+
instances.select! do |i|
|
141
|
+
options[:instances].map{ |pattern| i.instance_id.match(pattern) }.any?
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
ips = instances.map(&:public_ip_address)
|
129
146
|
num = options[:all] ? ips.count : options[:number].to_i
|
130
147
|
login_name = options[:login_name] ? "-l #{options[:login_name]}" : ''
|
131
148
|
ips.last(num).each do |ip|
|
149
|
+
puts ip if options[:verbose]
|
132
150
|
system "ssh #{login_name} #{ip} #{Array(args).join(' ')}"
|
133
151
|
end
|
134
152
|
end
|
data/lib/awful/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.155
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ric Lister
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|