rudy 0.4.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +54 -30
- data/README.rdoc +100 -12
- data/Rakefile +103 -8
- data/Rudyfile +119 -0
- data/bin/ird +175 -0
- data/bin/rudy +259 -156
- data/bin/rudy-ec2 +228 -95
- data/bin/rudy-s3 +76 -0
- data/bin/rudy-sdb +67 -0
- data/lib/annoy.rb +270 -0
- data/lib/console.rb +30 -9
- data/lib/escape.rb +305 -0
- data/lib/rudy.rb +151 -182
- data/lib/rudy/aws.rb +56 -49
- data/lib/rudy/aws/ec2.rb +47 -292
- data/lib/rudy/aws/ec2/address.rb +157 -0
- data/lib/rudy/aws/ec2/group.rb +301 -0
- data/lib/rudy/aws/ec2/image.rb +168 -0
- data/lib/rudy/aws/ec2/instance.rb +434 -0
- data/lib/rudy/aws/ec2/keypair.rb +104 -0
- data/lib/rudy/aws/ec2/snapshot.rb +98 -0
- data/lib/rudy/aws/ec2/volume.rb +230 -0
- data/lib/rudy/aws/ec2/zone.rb +77 -0
- data/lib/rudy/aws/s3.rb +54 -0
- data/lib/rudy/aws/sdb.rb +298 -0
- data/lib/rudy/aws/sdb/error.rb +46 -0
- data/lib/rudy/{metadata/backup.rb → backup.rb} +26 -51
- data/lib/rudy/cli.rb +157 -0
- data/lib/rudy/cli/aws/ec2/addresses.rb +105 -0
- data/lib/rudy/cli/aws/ec2/candy.rb +208 -0
- data/lib/rudy/cli/aws/ec2/groups.rb +121 -0
- data/lib/rudy/cli/aws/ec2/images.rb +196 -0
- data/lib/rudy/cli/aws/ec2/instances.rb +194 -0
- data/lib/rudy/cli/aws/ec2/keypairs.rb +53 -0
- data/lib/rudy/cli/aws/ec2/snapshots.rb +49 -0
- data/lib/rudy/cli/aws/ec2/volumes.rb +104 -0
- data/lib/rudy/cli/aws/ec2/zones.rb +22 -0
- data/lib/rudy/cli/aws/s3/buckets.rb +50 -0
- data/lib/rudy/cli/aws/s3/store.rb +22 -0
- data/lib/rudy/cli/aws/sdb/domains.rb +41 -0
- data/lib/rudy/cli/candy.rb +8 -0
- data/lib/rudy/{command → cli}/config.rb +34 -24
- data/lib/rudy/cli/disks.rb +35 -0
- data/lib/rudy/cli/machines.rb +94 -0
- data/lib/rudy/cli/routines.rb +57 -0
- data/lib/rudy/config.rb +77 -72
- data/lib/rudy/config/objects.rb +29 -0
- data/lib/rudy/disks.rb +248 -0
- data/lib/rudy/global.rb +121 -0
- data/lib/rudy/huxtable.rb +340 -0
- data/lib/rudy/machines.rb +245 -0
- data/lib/rudy/metadata.rb +123 -13
- data/lib/rudy/routines.rb +47 -0
- data/lib/rudy/routines/helpers/diskhelper.rb +101 -0
- data/lib/rudy/routines/helpers/scripthelper.rb +91 -0
- data/lib/rudy/routines/release.rb +34 -0
- data/lib/rudy/routines/shutdown.rb +57 -0
- data/lib/rudy/routines/startup.rb +58 -0
- data/lib/rudy/scm/svn.rb +1 -1
- data/lib/rudy/utils.rb +322 -4
- data/lib/storable.rb +26 -17
- data/lib/sysinfo.rb +274 -0
- data/lib/tryouts.rb +6 -13
- data/rudy.gemspec +128 -42
- data/support/randomize-root-password +45 -0
- data/support/rudy-ec2-startup +9 -9
- data/support/update-ec2-ami-tools +20 -0
- data/test/05_config/00_setup_test.rb +20 -0
- data/test/05_config/30_machines_test.rb +69 -0
- data/test/20_sdb/00_setup_test.rb +16 -0
- data/test/20_sdb/10_domains_test.rb +115 -0
- data/test/25_ec2/00_setup_test.rb +29 -0
- data/test/25_ec2/10_keypairs_test.rb +41 -0
- data/test/25_ec2/20_groups_test.rb +131 -0
- data/test/25_ec2/30_addresses_test.rb +38 -0
- data/test/25_ec2/40_volumes_test.rb +49 -0
- data/test/25_ec2/50_snapshots_test.rb +74 -0
- data/test/26_ec2_instances/00_setup_test.rb +28 -0
- data/test/26_ec2_instances/10_instances_test.rb +83 -0
- data/test/26_ec2_instances/50_images_test.rb +13 -0
- data/test/30_sdb_metadata/00_setup_test.rb +21 -0
- data/test/30_sdb_metadata/10_disks_test.rb +109 -0
- data/test/30_sdb_metadata/20_backups_test.rb +102 -0
- data/test/coverage.txt +51 -0
- data/test/helper.rb +36 -0
- data/vendor/highline-1.5.1/CHANGELOG +222 -0
- data/vendor/highline-1.5.1/INSTALL +35 -0
- data/vendor/highline-1.5.1/LICENSE +7 -0
- data/vendor/highline-1.5.1/README +63 -0
- data/vendor/highline-1.5.1/Rakefile +82 -0
- data/vendor/highline-1.5.1/TODO +6 -0
- data/vendor/highline-1.5.1/examples/ansi_colors.rb +38 -0
- data/vendor/highline-1.5.1/examples/asking_for_arrays.rb +18 -0
- data/vendor/highline-1.5.1/examples/basic_usage.rb +75 -0
- data/vendor/highline-1.5.1/examples/color_scheme.rb +32 -0
- data/vendor/highline-1.5.1/examples/limit.rb +12 -0
- data/vendor/highline-1.5.1/examples/menus.rb +65 -0
- data/vendor/highline-1.5.1/examples/overwrite.rb +19 -0
- data/vendor/highline-1.5.1/examples/page_and_wrap.rb +322 -0
- data/vendor/highline-1.5.1/examples/password.rb +7 -0
- data/vendor/highline-1.5.1/examples/trapping_eof.rb +22 -0
- data/vendor/highline-1.5.1/examples/using_readline.rb +17 -0
- data/vendor/highline-1.5.1/lib/highline.rb +758 -0
- data/vendor/highline-1.5.1/lib/highline/color_scheme.rb +120 -0
- data/vendor/highline-1.5.1/lib/highline/compatibility.rb +17 -0
- data/vendor/highline-1.5.1/lib/highline/import.rb +43 -0
- data/vendor/highline-1.5.1/lib/highline/menu.rb +395 -0
- data/vendor/highline-1.5.1/lib/highline/question.rb +463 -0
- data/vendor/highline-1.5.1/lib/highline/system_extensions.rb +193 -0
- data/vendor/highline-1.5.1/setup.rb +1360 -0
- data/vendor/highline-1.5.1/test/tc_color_scheme.rb +56 -0
- data/vendor/highline-1.5.1/test/tc_highline.rb +823 -0
- data/vendor/highline-1.5.1/test/tc_import.rb +54 -0
- data/vendor/highline-1.5.1/test/tc_menu.rb +429 -0
- data/vendor/highline-1.5.1/test/ts_all.rb +15 -0
- metadata +141 -38
- data/lib/aws_sdb.rb +0 -3
- data/lib/aws_sdb/error.rb +0 -42
- data/lib/aws_sdb/service.rb +0 -215
- data/lib/rudy/aws/simpledb.rb +0 -53
- data/lib/rudy/command/addresses.rb +0 -46
- data/lib/rudy/command/backups.rb +0 -175
- data/lib/rudy/command/base.rb +0 -841
- data/lib/rudy/command/deploy.rb +0 -12
- data/lib/rudy/command/disks.rb +0 -213
- data/lib/rudy/command/environment.rb +0 -73
- data/lib/rudy/command/groups.rb +0 -61
- data/lib/rudy/command/images.rb +0 -91
- data/lib/rudy/command/instances.rb +0 -85
- data/lib/rudy/command/machines.rb +0 -161
- data/lib/rudy/command/metadata.rb +0 -41
- data/lib/rudy/command/release.rb +0 -174
- data/lib/rudy/command/volumes.rb +0 -66
- data/lib/rudy/metadata/disk.rb +0 -138
- data/tryouts/console_tryout.rb +0 -91
data/lib/storable.rb
CHANGED
@@ -13,9 +13,11 @@ require 'fileutils'
|
|
13
13
|
# Storable.field method which tells Storable the order and
|
14
14
|
# name.
|
15
15
|
class Storable
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
unless defined?(SUPPORTED_FORMATS) # We can assume all are defined
|
17
|
+
VERSION = 5
|
18
|
+
NICE_TIME_FORMAT = "%Y-%m-%d@%H:%M:%S".freeze
|
19
|
+
SUPPORTED_FORMATS = %w{tsv csv yaml json s string}.freeze
|
20
|
+
end
|
19
21
|
|
20
22
|
# This value will be used as a default unless provided on-the-fly.
|
21
23
|
# See SUPPORTED_FORMATS for available values.
|
@@ -27,14 +29,11 @@ class Storable
|
|
27
29
|
@format = v
|
28
30
|
end
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
def init
|
33
|
-
# NOTE: I think this can be removed
|
34
|
-
self.class.send(:class_variable_set, :@@field_names, []) unless class_variable_defined?(:@@field_names)
|
35
|
-
self.class.send(:class_variable_set, :@@field_types, []) unless class_variable_defined?(:@@field_types)
|
32
|
+
def postprocess
|
36
33
|
end
|
37
34
|
|
35
|
+
# TODO: from_args([HASH or ordered params])
|
36
|
+
|
38
37
|
# Accepts field definitions in the one of the follow formats:
|
39
38
|
#
|
40
39
|
# field :product
|
@@ -68,7 +67,7 @@ class Storable
|
|
68
67
|
def self.field_names
|
69
68
|
class_variable_get(:@@field_names)
|
70
69
|
end
|
71
|
-
#
|
70
|
+
# Returns an array of field names defined by self.field
|
72
71
|
def field_names
|
73
72
|
self.class.send(:class_variable_get, :@@field_names)
|
74
73
|
end
|
@@ -77,18 +76,23 @@ class Storable
|
|
77
76
|
def self.field_types
|
78
77
|
class_variable_get(:@@field_types)
|
79
78
|
end
|
80
|
-
#
|
79
|
+
# Returns an array of field types defined by self.field. Fields that did
|
80
|
+
# not receive a type are set to nil.
|
81
81
|
def field_types
|
82
82
|
self.class.send(:class_variable_get, :@@field_types)
|
83
83
|
end
|
84
84
|
|
85
85
|
# Dump the object data to the given format.
|
86
|
-
def dump(format=nil, with_titles=
|
87
|
-
format ||=
|
86
|
+
def dump(format=nil, with_titles=false)
|
87
|
+
format ||= 's' # as in, to_s
|
88
88
|
raise "Format not defined (#{format})" unless SUPPORTED_FORMATS.member?(format)
|
89
89
|
send("to_#{format}", with_titles)
|
90
90
|
end
|
91
91
|
|
92
|
+
def to_string(*args)
|
93
|
+
to_s(*args)
|
94
|
+
end
|
95
|
+
|
92
96
|
# Create a new instance of the object using data from file.
|
93
97
|
def self.from_file(file_path, format='yaml')
|
94
98
|
raise "Cannot read file (#{file_path})" unless File.exists?(file_path)
|
@@ -108,10 +112,9 @@ class Storable
|
|
108
112
|
|
109
113
|
# Create a new instance of the object from a hash.
|
110
114
|
def self.from_hash(from={})
|
115
|
+
return nil if !from || from.empty?
|
111
116
|
me = self.new
|
112
|
-
|
113
|
-
return me if !from || from.empty?
|
114
|
-
|
117
|
+
|
115
118
|
fnames = field_names
|
116
119
|
fnames.each_with_index do |key,index|
|
117
120
|
|
@@ -122,8 +125,10 @@ class Storable
|
|
122
125
|
if field_types[index] == Array
|
123
126
|
((value ||= []) << stored_value).flatten
|
124
127
|
elsif field_types[index] == Hash
|
128
|
+
|
125
129
|
value = stored_value
|
126
130
|
else
|
131
|
+
|
127
132
|
# SimpleDB stores attribute shit as lists of values
|
128
133
|
value = stored_value.first if stored_value.is_a?(Array) && stored_value.size == 1
|
129
134
|
|
@@ -137,14 +142,18 @@ class Storable
|
|
137
142
|
value = value.to_f
|
138
143
|
elsif field_types[index] == Integer
|
139
144
|
value = value.to_i
|
145
|
+
elsif field_types[index].kind_of?(Storable) && stored_value.is_a?(Hash)
|
146
|
+
value = field_types[index].from_hash(stored_value)
|
140
147
|
else
|
141
|
-
value =
|
148
|
+
value = (stored_value.is_a?(Array) && stored_value.size == 1) ? stored_value.first : stored_value
|
142
149
|
end
|
143
150
|
end
|
144
151
|
|
145
152
|
me.send("#{key}=", value) if self.method_defined?("#{key}=")
|
146
153
|
end
|
147
154
|
|
155
|
+
me.postprocess
|
156
|
+
|
148
157
|
me
|
149
158
|
end
|
150
159
|
# Return the object data as a hash
|
data/lib/sysinfo.rb
ADDED
@@ -0,0 +1,274 @@
|
|
1
|
+
require 'storable'
|
2
|
+
require 'socket'
|
3
|
+
|
4
|
+
# SystemInfo
|
5
|
+
#
|
6
|
+
# A container for the system platform information.
|
7
|
+
# Portions of this code is from Amazon's EC2 AMI tools, lib/platform.rb.
|
8
|
+
class SystemInfo < Storable
|
9
|
+
unless defined?(IMPLEMENTATIONS)
|
10
|
+
VERSION = 2.freeze
|
11
|
+
IMPLEMENTATIONS = [
|
12
|
+
|
13
|
+
# These are for JRuby, System.getproperty('os.name').
|
14
|
+
# For a list of all values, see: http://lopica.sourceforge.net/os.html
|
15
|
+
[/mac\s*os\s*x/i, :unix, :osx ],
|
16
|
+
[/sunos/i, :unix, :solaris ],
|
17
|
+
[/windows\s*ce/i, :win32, :windows ],
|
18
|
+
[/windows/i, :win32, :windows ],
|
19
|
+
[/osx/i, :unix, :osx ],
|
20
|
+
|
21
|
+
# TODO: implement other windows matches: # /djgpp|(cyg|ms|bcc)win|mingw/ (from mongrel)
|
22
|
+
|
23
|
+
# These are for RUBY_PLATFORM and JRuby
|
24
|
+
[/java/i, :java, :java ],
|
25
|
+
[/darwin/i, :unix, :osx ],
|
26
|
+
[/linux/i, :unix, :linux ],
|
27
|
+
[/freebsd/i, :unix, :freebsd ],
|
28
|
+
[/netbsd/i, :unix, :netbsd ],
|
29
|
+
[/solaris/i, :unix, :solaris ],
|
30
|
+
[/irix/i, :unix, :irix ],
|
31
|
+
[/cygwin/i, :unix, :cygwin ],
|
32
|
+
[/mswin/i, :win32, :windows ],
|
33
|
+
[/mingw/i, :win32, :mingw ],
|
34
|
+
[/bccwin/i, :win32, :bccwin ],
|
35
|
+
[/wince/i, :win32, :wince ],
|
36
|
+
[/vms/i, :vms, :vms ],
|
37
|
+
[/os2/i, :os2, :os2 ],
|
38
|
+
[nil, :unknown, :unknown ],
|
39
|
+
].freeze
|
40
|
+
|
41
|
+
ARCHITECTURES = [
|
42
|
+
[/(i\d86)/i, :i386 ],
|
43
|
+
[/x86_64/i, :x86_64 ],
|
44
|
+
[/x86/i, :i386 ], # JRuby
|
45
|
+
[/ia64/i, :ia64 ],
|
46
|
+
[/alpha/i, :alpha ],
|
47
|
+
[/sparc/i, :sparc ],
|
48
|
+
[/mips/i, :mips ],
|
49
|
+
[/powerpc/i, :powerpc ],
|
50
|
+
[/universal/i,:universal ],
|
51
|
+
[nil, :unknown ],
|
52
|
+
].freeze
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
field :os => String
|
57
|
+
field :implementation => String
|
58
|
+
field :architecture => String
|
59
|
+
field :hostname => String
|
60
|
+
field :ipaddress => String
|
61
|
+
field :uptime => Float
|
62
|
+
|
63
|
+
|
64
|
+
alias :impl :implementation
|
65
|
+
alias :arch :architecture
|
66
|
+
|
67
|
+
|
68
|
+
def initialize
|
69
|
+
@os, @implementation, @architecture = guess
|
70
|
+
@hostname, @ipaddress, @uptime = get_info
|
71
|
+
end
|
72
|
+
|
73
|
+
# guess
|
74
|
+
#
|
75
|
+
# This is called at require-time in stella.rb. It guesses
|
76
|
+
# the current operating system, implementation, architecture.
|
77
|
+
# Returns [os, impl, arch]
|
78
|
+
def guess
|
79
|
+
os = :unknown
|
80
|
+
impl = :unknown
|
81
|
+
arch = :unknown
|
82
|
+
IMPLEMENTATIONS.each do |r, o, i|
|
83
|
+
if r and RUBY_PLATFORM =~ r
|
84
|
+
os, impl = [o, i]
|
85
|
+
break
|
86
|
+
end
|
87
|
+
end
|
88
|
+
ARCHITECTURES.each do |r, a|
|
89
|
+
if r and RUBY_PLATFORM =~ r
|
90
|
+
arch = a
|
91
|
+
break
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
#
|
96
|
+
if os == :win32
|
97
|
+
#require 'Win32API'
|
98
|
+
|
99
|
+
# If we're running in java, we'll need to look elsewhere
|
100
|
+
# for the implementation and architecture.
|
101
|
+
# We'll replace IMPL and ARCH with what we find.
|
102
|
+
elsif os == :java
|
103
|
+
require 'java'
|
104
|
+
include_class java.lang.System
|
105
|
+
|
106
|
+
osname = System.getProperty("os.name")
|
107
|
+
IMPLEMENTATIONS.each do |r, o, i|
|
108
|
+
if r and osname =~ r
|
109
|
+
impl = i
|
110
|
+
break
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
osarch = System.getProperty("os.arch")
|
115
|
+
ARCHITECTURES.each do |r, a|
|
116
|
+
if r and osarch =~ r
|
117
|
+
arch = a
|
118
|
+
break
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
[os, impl, arch]
|
125
|
+
end
|
126
|
+
|
127
|
+
# get_info
|
128
|
+
#
|
129
|
+
# Returns [hostname, ipaddr, uptime] for the local machine
|
130
|
+
def get_info
|
131
|
+
hostname = :unknown
|
132
|
+
ipaddr = :unknown
|
133
|
+
uptime = :unknown
|
134
|
+
|
135
|
+
begin
|
136
|
+
hostname = local_hostname
|
137
|
+
ipaddr = local_ip_address
|
138
|
+
uptime = local_uptime
|
139
|
+
rescue => ex
|
140
|
+
# Be silent!
|
141
|
+
end
|
142
|
+
|
143
|
+
[hostname, ipaddr, uptime]
|
144
|
+
end
|
145
|
+
|
146
|
+
# local_hostname
|
147
|
+
#
|
148
|
+
# Return the hostname for the local machine
|
149
|
+
def local_hostname
|
150
|
+
Socket.gethostname
|
151
|
+
end
|
152
|
+
|
153
|
+
# local_uptime
|
154
|
+
#
|
155
|
+
# Returns the local uptime in hours. Use Win32API in Windows,
|
156
|
+
# 'sysctl -b kern.boottime' os osx, and 'who -b' on unix.
|
157
|
+
# Based on Ruby Quiz solutions by: Matthias Reitinger
|
158
|
+
# On Windows, see also: net statistics server
|
159
|
+
def local_uptime
|
160
|
+
|
161
|
+
# Each method must return uptime in seconds
|
162
|
+
methods = {
|
163
|
+
|
164
|
+
:win32_windows => lambda {
|
165
|
+
# Win32API is required in self.guess
|
166
|
+
getTickCount = Win32API.new("kernel32", "GetTickCount", nil, 'L')
|
167
|
+
((getTickCount.call()).to_f / 1000).to_f
|
168
|
+
},
|
169
|
+
|
170
|
+
# Ya, this is kinda wack. Ruby -> Java -> Kernel32. See:
|
171
|
+
# http://www.oreillynet.com/ruby/blog/2008/01/jruby_meets_the_windows_api_1.html
|
172
|
+
# http://msdn.microsoft.com/en-us/library/ms724408(VS.85).aspx
|
173
|
+
# Ruby 1.9.1: Win32API is now deprecated in favor of using the DL library.
|
174
|
+
:java_windows => lambda {
|
175
|
+
kernel32 = com.sun.jna.NativeLibrary.getInstance('kernel32')
|
176
|
+
buf = java.nio.ByteBuffer.allocate(256)
|
177
|
+
(kernel32.getFunction('GetTickCount').invokeInt([256, buf].to_java).to_f / 1000).to_f
|
178
|
+
},
|
179
|
+
|
180
|
+
:unix_osx => lambda {
|
181
|
+
# This is faster than who and could work on BSD also.
|
182
|
+
(Time.now.to_f - Time.at(`sysctl -b kern.boottime 2>/dev/null`.unpack('L').first).to_f).to_f
|
183
|
+
},
|
184
|
+
# This should work for most unix flavours.
|
185
|
+
:unix => lambda {
|
186
|
+
# who is sloooooow. Use File.read('/proc/uptime')
|
187
|
+
(Time.now.to_f - Time.parse(`who -b 2>/dev/null`).to_f)
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
hours = 0
|
192
|
+
|
193
|
+
begin
|
194
|
+
key = platform
|
195
|
+
method = (methods.has_key? key) ? methods[key] : methods[:unix]
|
196
|
+
hours = (method.call) / 3600 # seconds to hours
|
197
|
+
rescue => ex
|
198
|
+
end
|
199
|
+
hours
|
200
|
+
end
|
201
|
+
|
202
|
+
|
203
|
+
#
|
204
|
+
# Return the local IP address which receives external traffic
|
205
|
+
# from: http://coderrr.wordpress.com/2008/05/28/get-your-local-ip-address/
|
206
|
+
# NOTE: This <em>does not</em> open a connection to the IP address.
|
207
|
+
def local_ip_address
|
208
|
+
# turn off reverse DNS resolution temporarily
|
209
|
+
orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true
|
210
|
+
UDPSocket.open {|s| s.connect('75.101.137.7', 1); s.addr.last } # Solutious IP
|
211
|
+
ensure
|
212
|
+
Socket.do_not_reverse_lookup = orig
|
213
|
+
end
|
214
|
+
|
215
|
+
#
|
216
|
+
# Returns the local IP address based on the hostname.
|
217
|
+
# According to coderrr (see comments on blog link above), this implementation
|
218
|
+
# doesn't guarantee that it will return the address for the interface external
|
219
|
+
# traffic goes through. It's also possible the hostname isn't resolvable to the
|
220
|
+
# local IP.
|
221
|
+
def local_ip_address_alt
|
222
|
+
ipaddr = :unknown
|
223
|
+
begin
|
224
|
+
saddr = Socket.getaddrinfo( Socket.gethostname, nil, Socket::AF_UNSPEC, Socket::SOCK_STREAM, nil, Socket::AI_CANONNAME)
|
225
|
+
ipaddr = saddr.select{|type| type[0] == 'AF_INET' }[0][3]
|
226
|
+
rescue => ex
|
227
|
+
end
|
228
|
+
ipaddr
|
229
|
+
end
|
230
|
+
|
231
|
+
# returns a symbol in the form: os_implementation. This is used throughout Stella
|
232
|
+
# for platform specific support.
|
233
|
+
def platform
|
234
|
+
"#{@os}_#{@implementation}".to_sym
|
235
|
+
end
|
236
|
+
|
237
|
+
# Returns Ruby version as an array
|
238
|
+
def ruby
|
239
|
+
RUBY_VERSION.split('.').map { |v| v.to_i }
|
240
|
+
end
|
241
|
+
|
242
|
+
# Returns the environment PATH as an Array
|
243
|
+
def paths
|
244
|
+
if @os == :unix
|
245
|
+
(ENV['PATH'] || '').split(':')
|
246
|
+
elsif
|
247
|
+
(ENV['PATH'] || '').split(';') # Note tested!
|
248
|
+
else
|
249
|
+
raise "paths not implemented for: #{@os}"
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
def user
|
254
|
+
ENV['USER']
|
255
|
+
end
|
256
|
+
|
257
|
+
def home
|
258
|
+
if @os == :unix
|
259
|
+
File.expand_path(ENV['HOME'])
|
260
|
+
elsif @os == :win32
|
261
|
+
File.expand_path(ENV['USERPROFILE'])
|
262
|
+
else
|
263
|
+
raise "paths not implemented for: #{@os}"
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
# Print friendly system information.
|
268
|
+
def to_s
|
269
|
+
sprintf("Hostname: %s#{$/}IP Address: %s#{$/}System: %s#{$/}Uptime: %.2f (hours)#{$/}Ruby: #{ruby.join('.')}",
|
270
|
+
@hostname, @ipaddress, "#{@os}-#{@implementation}-#{@architecture}", @uptime)
|
271
|
+
end
|
272
|
+
|
273
|
+
|
274
|
+
end
|
data/lib/tryouts.rb
CHANGED
@@ -3,25 +3,20 @@ require 'ostruct'
|
|
3
3
|
|
4
4
|
module Tryouts
|
5
5
|
|
6
|
-
def before(&b)
|
7
|
-
b.call
|
8
|
-
end
|
9
|
-
def after(&b)
|
10
|
-
at_exit &b
|
11
|
-
end
|
12
|
-
|
13
|
-
|
14
6
|
# tryout :name do
|
15
7
|
# ...
|
16
8
|
# end
|
17
9
|
def tryout(name, &b)
|
10
|
+
puts '-'*50
|
18
11
|
puts "Running#{@poop}: #{name}"
|
19
12
|
begin
|
20
13
|
b.call
|
21
|
-
|
22
|
-
sleep 1
|
14
|
+
sleep 0.1
|
23
15
|
rescue Interrupt
|
24
|
-
|
16
|
+
rescue => ex
|
17
|
+
STDERR.puts "Tryout error: #{ex.message}"
|
18
|
+
end
|
19
|
+
puts $/*2
|
25
20
|
end
|
26
21
|
|
27
22
|
# Ignore everything
|
@@ -36,5 +31,3 @@ module Tryouts
|
|
36
31
|
end
|
37
32
|
|
38
33
|
end
|
39
|
-
|
40
|
-
include Tryouts
|
data/rudy.gemspec
CHANGED
@@ -1,12 +1,38 @@
|
|
1
1
|
@spec = Gem::Specification.new do |s|
|
2
2
|
s.name = "rudy"
|
3
|
-
|
4
|
-
s.
|
3
|
+
s.rubyforge_project = 'rudy'
|
4
|
+
s.version = "0.6.0"
|
5
|
+
s.summary = "Rudy: Not your grandparent's deployment tool."
|
5
6
|
s.description = s.summary
|
6
7
|
s.author = "Delano Mandelbaum"
|
7
8
|
s.email = "delano@solutious.com"
|
8
9
|
s.homepage = "http://github.com/solutious/rudy"
|
9
|
-
|
10
|
+
|
11
|
+
s.extra_rdoc_files = %w[README.rdoc Rudyfile LICENSE.txt CHANGES.txt ]
|
12
|
+
s.has_rdoc = true
|
13
|
+
s.rdoc_options = ["--line-numbers", "--title", s.summary, "--main", "README.rdoc"]
|
14
|
+
s.require_paths = %w[lib]
|
15
|
+
s.rubygems_version = '1.1.1'
|
16
|
+
|
17
|
+
s.add_dependency 'drydock', '>= 0.5.5'
|
18
|
+
s.add_dependency 'caesars', '>= 0.5.4'
|
19
|
+
s.add_dependency 'rye', '>= 0.5.1'
|
20
|
+
|
21
|
+
s.add_dependency 'echoe'
|
22
|
+
s.add_dependency 'amazon-ec2', '>= 0.3.8' # region fix
|
23
|
+
s.add_dependency 'net-ssh', '>=2.0.9'
|
24
|
+
s.add_dependency 'net-scp', '>=1.0.2'
|
25
|
+
s.add_dependency 'net-ssh-gateway'
|
26
|
+
s.add_dependency 'net-ssh-multi'
|
27
|
+
|
28
|
+
# http://bit.ly/2WaAgV
|
29
|
+
#s.add_runtime_dependency('xml-simple', '>= 1.0.11')
|
30
|
+
#s.add_dependency('xml-simple', '>= 1.0.11')
|
31
|
+
#s.add_development_dependency('jgre-monkeyspecdoc', '>= 0.1.0')
|
32
|
+
#s.add_development_dependency('thoughtbot-shoulda', '>= 0.1.0')
|
33
|
+
|
34
|
+
s.executables = %w[ird rudy rudy-ec2 rudy-sdb rudy-s3]
|
35
|
+
|
10
36
|
# = MANIFEST =
|
11
37
|
# git ls-files
|
12
38
|
s.files = %w(
|
@@ -14,61 +40,121 @@
|
|
14
40
|
LICENSE.txt
|
15
41
|
README.rdoc
|
16
42
|
Rakefile
|
43
|
+
Rudyfile
|
44
|
+
bin/ird
|
17
45
|
bin/rudy
|
18
46
|
bin/rudy-ec2
|
19
|
-
|
20
|
-
|
21
|
-
lib/
|
47
|
+
bin/rudy-s3
|
48
|
+
bin/rudy-sdb
|
49
|
+
lib/annoy.rb
|
22
50
|
lib/console.rb
|
51
|
+
lib/escape.rb
|
23
52
|
lib/rudy.rb
|
24
53
|
lib/rudy/aws.rb
|
25
54
|
lib/rudy/aws/ec2.rb
|
55
|
+
lib/rudy/aws/ec2/address.rb
|
56
|
+
lib/rudy/aws/ec2/group.rb
|
57
|
+
lib/rudy/aws/ec2/image.rb
|
58
|
+
lib/rudy/aws/ec2/instance.rb
|
59
|
+
lib/rudy/aws/ec2/keypair.rb
|
60
|
+
lib/rudy/aws/ec2/snapshot.rb
|
61
|
+
lib/rudy/aws/ec2/volume.rb
|
62
|
+
lib/rudy/aws/ec2/zone.rb
|
26
63
|
lib/rudy/aws/s3.rb
|
27
|
-
lib/rudy/aws/
|
28
|
-
lib/rudy/
|
29
|
-
lib/rudy/
|
30
|
-
lib/rudy/
|
31
|
-
lib/rudy/
|
32
|
-
lib/rudy/
|
33
|
-
lib/rudy/
|
34
|
-
lib/rudy/
|
35
|
-
lib/rudy/
|
36
|
-
lib/rudy/
|
37
|
-
lib/rudy/
|
38
|
-
lib/rudy/
|
39
|
-
lib/rudy/
|
40
|
-
lib/rudy/
|
41
|
-
lib/rudy/
|
64
|
+
lib/rudy/aws/sdb.rb
|
65
|
+
lib/rudy/aws/sdb/error.rb
|
66
|
+
lib/rudy/backup.rb
|
67
|
+
lib/rudy/cli.rb
|
68
|
+
lib/rudy/cli/aws/ec2/addresses.rb
|
69
|
+
lib/rudy/cli/aws/ec2/candy.rb
|
70
|
+
lib/rudy/cli/aws/ec2/groups.rb
|
71
|
+
lib/rudy/cli/aws/ec2/images.rb
|
72
|
+
lib/rudy/cli/aws/ec2/instances.rb
|
73
|
+
lib/rudy/cli/aws/ec2/keypairs.rb
|
74
|
+
lib/rudy/cli/aws/ec2/snapshots.rb
|
75
|
+
lib/rudy/cli/aws/ec2/volumes.rb
|
76
|
+
lib/rudy/cli/aws/ec2/zones.rb
|
77
|
+
lib/rudy/cli/aws/s3/buckets.rb
|
78
|
+
lib/rudy/cli/aws/s3/store.rb
|
79
|
+
lib/rudy/cli/aws/sdb/domains.rb
|
80
|
+
lib/rudy/cli/candy.rb
|
81
|
+
lib/rudy/cli/config.rb
|
82
|
+
lib/rudy/cli/disks.rb
|
83
|
+
lib/rudy/cli/machines.rb
|
84
|
+
lib/rudy/cli/routines.rb
|
42
85
|
lib/rudy/config.rb
|
86
|
+
lib/rudy/config/objects.rb
|
87
|
+
lib/rudy/disks.rb
|
88
|
+
lib/rudy/global.rb
|
89
|
+
lib/rudy/huxtable.rb
|
90
|
+
lib/rudy/machines.rb
|
43
91
|
lib/rudy/metadata.rb
|
44
|
-
lib/rudy/
|
45
|
-
lib/rudy/
|
92
|
+
lib/rudy/routines.rb
|
93
|
+
lib/rudy/routines/helpers/diskhelper.rb
|
94
|
+
lib/rudy/routines/helpers/scripthelper.rb
|
95
|
+
lib/rudy/routines/release.rb
|
96
|
+
lib/rudy/routines/shutdown.rb
|
97
|
+
lib/rudy/routines/startup.rb
|
46
98
|
lib/rudy/scm/svn.rb
|
47
99
|
lib/rudy/utils.rb
|
48
100
|
lib/storable.rb
|
101
|
+
lib/sysinfo.rb
|
49
102
|
lib/tryouts.rb
|
50
103
|
rudy.gemspec
|
51
104
|
support/mailtest
|
105
|
+
support/randomize-root-password
|
52
106
|
support/rudy-ec2-startup
|
53
|
-
|
107
|
+
support/update-ec2-ami-tools
|
108
|
+
test/05_config/00_setup_test.rb
|
109
|
+
test/05_config/30_machines_test.rb
|
110
|
+
test/20_sdb/00_setup_test.rb
|
111
|
+
test/20_sdb/10_domains_test.rb
|
112
|
+
test/25_ec2/00_setup_test.rb
|
113
|
+
test/25_ec2/10_keypairs_test.rb
|
114
|
+
test/25_ec2/20_groups_test.rb
|
115
|
+
test/25_ec2/30_addresses_test.rb
|
116
|
+
test/25_ec2/40_volumes_test.rb
|
117
|
+
test/25_ec2/50_snapshots_test.rb
|
118
|
+
test/26_ec2_instances/00_setup_test.rb
|
119
|
+
test/26_ec2_instances/10_instances_test.rb
|
120
|
+
test/26_ec2_instances/50_images_test.rb
|
121
|
+
test/30_sdb_metadata/00_setup_test.rb
|
122
|
+
test/30_sdb_metadata/10_disks_test.rb
|
123
|
+
test/30_sdb_metadata/20_backups_test.rb
|
124
|
+
test/coverage.txt
|
125
|
+
test/helper.rb
|
126
|
+
vendor/highline-1.5.1/CHANGELOG
|
127
|
+
vendor/highline-1.5.1/INSTALL
|
128
|
+
vendor/highline-1.5.1/LICENSE
|
129
|
+
vendor/highline-1.5.1/README
|
130
|
+
vendor/highline-1.5.1/Rakefile
|
131
|
+
vendor/highline-1.5.1/TODO
|
132
|
+
vendor/highline-1.5.1/examples/ansi_colors.rb
|
133
|
+
vendor/highline-1.5.1/examples/asking_for_arrays.rb
|
134
|
+
vendor/highline-1.5.1/examples/basic_usage.rb
|
135
|
+
vendor/highline-1.5.1/examples/color_scheme.rb
|
136
|
+
vendor/highline-1.5.1/examples/limit.rb
|
137
|
+
vendor/highline-1.5.1/examples/menus.rb
|
138
|
+
vendor/highline-1.5.1/examples/overwrite.rb
|
139
|
+
vendor/highline-1.5.1/examples/page_and_wrap.rb
|
140
|
+
vendor/highline-1.5.1/examples/password.rb
|
141
|
+
vendor/highline-1.5.1/examples/trapping_eof.rb
|
142
|
+
vendor/highline-1.5.1/examples/using_readline.rb
|
143
|
+
vendor/highline-1.5.1/lib/highline.rb
|
144
|
+
vendor/highline-1.5.1/lib/highline/color_scheme.rb
|
145
|
+
vendor/highline-1.5.1/lib/highline/compatibility.rb
|
146
|
+
vendor/highline-1.5.1/lib/highline/import.rb
|
147
|
+
vendor/highline-1.5.1/lib/highline/menu.rb
|
148
|
+
vendor/highline-1.5.1/lib/highline/question.rb
|
149
|
+
vendor/highline-1.5.1/lib/highline/system_extensions.rb
|
150
|
+
vendor/highline-1.5.1/setup.rb
|
151
|
+
vendor/highline-1.5.1/test/tc_color_scheme.rb
|
152
|
+
vendor/highline-1.5.1/test/tc_highline.rb
|
153
|
+
vendor/highline-1.5.1/test/tc_import.rb
|
154
|
+
vendor/highline-1.5.1/test/tc_menu.rb
|
155
|
+
vendor/highline-1.5.1/test/ts_all.rb
|
54
156
|
)
|
55
|
-
s.executables = %w[rudy]
|
56
|
-
|
57
|
-
s.extra_rdoc_files = %w[README.rdoc LICENSE.txt]
|
58
|
-
s.has_rdoc = true
|
59
|
-
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Rudy: #{s.summary}", "--main", "README.rdoc"]
|
60
|
-
s.require_paths = %w[lib]
|
61
|
-
s.rubygems_version = '1.1.1'
|
62
157
|
|
63
158
|
|
64
|
-
|
65
|
-
|
66
|
-
s.add_dependency 'net-ssh'
|
67
|
-
s.add_dependency 'net-scp'
|
68
|
-
s.add_dependency 'net-ssh-gateway'
|
69
|
-
s.add_dependency 'net-ssh-multi'
|
70
|
-
s.add_dependency 'highline'
|
71
|
-
|
72
|
-
|
73
|
-
s.rubyforge_project = 'rudy'
|
74
|
-
end
|
159
|
+
end
|
160
|
+
|