Sha256: d875ce287c62d7fc5ff56a01a6a5e306ad272c6a7f3028c28c43a7684b3f5eb4

Contents?: true

Size: 1.15 KB

Versions: 45

Compression:

Stored size: 1.15 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} -C -q -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null #{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

45 entries across 45 versions & 1 rubygems

Version Path
standup-0.6.9 lib/standup/node.rb
standup-0.6.8 lib/standup/node.rb
standup-0.6.7 lib/standup/node.rb
standup-0.6.6 lib/standup/node.rb
standup-0.6.5 lib/standup/node.rb
standup-0.6.4 lib/standup/node.rb
standup-0.6.3 lib/standup/node.rb
standup-0.6.2 lib/standup/node.rb
standup-0.6.1 lib/standup/node.rb
standup-0.6.0 lib/standup/node.rb
standup-0.5.14 lib/standup/node.rb
standup-0.5.13 lib/standup/node.rb
standup-0.5.11 lib/standup/node.rb
standup-0.5.10 lib/standup/node.rb
standup-0.5.9 lib/standup/node.rb
standup-0.5.8 lib/standup/node.rb
standup-0.5.7 lib/standup/node.rb
standup-0.5.6 lib/standup/node.rb
standup-0.5.5 lib/standup/node.rb
standup-0.5.4 lib/standup/node.rb