Class: PoolParty::Remote::RemoteInstance

Inherits:
Object
  • Object
show all
Includes:
CloudResourcer, Configurable, PoolParty::Remote
Defined in:
lib/poolparty/net/remote_instance.rb

Instance Method Summary collapse

Methods included from CloudResourcer

#full_keypair_path, #instances, #keypair_path, #keypair_paths, #new_keypair_path, #number_of_resources, #parent, #possible_keypair_basenames, #set_parent

Methods included from Configurable

included

Methods included from PoolParty::Remote

#available_bases, #using, #using_remoter?

Methods included from Remoter

#can_shutdown_an_instance?, #can_start_a_new_instance?, #contract_cloud_if_necessary, #expand_cloud_if_necessary, #get_remote_nodes, #get_working_listing_file, included, #launch_minimum_number_of_instances, #list_from_local, #list_from_remote, #list_of_node_ips, #list_of_node_names, #local_instances_list_file_locations, #maximum_number_of_instances_are_not_running?, #minimum_number_of_instances_are_running?, #request_launch_new_instances, #request_launch_one_instance_at_a_time, #request_termination_of_non_master_instance, #rsync_command, #rsync_storage_files_to, #rsync_storage_files_to_command, #run_command_on, #run_command_on_command, #should_contract_cloud?, #should_expand_cloud?, #ssh_array, #ssh_command, #ssh_into, #ssh_into_instance_number, #ssh_string, #when_no_pending_instances

Constructor Details

#initialize(opts, parent = self) ⇒ RemoteInstance

Returns a new instance of RemoteInstance.



11
12
13
14
15
# File 'lib/poolparty/net/remote_instance.rb', line 11

def initialize(opts, parent=self)
  set_parent(parent) if parent
  set_vars_from_options(opts) unless opts.empty?        
  on_init
end

Instance Method Details

#load ⇒ Object

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



39
40
41
# File 'lib/poolparty/net/remote_instance.rb', line 39

def load
  current_load ||= 0.0
end

#master? ⇒ Boolean

Is this remote instance the master?

Returns:

  • (Boolean)


22
23
24
# File 'lib/poolparty/net/remote_instance.rb', line 22

def master?
  name == "master"
end

#on_init ⇒ Object

Callback



18
19
# File 'lib/poolparty/net/remote_instance.rb', line 18

def on_init        
end

#pending? ⇒ Boolean

Is this instance pending?

Returns:

  • (Boolean)


48
49
50
# File 'lib/poolparty/net/remote_instance.rb', line 48

def pending?
  !(status =~ /pending/).nil?
end

#responding? ⇒ Boolean

Determine if the RemoteInstance is responding

Returns:

  • (Boolean)


32
33
34
# File 'lib/poolparty/net/remote_instance.rb', line 32

def responding?
  !responding.nil?
end

#running? ⇒ Boolean

Is this instance running?

Returns:

  • (Boolean)


44
45
46
# File 'lib/poolparty/net/remote_instance.rb', line 44

def running?
  !(status =~ /running/).nil?
end

#terminated? ⇒ Boolean

Has this instance been terminated?

Returns:

  • (Boolean)


56
57
58
# File 'lib/poolparty/net/remote_instance.rb', line 56

def terminated?
  !(status =~ /terminated/).nil?
end

#terminating? ⇒ Boolean

Is this instance terminating?

Returns:

  • (Boolean)


52
53
54
# File 'lib/poolparty/net/remote_instance.rb', line 52

def terminating?
  !(status =~ /shutting/).nil?
end

#to_s ⇒ Object

Printing. This is how we extract the instances into the listing on the local side into the local listing file



62
63
64
# File 'lib/poolparty/net/remote_instance.rb', line 62

def to_s
  "#{name} #{ip}"
end

#valid? ⇒ Boolean

The remote instances is only valid if there is an ip and a name

Returns:

  • (Boolean)


27
28
29
# File 'lib/poolparty/net/remote_instance.rb', line 27

def valid?
  !(ip.nil? || name.nil?)
end