awful 0.0.54 → 0.0.55
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 +52 -43
- data/lib/awful/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56376495dec02b800fed9491623c01bbbdf421c1
|
4
|
+
data.tar.gz: 75d49a923b5d25064346e65f063938384192c75b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a13c33a1eac8b19dcab30d6498ce53f5a98ca1cfd6c1896ed658923c11f0297ee09b6d23070053b71072fe4dc61757c4006b65e061e54723f12ceb00ca77ae8e
|
7
|
+
data.tar.gz: 2d3c8916d7028a62a076a8d57255fa7ba672bff1789b1a1c1bb3688d8266ae692afaf1774131ebe8147fd8cd6337391f9796e75d23f91b2d4edbe31ddef3b793
|
data/lib/awful/auto_scaling.rb
CHANGED
@@ -14,37 +14,43 @@ module Awful
|
|
14
14
|
Successful: :green,
|
15
15
|
Failed: :red,
|
16
16
|
Cancelled: :red,
|
17
|
+
## instance state
|
18
|
+
running: :green,
|
19
|
+
stopped: :yellow,
|
20
|
+
terminated: :red,
|
17
21
|
}
|
18
22
|
|
19
23
|
no_commands do
|
20
24
|
def color(string)
|
21
25
|
set_color(string, COLORS.fetch(string.to_sym, :yellow))
|
22
26
|
end
|
27
|
+
|
28
|
+
def all_matching_asgs(name)
|
29
|
+
autoscaling.describe_auto_scaling_groups.map(&:auto_scaling_groups).flatten.select do |asg|
|
30
|
+
asg.auto_scaling_group_name.match(name) or tag_name(asg, '').match(name)
|
31
|
+
end
|
32
|
+
end
|
23
33
|
end
|
24
34
|
|
25
35
|
desc 'ls [PATTERN]', 'list autoscaling groups with name matching PATTERN'
|
26
36
|
method_option :long, aliases: '-l', default: false, desc: 'Long listing'
|
27
37
|
def ls(name = /./)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end.map do |asg|
|
45
|
-
fields.call(asg)
|
46
|
-
end.tap do |list|
|
47
|
-
print_table list
|
38
|
+
all_matching_asgs(name).tap do |asgs|
|
39
|
+
if options[:long]
|
40
|
+
print_table asgs.map { |a|
|
41
|
+
[
|
42
|
+
tag_name(a, '-')[0,40],
|
43
|
+
a.auto_scaling_group_name[0,40],
|
44
|
+
a.launch_configuration_name[0,40],
|
45
|
+
"#{a.instances.length}/#{a.desired_capacity}",
|
46
|
+
"#{a.min_size}-#{a.max_size}",
|
47
|
+
a.availability_zones.map{ |az| az[-1,1] }.sort.join(','),
|
48
|
+
a.created_time
|
49
|
+
]
|
50
|
+
}
|
51
|
+
else
|
52
|
+
puts asgs.map(&:auto_scaling_group_name)
|
53
|
+
end
|
48
54
|
end
|
49
55
|
end
|
50
56
|
|
@@ -59,16 +65,17 @@ module Awful
|
|
59
65
|
method_option :long, aliases: '-l', default: false, desc: 'Long listing'
|
60
66
|
method_option :launch_configuration, aliases: '-L', default: false, desc: 'Get instance launch_configs'
|
61
67
|
def instances(name)
|
62
|
-
|
63
|
-
instance.auto_scaling_group_name.match(name)
|
64
|
-
end.tap do |instances|
|
68
|
+
all_matching_asgs(name).map(&:instances).flatten.tap do |instances|
|
65
69
|
if options[:long]
|
66
70
|
print_table instances.map { |i|
|
67
|
-
[
|
68
|
-
|
71
|
+
[
|
72
|
+
i.instance_id,
|
73
|
+
i.availability_zone,
|
74
|
+
color(i.lifecycle_state),
|
75
|
+
color(i.health_status),
|
76
|
+
i.launch_configuration_name,
|
77
|
+
]
|
69
78
|
}
|
70
|
-
elsif options[:launch_configuration]
|
71
|
-
print_table instances.map { |i| [i.instance_id, i.launch_configuration_name] }
|
72
79
|
else
|
73
80
|
puts instances.map(&:instance_id)
|
74
81
|
end
|
@@ -78,20 +85,20 @@ module Awful
|
|
78
85
|
desc 'ips NAME', 'list IPs for instances in groups matching NAME'
|
79
86
|
method_option :long, aliases: '-l', default: false, desc: 'Long listing'
|
80
87
|
def ips(name)
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
instance_ids
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
print_table list
|
88
|
+
## get instance IDs for matching ASGs
|
89
|
+
ids = all_matching_asgs(name).map(&:instances).flatten.map(&:instance_id)
|
90
|
+
|
91
|
+
## get instance details for these IDs
|
92
|
+
ec2.describe_instances(instance_ids: ids).map(&:reservations).flatten.map(&:instances).flatten.sort_by(&:launch_time).tap do |instances|
|
93
|
+
if options[:long]
|
94
|
+
print_table instances.map { |i|
|
95
|
+
[ 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 ]
|
96
|
+
}
|
97
|
+
else
|
98
|
+
puts instances.map(&:public_ip_address)
|
99
|
+
end
|
94
100
|
end
|
101
|
+
|
95
102
|
end
|
96
103
|
|
97
104
|
desc 'ssh NAME [ARGS]', 'ssh to an instance for this autoscaling group'
|
@@ -99,7 +106,7 @@ module Awful
|
|
99
106
|
method_option :number, aliases: '-n', default: 1, desc: 'number of instances to ssh'
|
100
107
|
method_option :login_name, aliases: '-l', default: nil, desc: 'login name to pass to ssh'
|
101
108
|
def ssh(name, *args)
|
102
|
-
ips = ips(name).
|
109
|
+
ips = ips(name).map(&:public_ip_address)
|
103
110
|
num = options[:all] ? ips.count : options[:number].to_i
|
104
111
|
login_name = options[:login_name] ? "-l #{options[:login_name]}" : ''
|
105
112
|
ips.last(num).each do |ip|
|
@@ -109,8 +116,10 @@ module Awful
|
|
109
116
|
|
110
117
|
desc 'dump NAME', 'dump existing autoscaling group as yaml'
|
111
118
|
def dump(name)
|
112
|
-
|
113
|
-
|
119
|
+
all_matching_asgs(name).map(&:to_hash).tap do |asgs|
|
120
|
+
asgs.each do |asg|
|
121
|
+
puts YAML.dump(stringify_keys(asg)) unless options[:quiet]
|
122
|
+
end
|
114
123
|
end
|
115
124
|
end
|
116
125
|
|
data/lib/awful/version.rb
CHANGED