ec2-blackout 0.0.1 → 0.0.2
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.
@@ -22,6 +22,7 @@ command "on" do |c|
|
|
22
22
|
|
23
23
|
c.option '-r', '--regions STRING', 'Comma separated list of regions to search. Defaults to all regions'
|
24
24
|
c.option '-x', '--exclude-by-tag STRING', 'Exclude instances with the specified tag.'
|
25
|
+
c.option '-d', '--dry-run', 'Find instances without stopping them'
|
25
26
|
|
26
27
|
c.action do |args, options|
|
27
28
|
options.default :regions => DEFAULT_REGIONS
|
@@ -36,6 +37,7 @@ command "off" do |c|
|
|
36
37
|
|
37
38
|
c.option '-r', '--regions STRING', 'Comma separated list of regions to search. Defaults to all regions'
|
38
39
|
c.option '-f', '--force', 'Force start up regardless of who shut them dowm'
|
40
|
+
c.option '-d', '--dry-run', 'Find instances without starting them'
|
39
41
|
|
40
42
|
c.action do |args, options|
|
41
43
|
options.default :regions => DEFAULT_REGIONS
|
@@ -12,8 +12,10 @@ class Ec2::Blackout::Shutdown
|
|
12
12
|
@aws.regions[region].instances.each do |instance|
|
13
13
|
if stoppable? instance
|
14
14
|
@ui.say "-> Stopping instance: #{instance.id}, name: #{instance.tags['Name']}"
|
15
|
-
|
16
|
-
|
15
|
+
unless dry_run?
|
16
|
+
instance.add_tag('ec2:blackout:on', Date.now.utc)
|
17
|
+
instance.stop
|
18
|
+
end
|
17
19
|
elsif instance.status == :running
|
18
20
|
@ui.say "-> Skipping instance: #{instance.id}, name: #{instance.tags['Name']}, region: #{region}"
|
19
21
|
end
|
@@ -37,4 +39,8 @@ class Ec2::Blackout::Shutdown
|
|
37
39
|
def exclude_tag
|
38
40
|
@options[:exclude_by_tag]
|
39
41
|
end
|
42
|
+
|
43
|
+
def dry_run?
|
44
|
+
@options[:dry_run]
|
45
|
+
end
|
40
46
|
end
|
data/lib/ec2-blackout/startup.rb
CHANGED
@@ -12,8 +12,10 @@ class Ec2::Blackout::Startup
|
|
12
12
|
@aws.regions[region].instances.each do |instance|
|
13
13
|
if startable? instance
|
14
14
|
@ui.say "-> Starting instance: #{instance.id}, name: #{instance.tags['Name']}"
|
15
|
-
|
16
|
-
|
15
|
+
unless dry_run?
|
16
|
+
instance.tags.delete('ec2:blackout:on')
|
17
|
+
instance.start
|
18
|
+
end
|
17
19
|
elsif instance.status == :stopped
|
18
20
|
@ui.say "-> Skipping instance: #{instance.id}, name: #{instance.tags['Name'] || 'N/A'}"
|
19
21
|
end
|
@@ -30,8 +32,11 @@ class Ec2::Blackout::Startup
|
|
30
32
|
end
|
31
33
|
|
32
34
|
def startable? instance
|
33
|
-
(instance.status == :stopped && instance.tags['ec2
|
35
|
+
(instance.status == :stopped && instance.tags['ec2:blackout:on']) ||
|
34
36
|
(instance.status == :stopped && @options[:force])
|
35
37
|
end
|
36
38
|
|
39
|
+
def dry_run?
|
40
|
+
@options[:dry_run]
|
41
|
+
end
|
37
42
|
end
|
data/lib/ec2-blackout/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: commander
|