ec2ctl 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2db3d33906e470bb3a0e6b4a96e840feae7e0dfd
4
- data.tar.gz: aac465cbdf09c95ce707088fd6dd705584088290
3
+ metadata.gz: 2e93e145a9a46ba440c2425be62e4cc3165bf141
4
+ data.tar.gz: fb692f2bf1eb7c6f7ac199bbcf0f441f4a260b03
5
5
  SHA512:
6
- metadata.gz: 14cadc9ca8e185e0b97547b05a155b0fb44ee2be7952430ae27199a292f3dc2594027e24c5fbdc71e3afcf46be780ccba3c2533da63febb972c2de37abcc8aa7
7
- data.tar.gz: 19ab369c479627d591d68b44e943bcd6d3ce66ae66ec5fde155c634ec49f7afb0a411f1efe162a9b1d95487beaed8c4f26dccb50c900bace55b9bf8b940f8774
6
+ metadata.gz: 8c0a2e966e7f14ffeabc54b5cee63c31d77aaadc78f69e1b0c7b16287a45dda5cf6fc180dd0892c8f09486d590e46f1751d803c9a81be7ddb74a68693e88898b
7
+ data.tar.gz: 1a1cac4e840229b9bcaebb0a79985ba55359d7537a7f5f3a2b29f0fc15bfcc189e2c9ded055275832fbea56ec65ba887b79e8eb774255894df2cd7092d779010
data/README.md CHANGED
@@ -20,6 +20,12 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
+ Please run
24
+
25
+ ```
26
+ $ ec2ctl --help
27
+ ```
28
+
23
29
  ### `ec2 list`
24
30
 
25
31
  List EC2 instances.
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 = ec2_instances.each_with_object Array.new do |instance, instances_memo|
96
- instance_summary = @attributes.each_with_object Hash.new do |attribute, attributes_memo|
97
- attributes_memo[attribute] = query_instance_attribute(instance, attribute)
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
- instances_memo.push instance_summary
111
+ instances_memo.push instance_summary
112
+ end
101
113
  end
102
114
 
103
115
  @logger.info ec2_instances_summary: ec2_instances_summary
@@ -1,3 +1,3 @@
1
1
  module EC2Ctl
2
- VERSION = "0.8.0"
2
+ VERSION = "0.8.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ec2ctl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoriki Yamaguchi