Sha256: cc563701c0f565c7db181835106ab6ccfff71c745f41468421345d1fc142e91f

Contents?: true

Size: 999 Bytes

Versions: 5

Compression:

Stored size: 999 Bytes

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].titled_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

5 entries across 5 versions & 1 rubygems

Version Path
standup-0.3.3 lib/standup/node.rb
standup-0.3.2 lib/standup/node.rb
standup-0.3.1 lib/standup/node.rb
standup-0.3.0 lib/standup/node.rb
standup-0.2.0 lib/standup/node.rb