Class: PoolParty::Remote::RemoteInstance
- Includes:
- Dslify
- Defined in:
- lib/poolparty/net/remote_instance.rb
Direct Known Subclasses
Class Method Summary collapse
-
.hash_from_s(s) ⇒ Object
Class method to disect a neighborhood line.
- .puppet_master_rerun_command ⇒ Object
- .puppet_rerun_commad ⇒ Object
-
.puppet_runner_command ⇒ Object
Commands for the servers.
- .to_s(hsh) ⇒ Object
Instance Method Summary collapse
-
#dependency_resolver_command ⇒ Object
TODO: Diet the next 5 commands.
- #elapsed_runtime ⇒ Object
- #hosts_file_listing_for(cl) ⇒ Object
-
#initialize(opts = {}, containing_cloud = nil) ⇒ RemoteInstance
constructor
A new instance of RemoteInstance.
-
#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.
-
#master? ⇒ Boolean
Is this remote instance the master? DEPRECATE.
-
#on_init ⇒ Object
Callback.
-
#pending? ⇒ Boolean
Is this instance pending?.
-
#puppet_runner_command ⇒ Object
FIXME: deprecate puppet specific commands in this class.
-
#responding? ⇒ Boolean
Determine if the RemoteInstance is responding.
-
#running? ⇒ Boolean
Note, the next 4 methods will be overridden by the cloud specific remoter_base Is this instance running?.
-
#terminated? ⇒ Boolean
Has this instance been terminated?.
-
#terminating? ⇒ Boolean
Is this instance terminating?.
-
#to_s ⇒ Object
Printing.
-
#valid? ⇒ Boolean
The remote instances is only valid if there is an ip and a name.
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 (containing_cloud.) if containing_cloud && containing_cloud.respond_to?(: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_command ⇒ Object
94 95 96 |
# File 'lib/poolparty/net/remote_instance.rb', line 94 def self.puppet_master_rerun_command ". /etc/profile && puppetrerun" end |
.puppet_rerun_commad ⇒ Object
97 98 99 |
# File 'lib/poolparty/net/remote_instance.rb', line 97 def self.puppet_rerun_commad puppet_runner_command end |
.puppet_runner_command ⇒ Object
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_command ⇒ Object
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_runtime ⇒ Object
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 |
#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
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
25 26 27 |
# File 'lib/poolparty/net/remote_instance.rb', line 25 def master? name == "master" end |
#on_init ⇒ Object
Callback
20 21 |
# File 'lib/poolparty/net/remote_instance.rb', line 20 def on_init end |
#pending? ⇒ Boolean
Is this instance pending?
53 54 55 |
# File 'lib/poolparty/net/remote_instance.rb', line 53 def pending? false end |
#puppet_runner_command ⇒ Object
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
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?
49 50 51 |
# File 'lib/poolparty/net/remote_instance.rb', line 49 def running? true end |
#terminated? ⇒ Boolean
Has this instance been terminated?
61 62 63 |
# File 'lib/poolparty/net/remote_instance.rb', line 61 def terminated? false end |
#terminating? ⇒ Boolean
Is this instance terminating?
57 58 59 |
# File 'lib/poolparty/net/remote_instance.rb', line 57 def terminating? false end |
#to_s ⇒ Object
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
30 31 32 |
# File 'lib/poolparty/net/remote_instance.rb', line 30 def valid? (ip.nil? || name.nil?) ? false : true end |