ec2ctl 0.8.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ec2ctl.gemspec +1 -1
- data/lib/ec2ctl/cli.rb +1 -1
- data/lib/ec2ctl/client.rb +21 -5
- data/lib/ec2ctl/logger.rb +10 -6
- data/lib/ec2ctl/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dce53ee681a100859a592b712e6d350d5b42dc37
|
4
|
+
data.tar.gz: 41ae0cdcbd3246c92d6c1c33f714fbf6b83dd9a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cde8643788d2e8342ec3e21b35abf81ce6ee4d159b289de11c48e9f6a9645062424fd973b17a2905994bb1c62b1879ffd573688890a4662d5fd9f745d694d16
|
7
|
+
data.tar.gz: a7f825da6dec8d0e74748accf504aa4a126aa48d47e6d5eb3a97bd12ed415a2a5d16fe50be8dc145db8988af92cc9679905e9d5c1e0efbe79f34a7ace228ac22
|
data/ec2ctl.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.required_ruby_version = ">= 2.
|
21
|
+
spec.required_ruby_version = ">= 2.0.0"
|
22
22
|
|
23
23
|
spec.add_dependency "aws-sdk", "~> 2.3"
|
24
24
|
spec.add_dependency "commander", "~> 4.4"
|
data/lib/ec2ctl/cli.rb
CHANGED
@@ -30,7 +30,7 @@ module EC2Ctl
|
|
30
30
|
c.option "-C", "--count", "(Optional) Display instance attribute stats."
|
31
31
|
|
32
32
|
c.action do |args, options|
|
33
|
-
options.default attributes: %w(instance_id tag:Name instance_type public_dns_name state.name)
|
33
|
+
options.default attributes: %w(instance_id tag:Name instance_type public_dns_name state.name ssm:ping_status)
|
34
34
|
|
35
35
|
invoke options do
|
36
36
|
@client.ec2_list
|
data/lib/ec2ctl/client.rb
CHANGED
@@ -92,7 +92,8 @@ module EC2Ctl
|
|
92
92
|
def ec2_list
|
93
93
|
if @logger
|
94
94
|
if @logger.debug?
|
95
|
-
@logger.debug ec2_instances:
|
95
|
+
@logger.debug ec2_instances: ec2_instances
|
96
|
+
@logger.debug ssm_instance_states: ssm_instance_states(ec2_instances.map(&:instance_id))
|
96
97
|
else
|
97
98
|
ec2_instances_summary = if @count
|
98
99
|
@attributes.each_with_object Hash.new do |attribute, attributes_memo|
|
@@ -116,7 +117,10 @@ module EC2Ctl
|
|
116
117
|
end
|
117
118
|
end
|
118
119
|
|
119
|
-
{
|
120
|
+
{
|
121
|
+
ec2_instances: ec2_instances,
|
122
|
+
ssm_instance_states: ssm_instance_states(ec2_instances.map(&:instance_id)),
|
123
|
+
}
|
120
124
|
end
|
121
125
|
|
122
126
|
def ec2_execute
|
@@ -570,10 +574,22 @@ module EC2Ctl
|
|
570
574
|
tag = instance.tags.find {|t| t.key == attribute.split(":")[1..-1].join(":")}
|
571
575
|
|
572
576
|
tag ? tag.value : nil
|
573
|
-
|
574
|
-
|
575
|
-
|
577
|
+
when /\Assm:/i
|
578
|
+
ssm_instance_state = ssm_instance_states(ec2_instances.map(&:instance_id)).find do |i|
|
579
|
+
i.instance_id == instance.instance_id
|
580
|
+
end
|
581
|
+
|
582
|
+
if ssm_instance_state
|
583
|
+
query_struct(ssm_instance_state, attribute.split(":")[1..-1].join(":"))
|
576
584
|
end
|
585
|
+
else
|
586
|
+
query_struct(instance.data, attribute)
|
587
|
+
end
|
588
|
+
end
|
589
|
+
|
590
|
+
def query_struct(struct, attribute)
|
591
|
+
attribute.split(".").map(&:intern).inject struct do |_acc, method|
|
592
|
+
_acc.send method
|
577
593
|
end
|
578
594
|
end
|
579
595
|
end
|
data/lib/ec2ctl/logger.rb
CHANGED
@@ -50,13 +50,17 @@ module EC2Ctl
|
|
50
50
|
def to_hash(object)
|
51
51
|
case object
|
52
52
|
when Struct
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
Hash[
|
54
|
+
object.each_pair.to_a.map {|a|
|
55
|
+
[a.first, to_hash(a.last)]
|
56
|
+
}
|
57
|
+
]
|
56
58
|
when Hash
|
57
|
-
|
58
|
-
|
59
|
-
|
59
|
+
Hash[
|
60
|
+
object.to_a.map {|a|
|
61
|
+
[a.first, to_hash(a.last)]
|
62
|
+
}
|
63
|
+
]
|
60
64
|
when Array, Aws::Resources::Collection
|
61
65
|
object.map {|o| to_hash(o)}
|
62
66
|
when Aws::Resources::Resource
|
data/lib/ec2ctl/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ec2ctl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoriki Yamaguchi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -144,7 +144,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
144
144
|
requirements:
|
145
145
|
- - ">="
|
146
146
|
- !ruby/object:Gem::Version
|
147
|
-
version: 2.
|
147
|
+
version: 2.0.0
|
148
148
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - ">="
|