Class: PoolParty::Remote::RemoteInstance

Inherits:
Object
  • Object
show all
Includes:
Dslify
Defined in:
lib/poolparty/net/remote_instance.rb

Direct Known Subclasses

Ec2RemoteInstance

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}, containing_cloud = nil) ⇒ RemoteInstance

Returns a new instance of RemoteInstance.



7
8
9
10
11
12
13
# File 'lib/poolparty/net/remote_instance.rb', line 7

def initialize(opts={}, containing_cloud=nil)
  @parent = containing_cloud

  set_vars_from_options(containing_cloud.options) if containing_cloud && containing_cloud.respond_to?(:options)
  set_vars_from_options(opts) if opts.is_a?(Hash)
  on_init
end

Class Method Details

.hash_from_s(s) ⇒ Object

Class method to disect a neighborhood line



72
73
74
75
# File 'lib/poolparty/net/remote_instance.rb', line 72

def self.hash_from_s(s)
  arr = s.split("\t")
  {:name => arr[0], :ip => arr[1]}
end

.puppet_master_rerun_commandObject



94
95
96
# File 'lib/poolparty/net/remote_instance.rb', line 94

def self.puppet_master_rerun_command
  ". /etc/profile && puppetrerun"
end

.puppet_rerun_commadObject



97
98
99
# File 'lib/poolparty/net/remote_instance.rb', line 97

def self.puppet_rerun_commad
  puppet_runner_command
end

.puppet_runner_commandObject

Commands for the servers



91
92
93
# File 'lib/poolparty/net/remote_instance.rb', line 91

def self.puppet_runner_command
  ". /etc/profile && puppetrunner"
end

.to_s(hsh) ⇒ Object



77
78
79
# File 'lib/poolparty/net/remote_instance.rb', line 77

def self.to_s(hsh)
  new(hsh).to_s
end

Instance Method Details

#dependency_resolver_commandObject

TODO: Diet the next 5 commands



82
83
84
# File 'lib/poolparty/net/remote_instance.rb', line 82

def dependency_resolver_command
  cloud.dependency_resolver_command
end

#elapsed_runtimeObject



15
16
17
# File 'lib/poolparty/net/remote_instance.rb', line 15

def elapsed_runtime
  Time.now.to_i - launching_time.to_time.to_i
end

#hosts_file_listing_for(cl) ⇒ Object



102
103
104
105
# File 'lib/poolparty/net/remote_instance.rb', line 102

def hosts_file_listing_for(cl)
  string = (cl.name == cloud.name) ? "#{name}.#{my_cloud.name}\t#{name}" : "#{name}.#{my_cloud.name}"
  "#{internal_ip}\t#{string}"
end

#loadObject

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



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

def load
  current_load ||= 0.0  #NOTE MF: returning 0.0 seems like a bad idea here.  should return nil if we dont have a real value
end

#master?Boolean

Is this remote instance the master? DEPRECATE

Returns:

  • (Boolean)


25
26
27
# File 'lib/poolparty/net/remote_instance.rb', line 25

def master?
  name == "master"
end

#on_initObject

Callback



20
21
# File 'lib/poolparty/net/remote_instance.rb', line 20

def on_init
end

#pending?Boolean

Is this instance pending?

Returns:

  • (Boolean)


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

def pending?
  false
end

#puppet_runner_commandObject

FIXME: deprecate puppet specific commands in this class



87
88
89
# File 'lib/poolparty/net/remote_instance.rb', line 87

def puppet_runner_command
  self.class.send :puppet_runner_command
end

#responding?Boolean

Determine if the RemoteInstance is responding

Returns:

  • (Boolean)


35
36
37
38
# File 'lib/poolparty/net/remote_instance.rb', line 35

def responding?
  running?
  # !responding.nil? #TODO MF this needs to actually ping the node or something similar.  stubbed to running? for now
end

#running?Boolean

Note, the next 4 methods will be overridden by the cloud specific remoter_base Is this instance running?

Returns:

  • (Boolean)


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

def running?
  true
end

#terminated?Boolean

Has this instance been terminated?

Returns:

  • (Boolean)


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

def terminated?
  false
end

#terminating?Boolean

Is this instance terminating?

Returns:

  • (Boolean)


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

def terminating?
  false
end

#to_sObject

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



67
68
69
# File 'lib/poolparty/net/remote_instance.rb', line 67

def to_s
  "#{name}\t#{ip}\t#{instance_id rescue ""}"
end

#valid?Boolean

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

Returns:

  • (Boolean)


30
31
32
# File 'lib/poolparty/net/remote_instance.rb', line 30

def valid?
  (ip.nil? || name.nil?) ? false : true
end