solutious-rudy 0.7.5 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.txt CHANGED
@@ -1,12 +1,15 @@
1
1
  RUDY, CHANGES
2
2
 
3
- * TODO: Remove string messages for non-string output formats
4
- * TODO: Support for reserved instances
5
- * TODO: Tests for zone and region support
6
- * TODO: Support for machine image attributes
7
- * TODO: Support for product codes
8
3
 
9
- #### 0.7.5 (2009-05-??) ###############################
4
+ #### 0.7.6 (2009-05-18) ###############################
5
+
6
+ * ADDED: Better windows instance support during routines
7
+ * ADDED: "os" keyword to routines DSL
8
+ * ADDED: Config defaults for "yes" global (thanks sabat)
9
+ * FIXED: Handle exception when assigning inappropriate IP Address.
10
+
11
+
12
+ #### 0.7.5 (2009-05-12) ###############################
10
13
 
11
14
  * CHANGE: rudy-ec2 console now displays windows password automatically if keypair is supplied.
12
15
  * ADDED: register and destroy commands to rudy-ec2 images
data/bin/rudy CHANGED
@@ -9,8 +9,7 @@
9
9
  #
10
10
 
11
11
  $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') # Put our local lib in first place
12
- $:.unshift File.join(File.dirname(__FILE__), '..', '..', 'drydock', 'lib')
13
- require 'rubygems'
12
+ #$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'drydock', 'lib')
14
13
 
15
14
  #$SAFE = 1 # require is unsafe in Ruby 1.9??
16
15
 
data/bin/rudy-ec2 CHANGED
@@ -10,12 +10,11 @@
10
10
  #
11
11
 
12
12
  $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') # Put our local lib in first place
13
- #require 'rubygems'
14
13
 
14
+ require 'drydock'
15
15
  require 'rudy'
16
16
  require 'rudy/cli'
17
17
 
18
- require 'drydock'
19
18
 
20
19
  # Command-line interface for bin/rudy-ec2
21
20
  module RudyCLI_EC2
data/bin/rudy-s3 CHANGED
@@ -10,11 +10,10 @@
10
10
  #
11
11
 
12
12
  $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') # Put our local lib in first place
13
- #require 'rubygems'
14
13
 
14
+ require 'drydock'
15
15
  require 'rudy'
16
16
  require 'rudy/cli'
17
- require 'drydock'
18
17
 
19
18
  # Command-line interface for bin/rudy-s3
20
19
  module RudyCLI_S3
data/bin/rudy-sdb CHANGED
@@ -10,11 +10,10 @@
10
10
  #
11
11
 
12
12
  $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') # Put our local lib in first place
13
- #require 'rubygems'
14
13
 
14
+ require 'drydock'
15
15
  require 'rudy'
16
16
  require 'rudy/cli'
17
- require 'drydock'
18
17
 
19
18
  # Command-line interface for bin/rudy-sdb
20
19
  module RudyCLI_SDB
@@ -54,8 +54,8 @@ module Rudy::AWS
54
54
 
55
55
  address = address.ipaddress if address.is_a?(Rudy::AWS::EC2::Address)
56
56
  instance = instance.awsid if instance.is_a?(Rudy::AWS::EC2::Instance)
57
- raise UnknownAddress unless exists?(address)
58
- raise AddressAssociated if associated?(address)
57
+ raise UnknownAddress, address unless exists?(address)
58
+ raise AddressAssociated, address if associated?(address)
59
59
 
60
60
  opts ={
61
61
  :instance_id => instance,
@@ -134,7 +134,7 @@ module Rudy::AWS
134
134
  # Returns true if the given address is assigned to the current account
135
135
  def exists?(address)
136
136
  address = address.ipaddress if address.is_a?(Rudy::AWS::EC2::Address)
137
- list.each do |a|
137
+ list do |a|
138
138
  return true if a.ipaddress == address
139
139
  end
140
140
  false
data/lib/rudy/config.rb CHANGED
@@ -102,7 +102,8 @@ module Rudy
102
102
  environment :stage
103
103
  role :app
104
104
  user Rudy.sysinfo.user.to_sym
105
- color false # set to true for terminal colors
105
+ color false # Terminal colors? true/false
106
+ yes false # Auto-confirm? true/false
106
107
  end
107
108
  }
108
109
  Rudy::Utils.write_to_file(Rudy::CONFIG_FILE, rudy_config, 'w', 0600)
data/lib/rudy/global.rb CHANGED
@@ -56,7 +56,7 @@ module Rudy
56
56
  if config.defaults?
57
57
  # Apply the "color" default before "nocolor" so nocolor has presedence
58
58
  @nocolor = !config.defaults.color unless config.defaults.color.nil?
59
- %w[region zone environment role position user nocolor quiet].each do |name|
59
+ %w[region zone environment role position user nocolor quiet yes].each do |name|
60
60
  val = config.defaults.send(name)
61
61
  self.send("#{name}=", val) unless val.nil?
62
62
  end
@@ -101,6 +101,7 @@ module Rudy
101
101
  @position &&= @position.to_s.rjust(2, '0')
102
102
  @format &&= @format.to_sym rescue nil
103
103
  @quiet ? Rudy.enable_quiet : Rudy.disable_quiet
104
+ @yes ? Rudy.enable_yes : Rudy.disable_yes
104
105
  end
105
106
 
106
107
  def apply_environment_variables
data/lib/rudy/huxtable.rb CHANGED
@@ -188,6 +188,10 @@ module Rudy
188
188
  fetch_machine_param(:ami)
189
189
  end
190
190
 
191
+ def current_machine_os
192
+ fetch_machine_param(:os) || 'linux'
193
+ end
194
+
191
195
  def current_machine_size
192
196
  fetch_machine_param(:size) || 'm1.small'
193
197
  end
data/lib/rudy/machines.rb CHANGED
@@ -21,6 +21,8 @@ module Rudy
21
21
  field :dns_private
22
22
  field :state
23
23
 
24
+ field :os
25
+
24
26
  attr_reader :instance
25
27
 
26
28
  def init
@@ -32,6 +34,7 @@ module Rudy
32
34
  @role = @@global.role
33
35
  @position = find_next_position || '01'
34
36
  @state = 'no-instance'
37
+ @os = 'unknown'
35
38
  end
36
39
 
37
40
  def liner_note
@@ -117,20 +120,29 @@ module Rudy
117
120
  :machine_data => Machine.generate_machine_data.to_yaml
118
121
  }.merge(opts)
119
122
 
123
+ @os = current_machine_os
124
+
120
125
  @ec2inst.create(opts) do |inst|
121
126
  @awsid = inst.awsid
122
127
  @created = @starts = Time.now
123
128
  @state = inst.state
124
- # Assign IP address only if we have one for that position
125
- if current_machine_address(@position)
129
+ # We need to be safe when creating machines because if an exception is
130
+ # raised, instances will have been creating but the calling class won't know.
131
+ begin
126
132
  address = current_machine_address(@position)
127
- puts "Associating #{address} to #{inst.awsid}"
128
- begin
129
- @radd.associate(address, inst.awsid)
130
- rescue => ex
131
- STDERR.puts "Error while associating address (#{ex.class.to_s})"
132
- Rudy::Utils.bug()
133
+ # Assign IP address only if we have one for that position
134
+ if address
135
+ # Make sure the address is associated to the current account
136
+ if @radd.exists?(address)
137
+ puts "Associating #{address} to #{inst.awsid}"
138
+ @radd.associate(address, inst.awsid)
139
+ else
140
+ STDERR.puts "Unknown address: #{address}"
141
+ end
133
142
  end
143
+ rescue => ex
144
+ STDERR.puts "Error: #{ex.message}"
145
+ STDERR.puts ex.backtrace if Rudy.debug?
134
146
  end
135
147
  end
136
148
 
data/lib/rudy/metadata.rb CHANGED
@@ -6,6 +6,7 @@ module Rudy
6
6
  def initialize(*args)
7
7
  a, s, r = @@global.accesskey, @@global.secretkey, @@global.region
8
8
  @sdb = Rudy::AWS::SDB.new(a, s, r)
9
+ @radd = Rudy::AWS::EC2::Addresses.new(a, s, r)
9
10
  @rinst = Rudy::AWS::EC2::Instances.new(a, s, r)
10
11
  @rgrp = Rudy::AWS::EC2::Groups.new(a, s, r)
11
12
  @rkey = Rudy::AWS::EC2::KeyPairs.new(a, s, r)
@@ -23,13 +23,11 @@ module Rudy; module Routines;
23
23
  end
24
24
  end
25
25
 
26
- machines = []
27
- generic_machine_runner(:list) do |machine,rbox|
26
+ machines = generic_machine_runner(:list) do |machine,rbox|
28
27
  vlist.each do |scm|
29
28
  puts task_separator("CREATING REMOTE #{scm.engine.to_s.upcase} CHECKOUT")
30
29
  scm.create_remote_checkout(rbox)
31
30
  end
32
- machines << machine
33
31
  end
34
32
 
35
33
  machines
@@ -13,10 +13,9 @@ module Rudy; module Routines;
13
13
  STDERR.puts "[this is a generic shutdown routine]"
14
14
  @routine = {}
15
15
  end
16
- machines = []
17
- generic_machine_runner(:destroy) do |machine,rbox|
18
- puts $/, "Shutting down...", $/
19
- machines << machine
16
+
17
+ machines = generic_machine_runner(:list) do |machine|
18
+ machine.destroy
20
19
  end
21
20
  machines
22
21
  end
@@ -24,8 +23,10 @@ module Rudy; module Routines;
24
23
  # Called by generic_machine_runner
25
24
  def raise_early_exceptions
26
25
  rmach = Rudy::Machines.new
27
- raise Rudy::PrivateKeyNotFound, root_keypairpath unless has_keypair?(:root)
28
26
  raise MachineGroupNotRunning, current_machine_group unless rmach.running?
27
+ # Check private key after machine group, otherwise we could get an error
28
+ # about there being no key which doesn't make sense if the group isn't running.
29
+ raise Rudy::PrivateKeyNotFound, root_keypairpath unless has_keypair?(:root)
29
30
  end
30
31
 
31
32
  end
data/lib/rudy/routines.rb CHANGED
@@ -94,11 +94,11 @@ module Rudy
94
94
  end
95
95
  }
96
96
 
97
- # Execute the action (create, list, destroy, restart) & apply the block to each
98
- machines = []
99
- rmach.send(machine_action) do |machine|
100
- machines << machine
101
-
97
+
98
+ # Execute the action (create, list, destroy, restart)
99
+ machines = enjoy_every_sandwich([]) { rmach.send(machine_action) }
100
+
101
+ machines.each do |machine|
102
102
  puts machine_separator(machine.name, machine.awsid) unless skip_header
103
103
 
104
104
  unless skip_check
@@ -107,15 +107,19 @@ module Rudy
107
107
  inst = machine.get_instance
108
108
  inst && inst.running?
109
109
  }
110
+ end
110
111
 
111
- # Add instance info to machine and save it. This is really important
112
- # for the initial startup so the metadata is updated right away. But
113
- # it's also important to call here because if a routine was executed
114
- # and an unexpected exception occurs before this update is executed
115
- # the machine metadata won't contain the DNS information. Calling it
116
- # here ensure that the metadata is always up-to-date.
117
- machine.update
112
+ # Add instance info to machine and save it. This is really important
113
+ # for the initial startup so the metadata is updated right away. But
114
+ # it's also important to call here because if a routine was executed
115
+ # and an unexpected exception occurs before this update is executed
116
+ # the machine metadata won't contain the DNS information. Calling it
117
+ # here ensure that the metadata is always up-to-date.
118
+ machine.update
118
119
 
120
+ next if (machine.os || '').to_s == 'win32'
121
+
122
+ unless skip_check
119
123
  msg = preliminary_separator("Waiting for SSH daemon...")
120
124
  Rudy::Utils.waiter(2, 60, STDOUT, msg, 0) {
121
125
  Rudy::Utils.service_available?(machine.dns_public, 22)
@@ -150,11 +154,13 @@ module Rudy
150
154
  }
151
155
  end
152
156
 
153
- unless has_remote_task?(routine)
154
- puts "[no remote tasks]"
155
- next
156
- end
157
-
157
+ ## NOTE: This prevents shutdown from doing its thing and prob
158
+ ## isn't necessary.
159
+ ##unless has_remote_task?(routine)
160
+ ## puts "[no remote tasks]"
161
+ ## next
162
+ ##end
163
+
158
164
  enjoy_every_sandwich {
159
165
  if Rudy::Routines::UserHelper.adduser?(routine) # adduser
160
166
  puts task_separator("ADD USER")
@@ -231,6 +237,7 @@ module Rudy
231
237
  execute_dependency(after_dependencies, skip_check, skip_header)
232
238
  }
233
239
 
240
+ machines
234
241
  end
235
242
 
236
243
  def execute_dependency(depends, skip_check, skip_header)
@@ -295,14 +302,15 @@ module Rudy
295
302
  #puts '%-40s' % [name.bright]
296
303
  end
297
304
 
298
- def enjoy_every_sandwich(&bloc_party)
305
+ def enjoy_every_sandwich(ret=nil, &bloc_party)
299
306
  begin
300
- bloc_party.call
307
+ ret = bloc_party.call
301
308
  rescue => ex
302
309
  STDERR.puts " Error: #{ex.message}".color(:red)
303
310
  STDERR.puts ex.backtrace if Rudy.debug?
304
311
  exit 12 unless keep_going?
305
312
  end
313
+ ret
306
314
  end
307
315
 
308
316
  def keep_going?
data/lib/rudy.rb CHANGED
@@ -38,7 +38,7 @@ module Rudy
38
38
  unless defined?(MAJOR)
39
39
  MAJOR = 0.freeze
40
40
  MINOR = 7.freeze
41
- TINY = 4.freeze
41
+ TINY = 6.freeze
42
42
  end
43
43
  def self.to_s; [MAJOR, MINOR, TINY].join('.'); end
44
44
  def self.to_f; self.to_s.to_f; end
@@ -88,6 +88,7 @@ module Rudy
88
88
  }.freeze
89
89
 
90
90
  @@quiet = false
91
+ @@yes = false
91
92
  @@debug = false
92
93
  @@sysinfo = SysInfo.new.freeze
93
94
 
@@ -95,10 +96,13 @@ module Rudy
95
96
 
96
97
  def Rudy.debug?; @@debug == true; end
97
98
  def Rudy.quiet?; @@quiet == true; end
99
+ def Rudy.yes?; @@yes == true; end
98
100
  def Rudy.enable_debug; @@debug = true; end
99
101
  def Rudy.enable_quiet; @@quiet = true; end
102
+ def Rudy.enable_yes; @@yes = true; end
100
103
  def Rudy.disable_debug; @@debug = false; end
101
104
  def Rudy.disable_quiet; @@quiet = false; end
105
+ def Rudy.disable_yes; @@yes = false; end
102
106
 
103
107
  def Rudy.sysinfo; @@sysinfo; end
104
108
  def sysinfo; @@sysinfo; end
data/rudy.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  @spec = Gem::Specification.new do |s|
2
2
  s.name = "rudy"
3
3
  s.rubyforge_project = 'rudy'
4
- s.version = "0.7.5"
4
+ s.version = "0.7.6"
5
5
  s.summary = "Rudy: Not your grandparents' EC2 deployment tool."
6
6
  s.description = s.summary
7
7
  s.author = "Delano Mandelbaum"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solutious-rudy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delano Mandelbaum
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-08 00:00:00 -07:00
12
+ date: 2009-05-16 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency