Sha256: 0fec3a54b416a77fc22bd53c8fa2930c97dec4099a566010a4620d97c53887db

Contents?: true

Size: 1.69 KB

Versions: 6

Compression:

Stored size: 1.69 KB

Contents

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

module PoolParty  
  module Remote
    
    class RemoteInstance
      include Remote
      include Configurable
      include CloudResourcer
            
      def initialize(opts, parent=self)
        @parent = parent
        set_vars_from_options(parent.options) if parent && parent.respond_to?(:options)
        set_vars_from_options(opts) unless opts.nil? || 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

6 entries across 6 versions & 2 rubygems

Version Path
auser-poolparty-0.2.3 lib/poolparty/net/remote_instance.rb
auser-poolparty-0.2.4 lib/poolparty/net/remote_instance.rb
auser-poolparty-0.2.5 lib/poolparty/net/remote_instance.rb
auser-poolparty-0.2.6 lib/poolparty/net/remote_instance.rb
auser-poolparty-0.2.8 lib/poolparty/net/remote_instance.rb
poolparty-0.2.6 lib/poolparty/net/remote_instance.rb