Sha256: bd0bf960aba724c4462738de76f54e16b0dfa06674d412fe079dad3ef39b3616

Contents?: true

Size: 1.11 KB

Versions: 10

Compression:

Stored size: 1.11 KB

Contents

require 'active_support/hash_with_indifferent_access'

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 #{scripts.ec2.params.ssh_user}@#{instance.external_ip}"
    end
    
    def params
      Settings.nodes[@name] || ActiveSupport::HashWithIndifferentAccess.new
    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

10 entries across 10 versions & 1 rubygems

Version Path
standup-0.3.15 lib/standup/node.rb
standup-0.3.14 lib/standup/node.rb
standup-0.3.13 lib/standup/node.rb
standup-0.3.12 lib/standup/node.rb
standup-0.3.11 lib/standup/node.rb
standup-0.3.10 lib/standup/node.rb
standup-0.3.9 lib/standup/node.rb
standup-0.3.8 lib/standup/node.rb
standup-0.3.7 lib/standup/node.rb
standup-0.3.6 lib/standup/node.rb