Sha256: ffa50725394d5016b9d877bb9aa51971702e83825a21f409dd433dc22e5b601c

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

module Standup
  class Node
    def initialize name
      @name = name
      
      @scripts = ActiveSupport::HashWithIndifferentAccess.new
      Standup.scripts.each do |sname, script|
        @scripts[sname] = script.new self
      end
      @remoting = nil
    end
    
    attr_reader :name, :scripts
    
    def run_script script_name
      scripts[script_name].put_title
      scripts[script_name].run
      close_remoting
    end
    
    def instance
      @instance ||= EC2::Instance.group_running[id_group].try(:first)
    end
    
    def ssh_string
      return '' unless instance
      "ssh -i #{Settings.aws.keypair_file} -q -o StrictHostKeyChecking=no #{params.ec2.ssh_user}@#{instance.external_ip}"
    end
    
    def params
      Settings.nodes[@name]
    end
    
    def remoting
      @remoting ||= Remoting.new self
    end
    
    def id_group
      "standup_node_#{@name}"
    end
    
    protected
    
    def close_remoting
      @remoting.close if @remoting
      @remoting = nil
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
standup-0.3.5 lib/standup/node.rb
standup-0.3.4 lib/standup/node.rb