ec2-blackout 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 29a1a8480263a9c3557fd5719059e878180bfa40
4
- data.tar.gz: c57c8c15e4e9a2699346fb88c919561ec97f5d53
3
+ metadata.gz: 32705d8bf54ddb910f5d98659489ebf821f1168f
4
+ data.tar.gz: d53dc475da7f1c68e5743d1d3065b3ef3b72443f
5
5
  SHA512:
6
- metadata.gz: 0b1b0c88a0f77aaf49e0e29c4949992892bd9f4e35353dd6fde4a1036b1e8891b7262d4d825864548a1242e94eb6bb7c36746a6de022161a285642e7875ae570
7
- data.tar.gz: b2167e51383d000e4a125a78ac9257af0156c9b39ddd08d1d5f0c813482960ebbf6cfafecdbca29cf5d96dcf9ae7254b08aafb96fd6af7a3a018cec49c1b6b97
6
+ metadata.gz: cc1dadcca1a007aab1ff5550574ed9c6575b2f6dadfc0200497669ddb1b5f1ddef420ff8c10cb1ab275052c5c4d2a329bb4a8c5d7f960fc92f26c22714cc3d4b
7
+ data.tar.gz: a69ffc6ef40007c0da599488dcf4f8ab769ff8f83c21fef8a70ee78b312e5b9d47646e09cbc2ace46dcb34de0963ea6442c67a0b8114d899ff7cc5ec0bb5aaad
data/Gemfile CHANGED
@@ -3,4 +3,4 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in ec2-sleeper.gemspec
4
4
  gemspec
5
5
 
6
- gem "rspec"
6
+ gem "rspec", "2.14.1"
@@ -29,6 +29,8 @@ command "off" do |c|
29
29
 
30
30
  c.option '-r', '--regions region1,region2', Array, 'Comma separated list of regions to search. Defaults to all regions'
31
31
  c.option '-f', '--force', 'Force start up regardless of who shut them dowm'
32
+ c.option '-x', '--exclude-by-tag tagname1=value,tagname2', Array, 'Comma separated list of name-value tags to exclude from the blackout off'
33
+ c.option '-i', '--include-by-tag tagname1=value,tagname2', Array, 'Comma separated list of name-value tags to include in the blackout off'
32
34
  c.option '-d', '--dry-run', 'Find instances without starting them'
33
35
 
34
36
  c.action do |args, options|
@@ -55,6 +55,10 @@ class Ec2::Blackout::Ec2Instance
55
55
  true
56
56
  elsif !tags[TIMESTAMP_TAG_NAME]
57
57
  [false, "instance was not originally stopped by ec2-blackout"]
58
+ elsif @options.matches_exclude_tags?(tags)
59
+ [false, "matches exclude tags"]
60
+ elsif !@options.matches_include_tags?(tags)
61
+ [false, "does not match include tags"]
58
62
  else
59
63
  true
60
64
  end
@@ -1,6 +1,6 @@
1
1
  module Ec2
2
2
  module Blackout
3
- VERSION = "0.0.9"
3
+ VERSION = "0.0.10"
4
4
 
5
5
  def self.name
6
6
  'ec2-blackout'
@@ -172,6 +172,31 @@ module Ec2::Blackout
172
172
  startable, reason = instance.startable?
173
173
  expect(startable).to be_true
174
174
  end
175
+
176
+ it "returns false if the instance matches the exclude tags specified in the options" do
177
+ options = Ec2::Blackout::Options.new(:exclude_by_tag => ["foo=bar"])
178
+ instance = stubbed_startable_instance(aws_instance, options)
179
+ aws_instance.stub(:tags).and_return(ec2_tags("foo" => "bar", Ec2Instance::TIMESTAMP_TAG_NAME => '2014-02-13 02:35:52 UTC'))
180
+ startable, reason = instance.startable?
181
+ expect(startable).to be_false
182
+ end
183
+
184
+ it "returns true if the instance matches the include tags specified in the options" do
185
+ options = Ec2::Blackout::Options.new(:include_by_tag => ["foo=bar"])
186
+ instance = stubbed_startable_instance(aws_instance, options)
187
+ aws_instance.stub(:tags).and_return(ec2_tags("foo" => "bar", Ec2Instance::TIMESTAMP_TAG_NAME => '2014-02-13 02:35:52 UTC'))
188
+ startable, reason = instance.startable?
189
+ expect(startable).to be_true
190
+ end
191
+
192
+ it "returns false if the instance does not match the include tags specified in the options" do
193
+ options = Ec2::Blackout::Options.new(:include_by_tag => ["foo=bar"])
194
+ instance = stubbed_startable_instance(aws_instance, options)
195
+ aws_instance.stub(:tags).and_return(ec2_tags("bar" => "baz", Ec2Instance::TIMESTAMP_TAG_NAME => '2014-02-13 02:35:52 UTC'))
196
+ startable, reason = instance.startable?
197
+ expect(startable).to be_false
198
+ end
199
+
175
200
  end
176
201
 
177
202
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ec2-blackout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Bartlett
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-01-14 00:00:00.000000000 Z
12
+ date: 2016-06-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: commander
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  version: '0'
104
104
  requirements: []
105
105
  rubyforge_project:
106
- rubygems_version: 2.4.5
106
+ rubygems_version: 2.4.5.1
107
107
  signing_key:
108
108
  specification_version: 4
109
109
  summary: A command-line tool to shutdown EC2 instances.