ec2-host 0.0.8 → 0.0.9
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 +4 -4
- data/CHANGELOG.md +8 -0
- data/ec2-host.gemspec +1 -1
- data/lib/ec2/host/cli.rb +6 -0
- data/lib/ec2/host/host_data.rb +21 -8
- 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: 0dc25b078ef99bec51f8d6d3d34c847c12482dab
|
4
|
+
data.tar.gz: 942cbde8877b6f20681cd3d098bf0ae04133ea3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c5e37497cbc0b41c888ed077542a1b5659631152f0de62678ad2ed5db6df45cfd77d7ab54efa093d603ab3fb638ed2cbacb626e60753d0af3c077e66b11135e
|
7
|
+
data.tar.gz: 8bb986e56f4508a652942a16e28ee0ba9f0f110d40e6640d064d866e76c0d983873b9336f4a2d581a81b156849e446e0056aafc2d2f561cee544618b04fa1529
|
data/CHANGELOG.md
CHANGED
data/ec2-host.gemspec
CHANGED
data/lib/ec2/host/cli.rb
CHANGED
@@ -30,6 +30,12 @@ class EC2
|
|
30
30
|
option :instance_id,
|
31
31
|
:type => :array,
|
32
32
|
:desc => "instance_id"
|
33
|
+
option :state,
|
34
|
+
:type => :array,
|
35
|
+
:desc => "state"
|
36
|
+
option :monitoring,
|
37
|
+
:type => :array,
|
38
|
+
:desc => "monitoring"
|
33
39
|
Config.optional_options.each do |opt, tag|
|
34
40
|
option opt, :type => :array, :desc => opt
|
35
41
|
end
|
data/lib/ec2/host/host_data.rb
CHANGED
@@ -18,9 +18,9 @@ class EC2
|
|
18
18
|
:instance_id,
|
19
19
|
:private_ip_address,
|
20
20
|
:public_ip_address,
|
21
|
-
:launch_time
|
22
|
-
|
23
|
-
|
21
|
+
:launch_time
|
22
|
+
def state; instance.state.name; end
|
23
|
+
def monitoring; instance.monitoring.state; end
|
24
24
|
|
25
25
|
alias_method :ip, :private_ip_address
|
26
26
|
alias_method :start_date, :launch_time
|
@@ -41,16 +41,18 @@ class EC2
|
|
41
41
|
#
|
42
42
|
# @param [Hash] condition search parameters
|
43
43
|
def match?(condition)
|
44
|
+
return false if !condition[:state] and terminated? # remove terminated host from lists as default
|
44
45
|
return false unless role_match?(condition)
|
45
46
|
condition = HashUtil.except(condition,
|
46
47
|
:role, :role1, :role2, :role3,
|
47
48
|
:usage, :usage1, :usage2, :usage3
|
48
49
|
)
|
49
50
|
condition.each do |key, values|
|
50
|
-
|
51
|
-
|
51
|
+
v = get_value(key)
|
52
|
+
if v.is_a?(Array)
|
53
|
+
return false unless v.find {|_| values.include?(_) }
|
52
54
|
else
|
53
|
-
return false unless values.include?(
|
55
|
+
return false unless values.include?(v)
|
54
56
|
end
|
55
57
|
end
|
56
58
|
true
|
@@ -79,13 +81,24 @@ class EC2
|
|
79
81
|
private_ip_address: private_ip_address,
|
80
82
|
public_ip_address: public_ip_address,
|
81
83
|
launch_time: launch_time,
|
82
|
-
state: state
|
83
|
-
monitoring: monitoring
|
84
|
+
state: state,
|
85
|
+
monitoring: monitoring,
|
84
86
|
).to_json
|
85
87
|
end
|
86
88
|
|
87
89
|
# private
|
88
90
|
|
91
|
+
# "instance.instance_id" => self.send("instance").send("instance_id")
|
92
|
+
def get_value(key)
|
93
|
+
v = self
|
94
|
+
key.to_s.split('.').each {|k| v = v.send(k) }
|
95
|
+
v
|
96
|
+
end
|
97
|
+
|
98
|
+
def terminated?
|
99
|
+
state == "terminated"
|
100
|
+
end
|
101
|
+
|
89
102
|
def role_match?(condition)
|
90
103
|
# usage is an alias of role
|
91
104
|
if role = (condition[:role] || condition[:usage])
|