Class: PoolParty::Remote::RemoteInstance
- Includes:
- Dslify
- Defined in:
- lib/poolparty/net/remote_instance.rb
Direct Known Subclasses
Ec2RemoteInstance, LibvirtInstance, MetavirtInstance, VmwareInstance
Instance Method Summary collapse
- #[](k) ⇒ Object
- #[]=(k, v) ⇒ Object
-
#each ⇒ Object
hash like methods TODO: move these into a module, or into dslify include Enumerable.
- #elapsed_runtime ⇒ Object
- #has_key?(key) ⇒ Boolean
-
#initialize(opts = {}) ⇒ RemoteInstance
constructor
A new instance of RemoteInstance.
- #keys ⇒ Object
-
#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.
-
#on_init ⇒ Object
Callback.
-
#pending? ⇒ Boolean
Is this instance pending?.
-
#running? ⇒ Boolean
Is this instance running?.
-
#terminated? ⇒ Boolean
Has this instance been terminated?.
-
#terminating? ⇒ Boolean
Is this instance terminating?.
-
#valid? ⇒ Boolean
The remote instances is only valid if there is an ip and a name.
- #values ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ RemoteInstance
Returns a new instance of RemoteInstance.
15 16 17 18 19 |
# File 'lib/poolparty/net/remote_instance.rb', line 15 def initialize(opts={}) opts.choose{|k,v| .has_key? k} (opts) if opts.is_a?(Hash) on_init end |
Instance Method Details
#[](k) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/poolparty/net/remote_instance.rb', line 28 def [](k) if .has_key? k [k] else nil end end |
#[]=(k, v) ⇒ Object
36 37 38 |
# File 'lib/poolparty/net/remote_instance.rb', line 36 def []=(k,v) [k] = v end |
#each ⇒ Object
hash like methods TODO: move these into a module, or into dslify include Enumerable
24 25 26 |
# File 'lib/poolparty/net/remote_instance.rb', line 24 def each .each{ |k,v| yield k,v } end |
#elapsed_runtime ⇒ Object
70 71 72 |
# File 'lib/poolparty/net/remote_instance.rb', line 70 def elapsed_runtime Time.now.to_i - launching_time.to_time.to_i end |
#has_key?(key) ⇒ Boolean
40 41 42 |
# File 'lib/poolparty/net/remote_instance.rb', line 40 def has_key?(key) .has_key?(key) end |
#keys ⇒ Object
44 45 46 |
# File 'lib/poolparty/net/remote_instance.rb', line 44 def keys .keys 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
86 87 88 |
# File 'lib/poolparty/net/remote_instance.rb', line 86 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 |
#on_init ⇒ Object
Callback
75 76 |
# File 'lib/poolparty/net/remote_instance.rb', line 75 def on_init end |
#pending? ⇒ Boolean
Is this instance pending?
58 59 60 |
# File 'lib/poolparty/net/remote_instance.rb', line 58 def pending? !(status =~ /pending/).nil? end |
#running? ⇒ Boolean
Is this instance running?
54 55 56 |
# File 'lib/poolparty/net/remote_instance.rb', line 54 def running? !(status =~ /running/).nil? end |
#terminated? ⇒ Boolean
Has this instance been terminated?
66 67 68 |
# File 'lib/poolparty/net/remote_instance.rb', line 66 def terminated? !(status =~ /terminated/).nil? end |
#terminating? ⇒ Boolean
Is this instance terminating?
62 63 64 |
# File 'lib/poolparty/net/remote_instance.rb', line 62 def terminating? !(status =~ /shutting/).nil? end |
#valid? ⇒ Boolean
The remote instances is only valid if there is an ip and a name
79 80 81 |
# File 'lib/poolparty/net/remote_instance.rb', line 79 def valid? (ip.nil? || name.nil?) ? false : true end |
#values ⇒ Object
48 49 50 |
# File 'lib/poolparty/net/remote_instance.rb', line 48 def values .values end |