Class: PoolParty::Remote::Vmrun

Inherits:
RemoterBase show all
Includes:
Dslify
Defined in:
lib/poolparty/net/remoter_bases/vmrun/vmrun.rb

Instance Attribute Summary

Attributes inherited from RemoterBase

#cloud

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RemoterBase

#launch_instance!, launch_instance!, ping_port

Methods included from PoolParty::Remote

#_nodes, #are_any_nodes_exceeding_minimum_runtime?, #are_too_few_instances_running?, #are_too_many_instances_running?, #commands, #execute!, #is_master_running?, #list_of_instances, #list_of_nodes_exceeding_minimum_runtime, #master, #netssh, #nodes, #remote_rsync_command, #remote_ssh_array, #remote_ssh_string, #rsync, #rsync_command, #rsync_storage_files_to, #rsync_storage_files_to_command, #rsync_to, #rsync_to_command, #run_command_on, #run_command_on_command, #run_command_on_instance_number, #run_remote, #scp_array, #scp_to_command, #simplest_run_remote, #ssh_array, #ssh_command, #ssh_into, #ssh_into_instance_number, #ssh_options, #ssh_string, #target_host

Methods included from Pinger

included

Constructor Details

#initialize(par, opts = {}, &block) ⇒ Vmrun

Returns a new instance of Vmrun.



42
43
44
45
46
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun.rb', line 42

def initialize(par, opts={}, &block)
  dsl_options opts
  instance_eval &block if block
  super(par, &block)    
end

Class Method Details

.describe_instance(o = {}) ⇒ Object

Describe an instance’s status, must pass :vmx_file in the options



77
78
79
80
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun.rb', line 77

def self.describe_instance(o={})
  # vmx_file = o[:vmx_file] || Vmrun.running_instances.first
  new_instance(o).describe_instance
end

.describe_instances(o = {}) ⇒ Object



85
86
87
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun.rb', line 85

def self.describe_instances(o={})
  new_instance(o).describe_instances
end

.launch_new_instance!(o = {}) ⇒ Object



55
56
57
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun.rb', line 55

def self.launch_new_instance!(o={})
  new_instance(o).launch_new_instance!
end

.path_to_binaryObject



102
103
104
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun.rb', line 102

def self.path_to_binary
  new(parent).path_to_binary
end

.terminate!(o = {}) ⇒ Object

terminate all running instances



49
50
51
52
53
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun.rb', line 49

def self.terminate!(o={})
  describe_instances(o).each do |vmxf|
     terminate_instance! o.merge(:vmx_file => vmxf)
  end
end

.terminate_instance!(o = {}) ⇒ Object

Terminate an instance by id



65
66
67
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun.rb', line 65

def self.terminate_instance!(o={})
  new(nil, o).terminate_instance!
end

Instance Method Details

#after_launch_instance(inst = nil) ⇒ Object



106
107
108
109
110
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun.rb', line 106

def after_launch_instance(inst=nil)
  if inst
    dputs "Associate address after launched: #{inst.ip}"
  end
end

#after_launched(force = false) ⇒ Object

After launch callback This is called after a new instance is launched



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

def after_launched(force=false)
  puts "new vmware instance was launched"
end

#before_shutdownObject

Before shutdown callback This is called before the cloud is contracted



100
101
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun.rb', line 100

def before_shutdown
end

#describe_instance(o = {}) ⇒ Object



81
82
83
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun.rb', line 81

def describe_instance(o={})        
  running_instances.select {|inst| inst.vmx_file == o[:vmx_file] }.first
end

#describe_instances(o = {}) ⇒ Object



88
89
90
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun.rb', line 88

def describe_instances(o={})
  running_instances.map {|a| a.to_hash }
end

#launch_new_instance!(o = {}) ⇒ Object



58
59
60
61
62
63
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun.rb', line 58

def launch_new_instance!(o={})
  VmwareInstance.new( :vmx_file => next_unused_vmx_file, 
                      :ip => vmx_hash[next_unused_vmx_file], 
                      :keypair => @cloud.keypair
                    ).launch!
end

#terminate_instance!(o = {}) ⇒ Object



68
69
70
71
72
73
74
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun.rb', line 68

def terminate_instance!(o={})
  dsl_options o
  VmwareInstance.new( :vmx_file => last_unused_vmx_file, 
                      :ip => vmx_hash[last_unused_vmx_file], 
                      :keypair => @cloud.keypair
                    ).terminate!(terminate_options)
end