ec2-host 0.5.3 → 0.5.4
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 +10 -0
- data/lib/ec2/host.rb +1 -1
- data/lib/ec2/host/cli.rb +3 -0
- data/lib/ec2/host/host_data.rb +21 -6
- data/lib/ec2/host/string_util.rb +4 -0
- data/lib/ec2/host/version.rb +1 -1
- data/spec/host_spec.rb +5 -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: 3b7d6280530844f177bffe3fb56b25cf79cd3559
|
4
|
+
data.tar.gz: 92be8e05ef52d54aa68e69cef73d3f20035266f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85621d795fa491c5b9501fc3253f4cd7c0f03b138e2006a8fe5656586a9c3794c96177da31317c1ae20a87bfebeb27e5d109d0c209d1973bd30fd17b343448f4
|
7
|
+
data.tar.gz: ee5bee41bebc34f67b4e4c98dd45dc654d6a4f1534da94704582537a19bcfb3d86c4216f949f95172dd7a0e2cb69f75fedc47206c045f6081e2b6b613693812d
|
data/CHANGELOG.md
CHANGED
data/lib/ec2/host.rb
CHANGED
@@ -92,7 +92,7 @@ class EC2
|
|
92
92
|
raise ArgumentError, "Hash expected (options)" unless @options.is_a?(Hash)
|
93
93
|
@conditions = []
|
94
94
|
conditions.each do |condition|
|
95
|
-
@conditions << Hash[condition.map {|k, v| [k, Array(v)
|
95
|
+
@conditions << Hash[condition.map {|k, v| [k, StringUtil.stringify_symbols(Array(v))]}]
|
96
96
|
end
|
97
97
|
raise ArgumentError, "Array of Hash, or Hash expected (conditions)" unless @conditions.all? {|h| h.kind_of?(Hash)}
|
98
98
|
end
|
data/lib/ec2/host/cli.rb
CHANGED
@@ -45,6 +45,9 @@ class EC2
|
|
45
45
|
op.on('--monitoring one,two,three', Array, "filter with instance monitoring") {|v|
|
46
46
|
opts[:monitoring] = v
|
47
47
|
}
|
48
|
+
op.on('--[no-]spot', "filter to spot or non-spot instances") {|v|
|
49
|
+
opts[:spot] = v
|
50
|
+
}
|
48
51
|
Config.optional_options.each do |opt, tag|
|
49
52
|
op.on("--#{opt.to_s.gsub('_', '-')} one,two,three", Array, opt) {|v|
|
50
53
|
opts[opt.to_sym] = v
|
data/lib/ec2/host/host_data.rb
CHANGED
@@ -75,16 +75,20 @@ class EC2
|
|
75
75
|
instance.monitoring.state
|
76
76
|
end
|
77
77
|
|
78
|
+
def placement
|
79
|
+
instance.placement
|
80
|
+
end
|
81
|
+
|
78
82
|
def availability_zone
|
79
83
|
instance.placement.availability_zone
|
80
84
|
end
|
81
85
|
|
82
|
-
def
|
83
|
-
instance.
|
86
|
+
def tenancy
|
87
|
+
instance.placement.tenancy
|
84
88
|
end
|
85
89
|
|
86
|
-
def
|
87
|
-
instance.
|
90
|
+
def instance_lifecycle
|
91
|
+
instance.instance_lifecycle
|
88
92
|
end
|
89
93
|
|
90
94
|
# compatibility with dino-host
|
@@ -114,7 +118,7 @@ class EC2
|
|
114
118
|
state == "stopping"
|
115
119
|
end
|
116
120
|
|
117
|
-
def stopped
|
121
|
+
def stopped?
|
118
122
|
state == "stopped"
|
119
123
|
end
|
120
124
|
|
@@ -126,6 +130,16 @@ class EC2
|
|
126
130
|
state == "pending"
|
127
131
|
end
|
128
132
|
|
133
|
+
def spot?
|
134
|
+
instance_lifecycle == 'spot'
|
135
|
+
end
|
136
|
+
alias :spot :spot?
|
137
|
+
|
138
|
+
def dedicated?
|
139
|
+
tenancy == 'dedicated'
|
140
|
+
end
|
141
|
+
alias :dedicated :dedicated?
|
142
|
+
|
129
143
|
# match with condition or not
|
130
144
|
#
|
131
145
|
# @param [Hash] condition search parameters
|
@@ -159,7 +173,7 @@ class EC2
|
|
159
173
|
"launch_time" => launch_time,
|
160
174
|
"state" => state,
|
161
175
|
"monitoring" => monitoring,
|
162
|
-
"spot" => spot
|
176
|
+
"spot" => spot,
|
163
177
|
)
|
164
178
|
end
|
165
179
|
|
@@ -200,6 +214,7 @@ class EC2
|
|
200
214
|
(condition["role#{i}".to_sym] || condition["usage#{i}".to_sym] || []).first
|
201
215
|
end
|
202
216
|
end
|
217
|
+
return true if parts.compact.empty? # no role conditions
|
203
218
|
roles.find {|role| role.match?(*parts) }
|
204
219
|
end
|
205
220
|
|
data/lib/ec2/host/string_util.rb
CHANGED
data/lib/ec2/host/version.rb
CHANGED
data/spec/host_spec.rb
CHANGED
@@ -5,6 +5,7 @@ shared_examples_for 'host' do
|
|
5
5
|
[ :hostname,
|
6
6
|
:roles,
|
7
7
|
:region,
|
8
|
+
:availability_zone,
|
8
9
|
:service,
|
9
10
|
:status,
|
10
11
|
:tags,
|
@@ -15,6 +16,7 @@ shared_examples_for 'host' do
|
|
15
16
|
:launch_time,
|
16
17
|
:state,
|
17
18
|
:monitoring,
|
19
|
+
:spot,
|
18
20
|
:ip,
|
19
21
|
:start_date,
|
20
22
|
:usages,
|
@@ -50,13 +52,15 @@ describe EC2::Host do
|
|
50
52
|
'status',
|
51
53
|
'tags',
|
52
54
|
'region',
|
55
|
+
'availability_zone',
|
53
56
|
'instance_id',
|
54
57
|
'instance_type',
|
55
58
|
'private_ip_address',
|
56
59
|
'public_ip_address',
|
57
60
|
'launch_time',
|
58
61
|
'state',
|
59
|
-
'monitoring'
|
62
|
+
'monitoring',
|
63
|
+
'spot',
|
60
64
|
])
|
61
65
|
end
|
62
66
|
|