Sha256: 996a0218a7c91388cc37b27b84f1e449b7fca65d2975a57ea13597a929d53a90

Contents?: true

Size: 1.98 KB

Versions: 10

Compression:

Stored size: 1.98 KB

Contents


module Rudy; module Routines;

  class Startup < Rudy::Routines::Base

    def execute
      # There's no keypair check here because Rudy::Machines will attempt 
      # to create one. 
      rmach = Rudy::Machines.new
      routine = fetch_routine_config(:startup)
      rbox_local = Rye::Box.new('localhost')
      sconf = fetch_script_config
      
      # Runs "before_local" scripts of routines config. 
      # NOTE: Does not run "before" scripts b/c there are no remote machines
      puts task_separator("BEFORE SCRIPTS (local)")
      Rudy::Routines::ScriptHelper.before_local(routine, sconf, rbox_local)
      
      rmach.create do |machine|
      #rmach.list do |machine|
        puts machine_separator(machine.liner_note)
        print "Waiting for instance..."
        isup = Rudy::Utils.waiter(3, 120, STDOUT, "it's up!", 2) {
          inst = machine.get_instance
          inst && inst.running?
        } 
        machine.update # Add instance info to machine and save it
        print "Waiting for SSH daemon..."
        isup = Rudy::Utils.waiter(2, 60, STDOUT, "it's up!", 3) {
          Rudy::Utils.service_available?(machine.dns_public, 22)
        }
        
        opts = { :keys =>  root_keypairpath, :user => 'root', :debug => nil }
        rbox = Rye::Box.new(machine.dns_public, opts)
        
        puts task_separator("DISK ROUTINES")
        # Runs "disk" portion of routines config
        Rudy::Routines::DiskHelper.execute(routine, machine, rbox)
        
        puts task_separator("AFTER SCRIPTS")
        # Runs "after" scripts of routines config
        Rudy::Routines::ScriptHelper.after(routine, sconf, machine, rbox)
        
        puts task_separator("INFO")
        puts "Filesystem on #{machine.name}:"
        puts "  " << rbox.df(:h).join("#{$/}  ")
      end
      
      puts task_separator("AFTER SCRIPTS (local)")
      # Runs "after_local" scripts of routines config
      Rudy::Routines::ScriptHelper.after_local(routine, sconf, rbox_local)
      
    end

  end

end; end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
solutious-rudy-0.6.0 lib/rudy/routines/startup.rb
solutious-rudy-0.6.1 lib/rudy/routines/startup.rb
solutious-rudy-0.6.2 lib/rudy/routines/startup.rb
solutious-rudy-0.6.3 lib/rudy/routines/startup.rb
solutious-rudy-0.6.4 lib/rudy/routines/startup.rb
rudy-0.6.2 lib/rudy/routines/startup.rb
rudy-0.6.0 lib/rudy/routines/startup.rb
rudy-0.6.1 lib/rudy/routines/startup.rb
rudy-0.6.4 lib/rudy/routines/startup.rb
rudy-0.6.3 lib/rudy/routines/startup.rb