Skip to content

Commit

Permalink
Reverted DSL to use 'svn' instead of 'checkout' as the scm method
Browse files Browse the repository at this point in the history
  • Loading branch information
Solutious Inc committed Mar 12, 2009
1 parent d850c10 commit c2405b9
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 43 deletions.
50 changes: 19 additions & 31 deletions bin/rudy
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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 --------
# ------------------------------------------------------------------
Expand All @@ -164,22 +150,24 @@ 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







__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

8 changes: 8 additions & 0 deletions 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'
Expand Down
2 changes: 2 additions & 0 deletions lib/rudy/command/config.rb
Expand Up @@ -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) || ''
Expand Down
3 changes: 2 additions & 1 deletion lib/rudy/command/machines.rb
Expand Up @@ -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|
Expand Down
31 changes: 21 additions & 10 deletions lib/rudy/command/release.rb
Expand Up @@ -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

# <li>Creates a release tag based on the working copy on your machine</li>
# <li>Starts a new stage instance</li>
# <li>Executes release routines</li>
Expand Down Expand Up @@ -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
Expand All @@ -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]

Expand Down
4 changes: 3 additions & 1 deletion lib/rudy/config.rb
Expand Up @@ -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:
#
Expand All @@ -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?
Expand Down

0 comments on commit c2405b9

Please sign in to comment.