Sha256: 11e938c5c5a54c3732d53ff64673325b6d2e849e8a7d833629c7008727ad7f3e

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

require File.dirname(__FILE__) + "/remoter"

module PoolParty  
  module Remote
    
    class RemoteInstance
      include Remote
      include Configurable
      include CloudResourcer
            
      def initialize(opts, parent=self)
        set_parent(parent) if parent
        set_vars_from_options(opts) unless opts.empty?        
        on_init
      end
      
      # Callback
      def on_init        
      end
      
      # Is this remote instance the master?
      def master?
        name == "master"
      end
      
      # The remote instances is only valid if there is an ip and a name
      def valid?
        !(ip.nil? || name.nil?)
      end
      
      # Determine if the RemoteInstance is responding
      def responding?
        !responding.nil?
      end
      
      # This is how we get the current load of the instance
      # The approach of this may change entirely, but the usage of
      # it will always be the same
      def load
        current_load ||= 0.0
      end
            
      # Is this instance running?
      def running?
        !(status =~ /running/).nil?
      end
      # Is this instance pending?
      def pending?
        !(status =~ /pending/).nil?
      end
      # Is this instance terminating?
      def terminating?
        !(status =~ /shutting/).nil?
      end
      # Has this instance been terminated?
      def terminated?
        !(status =~ /terminated/).nil?
      end
      
      # Printing. This is how we extract the instances into the listing on the 
      # local side into the local listing file
      def to_s
        "#{name} #{ip}"
      end
    end
    
  end  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
auser-poolparty-0.2.2 lib/poolparty/net/remote_instance.rb