From c2405b90707d52e01043bda8874b539b208e44dd Mon Sep 17 00:00:00 2001 From: Solutious Inc Date: Thu, 12 Mar 2009 11:55:52 -0400 Subject: [PATCH] Reverted DSL to use 'svn' instead of 'checkout' as the scm method --- bin/rudy | 50 ++++++++++++++---------------------- lib/rudy.rb | 8 ++++++ lib/rudy/command/config.rb | 2 ++ lib/rudy/command/machines.rb | 3 ++- lib/rudy/command/release.rb | 31 ++++++++++++++-------- lib/rudy/config.rb | 4 ++- 6 files changed, 55 insertions(+), 43 deletions(-) diff --git a/bin/rudy b/bin/rudy index 8e39a615..b08b5272 100755 --- a/bin/rudy +++ b/bin/rudy @@ -9,29 +9,12 @@ RUDY_HOME = File.join(File.dirname(__FILE__), '..') RUDY_LIB = File.join(RUDY_HOME, 'lib') $:.unshift RUDY_LIB # Put our local lib in first place -# -# No Ruby 1.9.1 support. Only 1.8.x for now :[ -unless RUBY_VERSION < "1.9" - puts "Sorry! We're using the right_aws gem and it doesn't support Ruby 1.9 (md5 error)." - exit 1 -else - require 'rubygems' -end - +require 'rubygems' if RUBY_VERSION < "1.9" require 'date' require 'drydock' extend Drydock project "Rudy" # This also runs require 'ruby' -debug :off -capture :stderr -before do - @start = Time.now -end -after do - @elapsed = Time.now - @start - puts $/, "Elapsed: %.2f seconds" % @elapsed.to_f -end global :A, :accesskey, String, "AWS Access Key" global :S, :secretkey, String, "AWS Secret Access Key" @@ -123,9 +106,14 @@ command :metadata => Rudy::Command::Metadata command_alias :metadata, :md +desc "Machine Group Status" +command :status => Rudy::Command::Machines + + #desc "Update a Machine Group with the current version of Rudy" #command :update => Rudy::Command::Machines + usage "rudy [-e env] [-u user] connect [-p] [cmd]" desc "Open an SSH connection" option :p, :print, "Only print the SSH command, don't connect" @@ -143,8 +131,6 @@ command_alias :copy, :scp command_alias :copy, :upload command_alias :copy, :download -desc "Machine Group Status" -command :status => Rudy::Command::Machines # -------------------------------- RUDY ROUTINES COMMANDS -------- # ------------------------------------------------------------------ @@ -164,8 +150,8 @@ option :s, :switch, "Switch to the release branch/tag" option :m, :msg, String, "A short release note" command :release => Rudy::Command::Release -#desc "Update the release currently running machine group" -#command :rerelease => Rudy::Command::Release +desc "Update the release currently running machine group" +command :rerelease => Rudy::Command::Release #desc "Deploy disk snapshots from one machine to another" #command :deploy => Rudy::Command::Deploy @@ -173,13 +159,15 @@ command :release => Rudy::Command::Release - - - -__END__ -RUDY v0.5 UTC: 2009-02-27 15:39:57 - - [z:us-east-1b e:stage r:app p:01] - - +# ------------------------------------------- UGLY STUFFS -------- +# ------------------------------------------------------------------ +debug :on +capture :stderr +before do + @start = Time.now +end +after do + @elapsed = Time.now - @start + puts $/, "Elapsed: %.2f seconds" % @elapsed.to_f if @elapsed > 0.1 +end diff --git a/lib/rudy.rb b/lib/rudy.rb index 76e0b006..aef4be43 100644 --- a/lib/rudy.rb +++ b/lib/rudy.rb @@ -1,4 +1,12 @@ +# +# No Ruby 1.9.1 support. Only 1.8.x for now :[ +unless RUBY_VERSION < "1.9" + puts "Sorry! We're using the right_aws gem and it doesn't support Ruby 1.9 (md5 error)." + exit 1 +end + + begin require 'digest/md5' require 'right_aws' diff --git a/lib/rudy/command/config.rb b/lib/rudy/command/config.rb index 91e25fec..850cb3bb 100644 --- a/lib/rudy/command/config.rb +++ b/lib/rudy/command/config.rb @@ -51,6 +51,8 @@ def config if @option.all y @config.machines.to_hash y @config.routines.to_hash + elsif @option.defaults + y @config.defaults.to_hash else env, rol, usr, att = @global.environment, @global.role, @global.user, @argv.name val = @config.machines.find_deferred(env, rol, usr, att) || '' diff --git a/lib/rudy/command/machines.rb b/lib/rudy/command/machines.rb index 31df03a1..48fff9bd 100644 --- a/lib/rudy/command/machines.rb +++ b/lib/rudy/command/machines.rb @@ -128,15 +128,16 @@ def status # # raise "Cannot find startup script" unless File.exists?(@script) # - # exit unless are_you_sure? # # true #end # # #def update + # puts "Updating Rudy " # switch_user("root") # + # exit unless are_you_sure? # scp do |scp| # puts "Updating Rudy startup script (#{@script})" # scp.upload!(@script, "/etc/init.d/") do |ch, name, sent, total| diff --git a/lib/rudy/command/release.rb b/lib/rudy/command/release.rb index 8fd2fee3..8fbe2c3b 100644 --- a/lib/rudy/command/release.rb +++ b/lib/rudy/command/release.rb @@ -27,12 +27,17 @@ def release_valid? raise "No SCM defined for release routine" unless @scm raise "#{Dir.pwd} is not a working copy" unless @scm.working_copy?(Dir.pwd) - raise "There are local changes. Please revert or check them in." unless @scm.everything_checked_in? + #raise "There are local changes. Please revert or check them in." unless @scm.everything_checked_in? raise "Invalid base URI (#{@scm_params[:base]})." unless @scm.valid_uri?(@scm_params[:base]) true end + def release2 + p @scm + p @scm_params + end + #
  • Creates a release tag based on the working copy on your machine
  • #
  • Starts a new stage instance
  • #
  • Executes release routines
  • @@ -74,12 +79,12 @@ def release if @scm - puts "Creating checkout".att(:bright) + puts "Running SCM command".att(:bright) ssh do |session| - cmd = "svn co #{tag} #{@scm_params[:path]}" - puts "Running #{cmd}" + cmd = "svn #{@scm_params[:command]} #{tag} #{@scm_params[:path]}" + puts "#{cmd}" session.exec!(cmd) - puts "Checkout complete" + puts "#{@scm_params[:command]} complete" end end @@ -97,12 +102,18 @@ def find_scm # Look for the source control engine, checking all known scm values. # The available one will look like [environment][role][release][svn] - params = @config.routines.find_deferred(env, rol, :release, :checkout) - - raise "Unsupported SCM #{params[:scm]}" unless SUPPORTED_SCM_NAMES.member?(params[:scm].to_sym) + params = nil + scm_name = nil + SUPPORTED_SCM_NAMES.each do |v| + scm_name = v + params = @config.routines.find(env, rol, :release, scm_name) + break if params + end - klass = eval "Rudy::SCM::#{params[:scm].to_s.upcase}" - scm = klass.new(:base => params[:base]) + if params + klass = eval "Rudy::SCM::#{scm_name.to_s.upcase}" + scm = klass.new(:base => params[:base]) + end [scm, params] diff --git a/lib/rudy/config.rb b/lib/rudy/config.rb index 97b7b486..d747a1f1 100644 --- a/lib/rudy/config.rb +++ b/lib/rudy/config.rb @@ -29,6 +29,7 @@ def mount(*args, &b) hash_handler(:mount, *args, &b) end + # # Force the specified keyword to always be treated as a hash. # Example: # @@ -40,8 +41,9 @@ def mount(*args, &b) # end # end # end + # def hash_handler(caesars_meth, *args, &b) - + # TODO: Move to caesars return @caesars_properties[caesars_meth] if @caesars_properties.has_key?(caesars_meth) && args.empty? && b.nil? return nil if args.empty? && b.nil? return method_missing(caesars_meth, *args, &b) if args.empty?