ec2ctl 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/ec2ctl/cli.rb +3 -1
- data/lib/ec2ctl/client.rb +17 -5
- data/lib/ec2ctl/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: 2e93e145a9a46ba440c2425be62e4cc3165bf141
|
4
|
+
data.tar.gz: fb692f2bf1eb7c6f7ac199bbcf0f441f4a260b03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c0a2e966e7f14ffeabc54b5cee63c31d77aaadc78f69e1b0c7b16287a45dda5cf6fc180dd0892c8f09486d590e46f1751d803c9a81be7ddb74a68693e88898b
|
7
|
+
data.tar.gz: 1a1cac4e840229b9bcaebb0a79985ba55359d7537a7f5f3a2b29f0fc15bfcc189e2c9ded055275832fbea56ec65ba887b79e8eb774255894df2cd7092d779010
|
data/README.md
CHANGED
data/lib/ec2ctl/cli.rb
CHANGED
@@ -26,6 +26,9 @@ module EC2Ctl
|
|
26
26
|
|
27
27
|
ec2_options c
|
28
28
|
|
29
|
+
c.option "-a", "--attributes KEY1,KEY2...", Array, "(Optional) The instance attribute keys to display."
|
30
|
+
c.option "-C", "--count", "(Optional) Display instance attribute stats."
|
31
|
+
|
29
32
|
c.action do |args, options|
|
30
33
|
options.default attributes: %w(instance_id tag:Name instance_type public_dns_name state.name)
|
31
34
|
|
@@ -229,7 +232,6 @@ module EC2Ctl
|
|
229
232
|
end
|
230
233
|
|
231
234
|
def ec2_options(_command)
|
232
|
-
_command.option "-a", "--attributes KEY1,KEY2...", Array, "(Optional) The instance attribute keys to display."
|
233
235
|
_command.option "-f", "--filters KEY1=VALUE1,KEY2=VALUE2...", Array, "(Optional) The key-value pairs to filter instances."
|
234
236
|
_command.option "-s", "--search KEY1=VALUE1,KEY2=VALUE2...", Array, "(Optional) The key-value pairs to search instances by Regexp."
|
235
237
|
_command.option "-i", "--instance-ids STRING1,STRING2", Array, "(Optional) The IDs of the instances."
|
data/lib/ec2ctl/client.rb
CHANGED
@@ -42,7 +42,8 @@ module EC2Ctl
|
|
42
42
|
instance_ids: [],
|
43
43
|
filters: [],
|
44
44
|
attributes: [],
|
45
|
-
search: []
|
45
|
+
search: [],
|
46
|
+
count: false
|
46
47
|
)
|
47
48
|
@logger = logger
|
48
49
|
|
@@ -73,6 +74,7 @@ module EC2Ctl
|
|
73
74
|
@filters = filters
|
74
75
|
@attributes = attributes
|
75
76
|
@search = search
|
77
|
+
@count = count
|
76
78
|
|
77
79
|
if @load_balancer_name
|
78
80
|
@elb_instance_ids = elb_instance_states.map(&:instance_id).select do |instance_id|
|
@@ -92,12 +94,22 @@ module EC2Ctl
|
|
92
94
|
if @logger.debug?
|
93
95
|
@logger.debug ec2_instances: ec2_instances
|
94
96
|
else
|
95
|
-
ec2_instances_summary =
|
96
|
-
|
97
|
-
|
97
|
+
ec2_instances_summary = if @count
|
98
|
+
@attributes.each_with_object Hash.new do |attribute, attributes_memo|
|
99
|
+
attribute_hash = ec2_instances.each_with_object Hash.new(0) do |instance, instances_memo|
|
100
|
+
instances_memo[query_instance_attribute(instance, attribute)] += 1
|
101
|
+
end
|
102
|
+
|
103
|
+
attributes_memo[attribute] = attribute_hash
|
98
104
|
end
|
105
|
+
else
|
106
|
+
ec2_instances.each_with_object Array.new do |instance, instances_memo|
|
107
|
+
instance_summary = @attributes.each_with_object Hash.new do |attribute, attributes_memo|
|
108
|
+
attributes_memo[attribute] = query_instance_attribute(instance, attribute)
|
109
|
+
end
|
99
110
|
|
100
|
-
|
111
|
+
instances_memo.push instance_summary
|
112
|
+
end
|
101
113
|
end
|
102
114
|
|
103
115
|
@logger.info ec2_instances_summary: ec2_instances_summary
|
data/lib/ec2ctl/version.rb
CHANGED