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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e80e3a14cf3ad4795bc1273295ee6b035e507d5c
4
- data.tar.gz: d032c6349e2f6a6e7a0e9f0463143e244a3aee42
3
+ metadata.gz: 3b7d6280530844f177bffe3fb56b25cf79cd3559
4
+ data.tar.gz: 92be8e05ef52d54aa68e69cef73d3f20035266f6
5
5
  SHA512:
6
- metadata.gz: a46430ddba38a195b0a075bef6f09f0eda61753dada4e13f97b349a6ff90b7bdecf75be1fe2ecb44d0035d93b284c4293f8cb63e4c03934cbd509ff8c7919ca4
7
- data.tar.gz: 548aca969b81f3988c6b5d668b9f2255df8e528bd24dbb5f96634f9dfec507412a742e9144ba8a46e628c8e7be93d213b64dec1640b0998fe90f798b526db46c
6
+ metadata.gz: 85621d795fa491c5b9501fc3253f4cd7c0f03b138e2006a8fe5656586a9c3794c96177da31317c1ae20a87bfebeb27e5d109d0c209d1973bd30fd17b343448f4
7
+ data.tar.gz: ee5bee41bebc34f67b4e4c98dd45dc654d6a4f1534da94704582537a19bcfb3d86c4216f949f95172dd7a0e2cb69f75fedc47206c045f6081e2b6b613693812d
@@ -1,3 +1,13 @@
1
+ # 0.5.4 (2017/01/19)
2
+
3
+ Enhancements:
4
+
5
+ * Add --spot and --no-spot option
6
+
7
+ Fixes:
8
+
9
+ * Show instances whose roles are empty
10
+
1
11
  # 0.5.3 (2017/01/19)
2
12
 
3
13
  Enhancements:
@@ -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).map(&:to_s)]}]
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
@@ -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
@@ -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 spot?
83
- instance.instance_lifecycle == 'spot'
86
+ def tenancy
87
+ instance.placement.tenancy
84
88
  end
85
89
 
86
- def dedicated?
87
- instance.placement.tenancy == 'dedicated'
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
 
@@ -26,6 +26,10 @@ class EC2
26
26
  def self.singularize(string)
27
27
  string.chomp('s')
28
28
  end
29
+
30
+ def self.stringify_symbols(array)
31
+ array.map {|e| e.is_a?(Symbol) ? e.to_s : e }
32
+ end
29
33
  end
30
34
  end
31
35
  end
@@ -1,5 +1,5 @@
1
1
  class EC2
2
2
  class Host
3
- VERSION = '0.5.3'
3
+ VERSION = '0.5.4'
4
4
  end
5
5
  end
@@ -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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ec2-host
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo