sumo 0.1.1 → 0.1.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.
- data/README.rdoc +8 -0
- data/Rakefile +7 -0
- data/VERSION +1 -1
- data/bin/sumo +5 -2
- data/lib/sumo.rb +9 -5
- data/spec/base.rb +21 -0
- data/spec/sumo_spec.rb +31 -0
- metadata +7 -4
data/README.rdoc
CHANGED
@@ -49,11 +49,17 @@ Then create ~/.sumo/config.yml containing:
|
|
49
49
|
---
|
50
50
|
access_id: <your amazon access key id>
|
51
51
|
access_secret: <your amazon secret access key>
|
52
|
+
|
53
|
+
Optional config you can include in config.yml:
|
54
|
+
|
55
|
+
user: root
|
52
56
|
ami: ami-ed46a784
|
53
57
|
cookbooks_url: git://github.com/adamwiggins/chef-cookbooks.git
|
54
58
|
|
55
59
|
If you run any production machines from your EC2 account, I recommend setting up a separate account for use with Sumo. It does not prompt for confirmation when terminating an instance or differentiate between instances started by it vs. instances started by other tools.
|
56
60
|
|
61
|
+
You'll need Bacon and Mocha if you want to run the specs, and Jewler if you want to create gems.
|
62
|
+
|
57
63
|
== Features
|
58
64
|
|
59
65
|
Launch, ssh to, and terminate instances.
|
@@ -75,6 +81,8 @@ Sumo is not a cloud management tool, a monitor tool, or anything more than a way
|
|
75
81
|
|
76
82
|
Created by Adam Wiggins
|
77
83
|
|
84
|
+
Patches contributed by Blake Mizerany and Jesse Newland
|
85
|
+
|
78
86
|
Released under the MIT License: http://www.opensource.org/licenses/mit-license.php
|
79
87
|
|
80
88
|
http://github.com/adamwiggins/sumo
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/bin/sumo
CHANGED
@@ -95,6 +95,10 @@ class CLI < Thor
|
|
95
95
|
@sumo ||= Sumo.new
|
96
96
|
end
|
97
97
|
|
98
|
+
def config
|
99
|
+
sumo.config
|
100
|
+
end
|
101
|
+
|
98
102
|
def task(msg, &block)
|
99
103
|
printf "---> %-24s ", "#{msg}..."
|
100
104
|
start = Time.now
|
@@ -107,8 +111,7 @@ class CLI < Thor
|
|
107
111
|
|
108
112
|
def connect_ssh(hostname)
|
109
113
|
sumo.wait_for_ssh(hostname)
|
110
|
-
|
111
|
-
system "ssh -i #{sumo.keypair_file} root@#{hostname}"
|
114
|
+
system "ssh -i #{sumo.keypair_file} #{config['user']}@#{hostname}"
|
112
115
|
if $?.success?
|
113
116
|
puts "\nType 'sumo terminate' if you're done with this instance."
|
114
117
|
end
|
data/lib/sumo.rb
CHANGED
@@ -116,7 +116,7 @@ class Sumo
|
|
116
116
|
end
|
117
117
|
|
118
118
|
def ssh(hostname, cmds)
|
119
|
-
IO.popen("ssh -i #{keypair_file}
|
119
|
+
IO.popen("ssh -i #{keypair_file} #{config['user']}@#{hostname} > ~/.sumo/ssh.log 2>&1", "w") do |pipe|
|
120
120
|
pipe.puts cmds.join(' && ')
|
121
121
|
end
|
122
122
|
unless $?.success?
|
@@ -130,7 +130,7 @@ class Sumo
|
|
130
130
|
end
|
131
131
|
|
132
132
|
def fetch_resources(hostname)
|
133
|
-
cmd = "ssh -i #{keypair_file}
|
133
|
+
cmd = "ssh -i #{keypair_file} #{config['user']}@#{hostname} 'cat /root/resources' 2>&1"
|
134
134
|
out = IO.popen(cmd, 'r') { |pipe| pipe.read }
|
135
135
|
abort "failed to read resources, output:\n#{out}" unless $?.success?
|
136
136
|
parse_resources(out, hostname)
|
@@ -147,7 +147,11 @@ class Sumo
|
|
147
147
|
end
|
148
148
|
|
149
149
|
def config
|
150
|
-
@config ||= read_config
|
150
|
+
@config ||= default_config.merge read_config
|
151
|
+
end
|
152
|
+
|
153
|
+
def default_config
|
154
|
+
{ 'user' => 'root', 'ami' => 'ami-ed46a784' }
|
151
155
|
end
|
152
156
|
|
153
157
|
def sumo_dir
|
@@ -172,7 +176,7 @@ class Sumo
|
|
172
176
|
|
173
177
|
def create_security_group
|
174
178
|
ec2.create_security_group(:group_name => 'sumo', :group_description => 'Sumo')
|
175
|
-
rescue AWS::
|
179
|
+
rescue AWS::InvalidGroupDuplicate
|
176
180
|
end
|
177
181
|
|
178
182
|
def open_firewall(port)
|
@@ -183,7 +187,7 @@ class Sumo
|
|
183
187
|
:to_port => port,
|
184
188
|
:cidr_ip => '0.0.0.0/0'
|
185
189
|
)
|
186
|
-
rescue AWS::
|
190
|
+
rescue AWS::InvalidPermissionDuplicate
|
187
191
|
end
|
188
192
|
|
189
193
|
def ec2
|
data/spec/base.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../lib/sumo'
|
2
|
+
|
3
|
+
require 'bacon'
|
4
|
+
require 'mocha/standalone'
|
5
|
+
require 'mocha/object'
|
6
|
+
|
7
|
+
class Bacon::Context
|
8
|
+
include Mocha::API
|
9
|
+
|
10
|
+
def initialize(name, &block)
|
11
|
+
@name = name
|
12
|
+
@before, @after = [
|
13
|
+
[lambda { mocha_setup }],
|
14
|
+
[lambda { mocha_verify ; mocha_teardown }]
|
15
|
+
]
|
16
|
+
@block = block
|
17
|
+
end
|
18
|
+
|
19
|
+
def xit(desc, &bk)
|
20
|
+
end
|
21
|
+
end
|
data/spec/sumo_spec.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/base'
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
describe Sumo do
|
6
|
+
before do
|
7
|
+
@work_path = "/tmp/spec_#{Process.pid}/"
|
8
|
+
FileUtils.mkdir_p(@work_path)
|
9
|
+
File.open("#{@work_path}/config.yml", "w") do |f|
|
10
|
+
f.write YAML.dump({})
|
11
|
+
end
|
12
|
+
|
13
|
+
@sumo = Sumo.new
|
14
|
+
@sumo.stubs(:sumo_dir).returns(@work_path)
|
15
|
+
end
|
16
|
+
|
17
|
+
after do
|
18
|
+
FileUtils.rm_rf(@work_path)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "defaults to user root if none is specified in the config" do
|
22
|
+
@sumo.config['user'].should == 'root'
|
23
|
+
end
|
24
|
+
|
25
|
+
it "uses specified user if one is in the config" do
|
26
|
+
File.open("#{@work_path}/config.yml", "w") do |f|
|
27
|
+
f.write YAML.dump('user' => 'joe')
|
28
|
+
end
|
29
|
+
@sumo.config['user'].should == 'joe'
|
30
|
+
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sumo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Wiggins
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-05 00:00:00 -07:00
|
13
13
|
default_executable: sumo
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -27,6 +27,8 @@ files:
|
|
27
27
|
- VERSION
|
28
28
|
- bin/sumo
|
29
29
|
- lib/sumo.rb
|
30
|
+
- spec/base.rb
|
31
|
+
- spec/sumo_spec.rb
|
30
32
|
has_rdoc: true
|
31
33
|
homepage: http://github.com/adamwiggins/sumo
|
32
34
|
post_install_message:
|
@@ -53,5 +55,6 @@ rubygems_version: 1.3.1
|
|
53
55
|
signing_key:
|
54
56
|
specification_version: 2
|
55
57
|
summary: A no-hassle way to launch one-off EC2 instances from the command line
|
56
|
-
test_files:
|
57
|
-
|
58
|
+
test_files:
|
59
|
+
- spec/base.rb
|
60
|
+
- spec/sumo_spec.rb
|