cliaws 1.4.2 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/License.txt +2 -2
- data/README.txt +0 -1
- data/Rakefile +50 -4
- data/VERSION +1 -0
- data/bin/cliec2 +2 -28
- data/bin/clis3 +2 -185
- data/bin/clisdb +44 -0
- data/bin/clisqs +2 -103
- data/cliaws.gemspec +40 -20
- data/lib/cliaws/cli/ec2.rb +97 -0
- data/lib/cliaws/cli/s3.rb +172 -0
- data/lib/cliaws/cli/sqs.rb +73 -0
- data/lib/cliaws/ec2.rb +38 -0
- data/lib/cliaws/s3.rb +1 -7
- data/lib/cliaws/sqs.rb +4 -4
- data/lib/cliaws.rb +0 -2
- metadata +20 -45
- data/Manifest.txt +0 -29
- data/config/hoe.rb +0 -73
- data/config/requirements.rb +0 -15
- data/lib/cliaws/version.rb +0 -9
- data/log/.gitignore +0 -0
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/script/txt2html +0 -74
- data/setup.rb +0 -1585
- data/tasks/deployment.rake +0 -46
- data/tasks/environment.rake +0 -7
- data/test/test_cliaws.rb +0 -11
- data/test/test_helper.rb +0 -2
- data/vendor/right_http_connection-1.2.1/README.txt +0 -3
- data/vendor/right_http_connection-1.2.1/lib/right_http_connection.rb +0 -117
data/.gitignore
CHANGED
data/License.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2008
|
1
|
+
Copyright (c) 2008 François Beausoleil
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
17
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
18
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
19
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.txt
CHANGED
data/Rakefile
CHANGED
@@ -1,4 +1,50 @@
|
|
1
|
-
|
2
|
-
require '
|
3
|
-
|
4
|
-
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
Jeweler::Tasks.new do |gemspec|
|
4
|
+
gemspec.name = "cliaws"
|
5
|
+
gemspec.rubyforge_project = gemspec.name
|
6
|
+
gemspec.email = "francois@teksol.info"
|
7
|
+
gemspec.homepage = "http://cliaws.rubyforge.org/"
|
8
|
+
gemspec.summary = "A command-line suite of tools to access Amazon Web Services, using the RightAws gems."
|
9
|
+
gemspec.description = gemspec.summary
|
10
|
+
gemspec.authors = ["François Beausoleil"]
|
11
|
+
gemspec.executables = %w(clis3 clisqs cliec2)
|
12
|
+
gemspec.extra_rdoc_files = %w(History.txt License.txt vendor/right_http_connection-1.2.1/README.txt)
|
13
|
+
|
14
|
+
gemspec.add_dependency "thor", "~> 0.9"
|
15
|
+
gemspec.add_dependency "right_aws", "~> 1.10"
|
16
|
+
end
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
19
|
+
end
|
20
|
+
|
21
|
+
begin
|
22
|
+
require 'rake/contrib/sshpublisher'
|
23
|
+
namespace :rubyforge do
|
24
|
+
|
25
|
+
desc "Release gem and RDoc documentation to RubyForge"
|
26
|
+
task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
|
27
|
+
|
28
|
+
namespace :release do
|
29
|
+
desc "Publish RDoc to RubyForge."
|
30
|
+
task :docs => [:rdoc] do
|
31
|
+
config = YAML.load(
|
32
|
+
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
33
|
+
)
|
34
|
+
|
35
|
+
host = "#{config['username']}@rubyforge.org"
|
36
|
+
remote_dir = "/var/www/gforge-projects/cliaws/"
|
37
|
+
local_dir = 'doc'
|
38
|
+
|
39
|
+
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
rescue LoadError
|
44
|
+
puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
|
45
|
+
end
|
46
|
+
|
47
|
+
task :rdoc do
|
48
|
+
rm_r "doc"
|
49
|
+
sh "rdoc --title 'Cliaws: Ruby command-line AWS client' --exclude=doc/"
|
50
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.5.0
|
data/bin/cliec2
CHANGED
@@ -1,29 +1,3 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
# Copyright (c) 2008. All rights reserved.
|
5
|
-
|
6
|
-
begin
|
7
|
-
require 'rubygems'
|
8
|
-
rescue LoadError
|
9
|
-
# no rubygems to load, so we fail silently
|
10
|
-
end
|
11
|
-
|
12
|
-
require "main"
|
13
|
-
|
14
|
-
$:.unshift File.dirname(__FILE__) + "/../lib"
|
15
|
-
require "cliaws"
|
16
|
-
|
17
|
-
Main {
|
18
|
-
mode("list") do
|
19
|
-
def run
|
20
|
-
instances = Cliaws.ec2.list
|
21
|
-
printf "%-50s %-12s %s\n", "DNS Name", "State", "Groups"
|
22
|
-
printf "-"*120
|
23
|
-
print "\n"
|
24
|
-
instances.each do |instance|
|
25
|
-
printf "%-50s %-12s %s\n", instance.public_dns_name, instance.state, instance.groups.join(", ")
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
}
|
2
|
+
require "cliaws/cli/ec2"
|
3
|
+
Cliaws::Cli::Ec2.start
|
data/bin/clis3
CHANGED
@@ -1,186 +1,3 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
# Copyright (c) 2008. All rights reserved.
|
5
|
-
|
6
|
-
begin
|
7
|
-
require 'rubygems'
|
8
|
-
rescue LoadError
|
9
|
-
# no rubygems to load, so we fail silently
|
10
|
-
end
|
11
|
-
|
12
|
-
require "main"
|
13
|
-
|
14
|
-
$:.unshift File.dirname(__FILE__) + "/../lib"
|
15
|
-
require "cliaws"
|
16
|
-
|
17
|
-
Main {
|
18
|
-
mixin :s3_object do
|
19
|
-
argument("s3_object") do
|
20
|
-
required
|
21
|
-
argument_required
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
mode("url") do
|
26
|
-
mixin :s3_object
|
27
|
-
|
28
|
-
def run
|
29
|
-
puts Cliaws.s3.url(params["s3_object"].value)
|
30
|
-
|
31
|
-
rescue Cliaws::S3::UnknownBucket
|
32
|
-
abort "Could not find bucket named #{$!.bucket_name}"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
mode("list") do
|
37
|
-
mixin :s3_object
|
38
|
-
|
39
|
-
def run
|
40
|
-
puts Cliaws.s3.list(params["s3_object"].value)
|
41
|
-
|
42
|
-
rescue Cliaws::S3::UnknownBucket
|
43
|
-
abort "Could not find bucket named #{$!.bucket_name}"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
mode("touch") do
|
48
|
-
mixin :s3_object
|
49
|
-
|
50
|
-
def run
|
51
|
-
Cliaws.s3.put("", params["s3_object"].value)
|
52
|
-
|
53
|
-
rescue Cliaws::S3::UnknownBucket
|
54
|
-
abort "Could not find bucket named #{$!.bucket_name}"
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
mode("put") do
|
59
|
-
argument("files_or_s3_path") do
|
60
|
-
optional
|
61
|
-
argument_required
|
62
|
-
arity -2
|
63
|
-
end
|
64
|
-
|
65
|
-
option("data") do
|
66
|
-
optional
|
67
|
-
argument_required
|
68
|
-
end
|
69
|
-
|
70
|
-
def run
|
71
|
-
paths = params["files_or_s3_path"].values
|
72
|
-
s3_object = paths.pop
|
73
|
-
|
74
|
-
single_put_mapper = lambda do |source, s3_path|
|
75
|
-
raise ArgumentError, "Writing directly from STDIN is forbidden when STDIN's size is unknown. The RightAws library will write a zero-byte file to Amazon's servers." unless source.respond_to?(:lstat) || source.respond_to?(:size)
|
76
|
-
s3_path
|
77
|
-
end
|
78
|
-
|
79
|
-
multi_put_mapper = lambda do |source, s3_path|
|
80
|
-
if source.respond_to?(:path) then
|
81
|
-
File.join(s3_path, File.basename(source.path))
|
82
|
-
else
|
83
|
-
raise ArgumentError, "Cannot write to a directory when one or more sources are not files: #{source.inspect}"
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
if params["data"].given? && !paths.empty? then
|
88
|
-
raise ArgumentError, "Cannot specify both --data and filename(s) to send."
|
89
|
-
elsif params["data"].given? then
|
90
|
-
sources = [StringIO.new(params["data"].value)]
|
91
|
-
mapper = single_put_mapper
|
92
|
-
elsif paths == ["-"] then
|
93
|
-
sources = [STDIN]
|
94
|
-
mapper = single_put_mapper
|
95
|
-
else
|
96
|
-
targets = paths.map {|filename| filename.to_s}
|
97
|
-
case targets.length
|
98
|
-
when 0
|
99
|
-
sources = [STDIN]
|
100
|
-
mapper = single_put_mapper
|
101
|
-
when 1
|
102
|
-
sources = targets.map {|target| File.open(target, "rb")}
|
103
|
-
mapper = single_put_mapper
|
104
|
-
else
|
105
|
-
sources = targets.map {|target| File.open(target, "rb")}
|
106
|
-
mapper = multi_put_mapper
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
sources.each do |source|
|
111
|
-
target = mapper.call(source, s3_object)
|
112
|
-
if source.respond_to?(:path) then
|
113
|
-
puts "#{source.path} => #{target}"
|
114
|
-
else
|
115
|
-
puts "STDIN => #{target}"
|
116
|
-
end
|
117
|
-
|
118
|
-
Cliaws.s3.put(source, target)
|
119
|
-
end
|
120
|
-
exit_success!
|
121
|
-
|
122
|
-
rescue Cliaws::S3::UnknownBucket
|
123
|
-
abort "Could not find bucket named #{$!.bucket_name}"
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
mode("rm") do
|
128
|
-
mixin :s3_object
|
129
|
-
|
130
|
-
def run
|
131
|
-
Cliaws.s3.rm(params["s3_object"].value)
|
132
|
-
|
133
|
-
rescue Cliaws::S3::UnknownBucket
|
134
|
-
abort "Could not find bucket named #{$!.bucket_name}"
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
mode("cat") do
|
139
|
-
mixin :s3_object
|
140
|
-
|
141
|
-
def run
|
142
|
-
Cliaws.s3.get(params["s3_object"].value, STDOUT)
|
143
|
-
puts
|
144
|
-
|
145
|
-
rescue Cliaws::S3::UnknownBucket
|
146
|
-
abort "Could not find bucket named #{$!.bucket_name}"
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
mode("get") do
|
151
|
-
mixin :s3_object
|
152
|
-
|
153
|
-
argument("local_file") do
|
154
|
-
argument_required
|
155
|
-
optional
|
156
|
-
end
|
157
|
-
|
158
|
-
def run
|
159
|
-
if params["local_file"].given? then
|
160
|
-
dest = File.open(params["local_file"].value, "wb")
|
161
|
-
else
|
162
|
-
dest = STDOUT
|
163
|
-
end
|
164
|
-
|
165
|
-
Cliaws.s3.get(params["s3_object"].value, dest)
|
166
|
-
|
167
|
-
rescue Cliaws::S3::UnknownBucket
|
168
|
-
abort "Could not find bucket named #{$!.bucket_name}"
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
mode("head") do
|
173
|
-
mixin :s3_object
|
174
|
-
|
175
|
-
def run
|
176
|
-
Cliaws.s3.head(params["s3_object"].value)
|
177
|
-
|
178
|
-
rescue Cliaws::S3::UnknownBucket
|
179
|
-
abort "Could not find bucket named #{$!.bucket_name}"
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
def run
|
184
|
-
abort "Required action argument missing. Run '#{$0} help' for details."
|
185
|
-
end
|
186
|
-
}
|
2
|
+
require "cliaws/cli/s3"
|
3
|
+
Cliaws::Cli::S3.start
|
data/bin/clisdb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Created on 2008-4-12.
|
4
|
+
# Copyright (c) 2008. All rights reserved.
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'rubygems'
|
8
|
+
rescue LoadError
|
9
|
+
# no rubygems to load, so we fail silently
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'optparse'
|
13
|
+
|
14
|
+
# NOTE: the option -p/--path= is given as an example, and should probably be replaced in your application.
|
15
|
+
|
16
|
+
OPTIONS = {
|
17
|
+
:path => '~'
|
18
|
+
}
|
19
|
+
MANDATORY_OPTIONS = %w( )
|
20
|
+
|
21
|
+
parser = OptionParser.new do |opts|
|
22
|
+
opts.banner = <<BANNER
|
23
|
+
This application is wonderful because...
|
24
|
+
|
25
|
+
Usage: #{File.basename($0)} [options]
|
26
|
+
|
27
|
+
Options are:
|
28
|
+
BANNER
|
29
|
+
opts.separator ""
|
30
|
+
opts.on("-p", "--path=PATH", String,
|
31
|
+
"The root path for selecting files",
|
32
|
+
"Default: ~") { |OPTIONS[:path]| }
|
33
|
+
opts.on("-h", "--help",
|
34
|
+
"Show this help message.") { puts opts; exit }
|
35
|
+
opts.parse!(ARGV)
|
36
|
+
|
37
|
+
if MANDATORY_OPTIONS && MANDATORY_OPTIONS.find { |option| OPTIONS[option.to_sym].nil? }
|
38
|
+
puts opts; exit
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
path = OPTIONS[:path]
|
43
|
+
|
44
|
+
# do stuff
|
data/bin/clisqs
CHANGED
@@ -1,104 +1,3 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
# Copyright (c) 2008. All rights reserved.
|
5
|
-
|
6
|
-
begin
|
7
|
-
require 'rubygems'
|
8
|
-
rescue LoadError
|
9
|
-
# no rubygems to load, so we fail silently
|
10
|
-
end
|
11
|
-
|
12
|
-
require "main"
|
13
|
-
require "cliaws"
|
14
|
-
|
15
|
-
Main {
|
16
|
-
mixin(:qname) do
|
17
|
-
argument("queue_name") do
|
18
|
-
required
|
19
|
-
argument_required
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
mode("create") do
|
24
|
-
mixin :qname
|
25
|
-
description "Create a new queue"
|
26
|
-
def run
|
27
|
-
Cliaws.sqs.create(queue_name)
|
28
|
-
puts "Queue #{queue_name} was created."
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
mode("delete") do
|
33
|
-
mixin :qname
|
34
|
-
description "Deletes a queue"
|
35
|
-
option("force") { cast :boolean; default false }
|
36
|
-
def run
|
37
|
-
Cliaws.sqs.delete(queue_name, params["force"].value)
|
38
|
-
puts "Queue #{queue_name} was deleted."
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
mode("list") do
|
43
|
-
description "Lists the available queues"
|
44
|
-
def run
|
45
|
-
puts Cliaws.sqs.list
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
mode("size") do
|
50
|
-
mixin :qname
|
51
|
-
description "Prints the queue's size."
|
52
|
-
def run
|
53
|
-
puts Cliaws.sqs.size(queue_name)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
mode("receive") do
|
58
|
-
mixin :qname
|
59
|
-
description "Receive (but keep) a message from the named queue."
|
60
|
-
def run
|
61
|
-
puts Cliaws.sqs.receive(queue_name)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
mode("pop") do
|
66
|
-
mixin :qname
|
67
|
-
description "Retrieve and delete a message from the named queue."
|
68
|
-
def run
|
69
|
-
puts Cliaws.sqs.pop(queue_name)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
mode("push") do
|
74
|
-
mixin :qname
|
75
|
-
option("data") { optional; argument_required }
|
76
|
-
argument("data_file") { optional; argument_required }
|
77
|
-
description "Pushes (sends) data from --data, data_file or STDIN to the named queue."
|
78
|
-
def run
|
79
|
-
data = case
|
80
|
-
when params["data"].given?
|
81
|
-
params["data"].value
|
82
|
-
when params["data_file"].given?
|
83
|
-
File.read(params["data_file"].value)
|
84
|
-
else
|
85
|
-
STDIN.read
|
86
|
-
end
|
87
|
-
Cliaws.sqs.push(queue_name, data)
|
88
|
-
puts "Pushed #{data.size} bytes to queue #{queue_name}"
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
mode("info") do
|
93
|
-
mixin :qname
|
94
|
-
def run
|
95
|
-
info = Cliaws.sqs.info(queue_name)
|
96
|
-
puts "Visibility: #{info[:visibility_timeout]}"
|
97
|
-
puts "Number of messages: #{info[:size]}"
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def queue_name
|
102
|
-
params["queue_name"].value
|
103
|
-
end
|
104
|
-
}
|
2
|
+
require "cliaws/cli/sqs"
|
3
|
+
Cliaws::Cli::Sqs.start
|
data/cliaws.gemspec
CHANGED
@@ -1,40 +1,60 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
1
3
|
Gem::Specification.new do |s|
|
2
4
|
s.name = %q{cliaws}
|
3
|
-
s.version = "1.
|
5
|
+
s.version = "1.5.0"
|
4
6
|
|
5
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
8
|
s.authors = ["Fran\303\247ois Beausoleil"]
|
7
|
-
s.date = %q{
|
9
|
+
s.date = %q{2009-07-07}
|
8
10
|
s.description = %q{A command-line suite of tools to access Amazon Web Services, using the RightAws gems.}
|
9
|
-
s.email =
|
11
|
+
s.email = %q{francois@teksol.info}
|
10
12
|
s.executables = ["clis3", "clisqs", "cliec2"]
|
11
|
-
s.extra_rdoc_files = [
|
12
|
-
|
13
|
+
s.extra_rdoc_files = [
|
14
|
+
"History.txt",
|
15
|
+
"License.txt"
|
16
|
+
]
|
17
|
+
s.files = [
|
18
|
+
".gitignore",
|
19
|
+
"History.txt",
|
20
|
+
"License.txt",
|
21
|
+
"README.txt",
|
22
|
+
"Rakefile",
|
23
|
+
"VERSION",
|
24
|
+
"bin/cliec2",
|
25
|
+
"bin/clis3",
|
26
|
+
"bin/clisdb",
|
27
|
+
"bin/clisqs",
|
28
|
+
"cliaws.gemspec",
|
29
|
+
"lib/cliaws.rb",
|
30
|
+
"lib/cliaws/cli/ec2.rb",
|
31
|
+
"lib/cliaws/cli/s3.rb",
|
32
|
+
"lib/cliaws/cli/sqs.rb",
|
33
|
+
"lib/cliaws/ec2.rb",
|
34
|
+
"lib/cliaws/s3.rb",
|
35
|
+
"lib/cliaws/sqs.rb"
|
36
|
+
]
|
13
37
|
s.has_rdoc = true
|
14
|
-
s.homepage = %q{http://cliaws.rubyforge.org}
|
15
|
-
s.rdoc_options = ["--
|
38
|
+
s.homepage = %q{http://cliaws.rubyforge.org/}
|
39
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
16
40
|
s.require_paths = ["lib"]
|
17
41
|
s.rubyforge_project = %q{cliaws}
|
18
|
-
s.rubygems_version = %q{1.2
|
42
|
+
s.rubygems_version = %q{1.3.2}
|
19
43
|
s.summary = %q{A command-line suite of tools to access Amazon Web Services, using the RightAws gems.}
|
20
|
-
s.test_files = ["test/test_cliaws.rb", "test/test_helper.rb"]
|
21
44
|
|
22
45
|
if s.respond_to? :specification_version then
|
23
46
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
|
-
s.specification_version =
|
47
|
+
s.specification_version = 3
|
25
48
|
|
26
|
-
if
|
27
|
-
s.add_runtime_dependency(%q<
|
28
|
-
s.add_runtime_dependency(%q<right_aws>, ["~> 1.
|
29
|
-
s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
|
49
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
50
|
+
s.add_runtime_dependency(%q<thor>, ["~> 0.9"])
|
51
|
+
s.add_runtime_dependency(%q<right_aws>, ["~> 1.10"])
|
30
52
|
else
|
31
|
-
s.add_dependency(%q<
|
32
|
-
s.add_dependency(%q<right_aws>, ["~> 1.
|
33
|
-
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
53
|
+
s.add_dependency(%q<thor>, ["~> 0.9"])
|
54
|
+
s.add_dependency(%q<right_aws>, ["~> 1.10"])
|
34
55
|
end
|
35
56
|
else
|
36
|
-
s.add_dependency(%q<
|
37
|
-
s.add_dependency(%q<right_aws>, ["~> 1.
|
38
|
-
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
57
|
+
s.add_dependency(%q<thor>, ["~> 0.9"])
|
58
|
+
s.add_dependency(%q<right_aws>, ["~> 1.10"])
|
39
59
|
end
|
40
60
|
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require "thor"
|
2
|
+
require "cliaws"
|
3
|
+
|
4
|
+
module Cliaws
|
5
|
+
module Cli
|
6
|
+
class Ec2 < Thor
|
7
|
+
map ["-h", "--help"] => :help
|
8
|
+
|
9
|
+
map ["describe-instances"] => :list
|
10
|
+
desc "list", <<EOD
|
11
|
+
Returns a list of all known EC2 instances
|
12
|
+
EOD
|
13
|
+
method_options :yaml => :boolean
|
14
|
+
def list
|
15
|
+
instances = Cliaws.ec2.list
|
16
|
+
if options[:yaml] then
|
17
|
+
puts instances.map {|i| i.raw_data}.to_yaml
|
18
|
+
else
|
19
|
+
printf "%-10s %-50s %-12s %s\n", "ID", "DNS Name", "State", "Groups"
|
20
|
+
printf "-"*120
|
21
|
+
print "\n"
|
22
|
+
instances.each do |instance|
|
23
|
+
printf "%-10s %-50s %-12s %s\n", instance.instance_id, instance.public_dns_name, instance.state, instance.groups.join(", ")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
map ["launch"] => :run
|
29
|
+
desc "run AMI", <<EOD
|
30
|
+
Launches one or more instances. Only one group may be specified at this time.
|
31
|
+
EOD
|
32
|
+
method_options :count => 1, :type => "m1.small", :keypair => :required, :group => :optional
|
33
|
+
def run(ami)
|
34
|
+
instances = Cliaws.ec2.run(ami, :type => options[:type], :count => options[:count], :keypair => options[:keypair], :groups => options[:group])
|
35
|
+
result = {"Started" => instances.map {|i| i.instance_id}}
|
36
|
+
puts result.to_yaml
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "terminate INSTANCE_ID [INSTANCE_ID...]", <<EOD
|
40
|
+
Terminates all specified instances.
|
41
|
+
EOD
|
42
|
+
def terminate(*instance_ids)
|
43
|
+
instances = Cliaws.ec2.terminate(instance_ids)
|
44
|
+
result = {"Terminating" => instances.map {|i| i.instance_id}}
|
45
|
+
puts result.to_yaml
|
46
|
+
end
|
47
|
+
|
48
|
+
map ["allocate-address"] => :allocate_address
|
49
|
+
desc "allocate-address", <<EOD
|
50
|
+
Assigns an elastic IP with your account.
|
51
|
+
EOD
|
52
|
+
def allocate_address
|
53
|
+
address = Cliaws.ec2.allocate_address
|
54
|
+
puts "Allocated: #{address}"
|
55
|
+
end
|
56
|
+
|
57
|
+
map ["deallocate-address"] => :deallocate_address
|
58
|
+
desc "deallocate-address ADDRESS", <<EOD
|
59
|
+
Deallocates the given Elastic IP address from your account.
|
60
|
+
EOD
|
61
|
+
def deallocate_address(address)
|
62
|
+
Cliaws.ec2.deallocate_address(address)
|
63
|
+
puts "Deallocated: #{address}"
|
64
|
+
end
|
65
|
+
|
66
|
+
map ["associate-address"] => :associate_address
|
67
|
+
method_options :address => :required, :instance => :required
|
68
|
+
desc "associate-address", <<EOD
|
69
|
+
Associates an address to an instance.
|
70
|
+
EOD
|
71
|
+
def associate_address
|
72
|
+
address = options[:address]
|
73
|
+
instance = options[:instance]
|
74
|
+
Cliaws.ec2.associate_address(:address => address, :instance => instance)
|
75
|
+
puts "Associated:\n #{instance}: #{address.inspect}"
|
76
|
+
end
|
77
|
+
|
78
|
+
map ["disassociate-address"] => :disassociate_address
|
79
|
+
desc "disassociate-address ADDRESS", <<EOD
|
80
|
+
Disassociates an address from an instance.
|
81
|
+
EOD
|
82
|
+
def disassociate_address(address)
|
83
|
+
address = options[:address]
|
84
|
+
Cliaws.ec2.disassociate_address(address)
|
85
|
+
puts "Disassociated: #{address}"
|
86
|
+
end
|
87
|
+
|
88
|
+
map ["describe-addresses"] => :describe_addresses
|
89
|
+
desc "describe-addresses", <<EOD
|
90
|
+
Returns a YAML representation of all Elastic IP addresses associated with this account.
|
91
|
+
EOD
|
92
|
+
def describe_addresses
|
93
|
+
puts Cliaws.ec2.describe_addresses.to_yaml
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|