Class: PoolParty::Remote::VmwareInstance
- Defined in:
- lib/poolparty/net/remoter_bases/vmrun/vmrun_instance.rb
Instance Attribute Summary collapse
-
#cloud ⇒ Object
readonly
Returns the value of attribute cloud.
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#keypair ⇒ Object
readonly
Returns the value of attribute keypair.
-
#mac_address ⇒ Object
readonly
Get the ip from the arp -a def ip @ip ||= %x[arp -a].select {|a| a if a =~ /#{mac_address.macify}/}.first end Get the mac address in the vmx_file.
-
#vmx_file ⇒ Object
readonly
Returns the value of attribute vmx_file.
Instance Method Summary collapse
-
#initialize(o = {}, cld = nil) ⇒ VmwareInstance
constructor
A new instance of VmwareInstance.
- #launch! ⇒ Object
- #parse_vmx_file ⇒ Object
-
#pending? ⇒ Boolean
Is this instance pending?.
-
#running? ⇒ Boolean
Is this instance running?.
- #status ⇒ Object
- #terminate!(o) ⇒ Object
-
#terminated? ⇒ Boolean
Has this instance been terminated?.
-
#terminating? ⇒ Boolean
Is this instance terminating?.
- #to_hash ⇒ Object
- #vmx_data ⇒ Object
Constructor Details
#initialize(o = {}, cld = nil) ⇒ VmwareInstance
Returns a new instance of VmwareInstance.
7 8 9 10 11 12 13 14 |
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun_instance.rb', line 7 def initialize(o={}, cld=nil) raise "You must pass a vmx_file" unless o[:vmx_file] @vmx_file = ::File.(o[:vmx_file]) @ip = o[:ip] @keypair = o[:keypair] @cloud = cld end |
Instance Attribute Details
#cloud ⇒ Object (readonly)
Returns the value of attribute cloud.
5 6 7 |
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun_instance.rb', line 5 def cloud @cloud end |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
5 6 7 |
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun_instance.rb', line 5 def ip @ip end |
#keypair ⇒ Object (readonly)
Returns the value of attribute keypair.
5 6 7 |
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun_instance.rb', line 5 def keypair @keypair end |
#mac_address ⇒ Object (readonly)
Get the ip from the arp -a def ip
@ip ||= %x[arp -a].select {|a| a if a =~ /#{mac_address.macify}/}.first[/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/]
end Get the mac address in the vmx_file
58 59 60 |
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun_instance.rb', line 58 def mac_address @mac_address end |
#vmx_file ⇒ Object (readonly)
Returns the value of attribute vmx_file.
5 6 7 |
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun_instance.rb', line 5 def vmx_file @vmx_file end |
Instance Method Details
#launch! ⇒ Object
45 46 47 48 49 |
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun_instance.rb', line 45 def launch! Vmrun.run_local("#{Vmrun.path_to_binary} start \"#{vmx_file}\"") dputs "Launched new vmware instance from vmx: #{vmx_file}" to_hash end |
#parse_vmx_file ⇒ Object
61 62 63 |
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun_instance.rb', line 61 def parse_vmx_file vmx_data.to_hash end |
#pending? ⇒ Boolean
Is this instance pending?
34 35 36 |
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun_instance.rb', line 34 def pending? false end |
#running? ⇒ Boolean
Is this instance running?
30 31 32 |
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun_instance.rb', line 30 def running? true end |
#status ⇒ Object
26 27 28 |
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun_instance.rb', line 26 def status "running" end |
#terminate!(o) ⇒ Object
50 51 52 |
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun_instance.rb', line 50 def terminate!(o) Vmrun.run_local("#{Vmrun.path_to_binary} stop \"#{vmx_file}\" #{o}") end |
#terminated? ⇒ Boolean
Has this instance been terminated?
42 43 44 |
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun_instance.rb', line 42 def terminated? false end |
#terminating? ⇒ Boolean
Is this instance terminating?
38 39 40 |
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun_instance.rb', line 38 def terminating? false end |
#to_hash ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun_instance.rb', line 16 def to_hash { :status => status, :mac_addresses => mac_address, :ip => ip, :instance_id => vmx_file, :internal_ip => ip, :keypair => keypair } end |
#vmx_data ⇒ Object
64 65 66 |
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun_instance.rb', line 64 def vmx_data @vmx_data ||= open(vmx_file).read end |