stemcell 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/bin/necrosis ADDED
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # -*- mode: shell -*-
4
+
5
+ require_relative '../lib/stemcell'
6
+
7
+ require 'trollop'
8
+
9
+ options = Trollop::options do
10
+ version "stemcell #{Stemcell::VERSION} (c) 2013 Martin Rhoads"
11
+ banner <<END_OF_BANNER
12
+ welcome to stemcell
13
+ END_OF_BANNER
14
+
15
+ opt('aws_access_key',
16
+ "aws access key",
17
+ :type => String,
18
+ :default => ENV['AWS_ACCESS_KEY']
19
+ )
20
+
21
+ opt('aws_secret_key',
22
+ "aws secret key",
23
+ :type => String,
24
+ :default => ENV['AWS_SECRET_KEY']
25
+ )
26
+
27
+ opt('region',
28
+ 'ec2 region to launch in',
29
+ :type => String,
30
+ :default => ENV['REGION'] ? ENV['REGION'] : 'us-east-1',
31
+ )
32
+
33
+ end
34
+
35
+
36
+ required_parameters = [
37
+ 'aws_access_key',
38
+ 'aws_secret_key',
39
+ ]
40
+
41
+
42
+ required_parameters.each do |arg|
43
+ raise ArgumentError, "--#{arg.gsub('_','-')} needs to be specified on the commandline or set \
44
+ by the #{arg.upcase.gsub('-','_')} environment variable" if
45
+ options[arg].nil? or ! options[arg]
46
+ end
47
+
48
+
49
+ raise ArgumentError, "you did not provide any instance ids to kill" if ARGV.size == 0
50
+
51
+
52
+ # create stemcell object
53
+ stemcell = Stemcell::Stemcell.new({
54
+ 'aws_access_key' => options['aws_access_key'],
55
+ 'aws_secret_key' => options['aws_secret_key'],
56
+ 'region' => options['region'],
57
+ })
58
+
59
+
60
+ # launch instance(s)
61
+ stemcell.kill(ARGV)
@@ -1,3 +1,3 @@
1
1
  module Stemcell
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/stemcell.rb CHANGED
@@ -86,6 +86,15 @@ module Stemcell
86
86
  return instances
87
87
  end
88
88
 
89
+ def kill(instance_list=[])
90
+ @log.info "killing instances #{instance_list}"
91
+ instances = instance_list.map {|id| @ec2.instances[id]}
92
+ instances.each do |instance|
93
+ instance.terminate
94
+ @log.info "killed instance #{instance.id}"
95
+ end
96
+ end
97
+
89
98
  private
90
99
 
91
100
  def print_run_info(instances)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stemcell
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -47,6 +47,7 @@ description: stemcell launches instances
47
47
  email:
48
48
  - martin.rhoads@airbnb.com
49
49
  executables:
50
+ - necrosis
50
51
  - stemcell
51
52
  extensions: []
52
53
  extra_rdoc_files: []
@@ -56,6 +57,7 @@ files:
56
57
  - LICENSE.txt
57
58
  - README.md
58
59
  - Rakefile
60
+ - bin/necrosis
59
61
  - bin/stemcell
60
62
  - examples/stemcellrc
61
63
  - lib/stemcell.rb