Class: PoolParty::Remote::Vmrun

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RemoterBase

available_bases, #cloud, inherited, #initialize, #key_name, launch_instance!, #launch_instance!, #remoter_base_options, symbol, #terminate_youngest_instance!, #to_hash, #to_s

Methods included from Pinger

included

Methods included from PoolParty::Remote

#are_any_nodes_exceeding_minimum_runtime?, #are_too_few_instances_running?, #are_too_many_instances_running?, available, #commands, #execute!, #list_of_instances, #list_of_nodes_exceeding_minimum_runtime, #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

Constructor Details

This class inherits a constructor from PoolParty::Remote::RemoterBase

Class Method Details

.describe_instance(o = {}) ⇒ Object

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



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

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

.describe_instances(o = {}) ⇒ Object



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

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

.launch_new_instance!(o = {}) ⇒ Object



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

def self.launch_new_instance!(o={})
  # puts "launch_new_instance 0 = #{o.inspect}"
  new(o).launch_new_instance!
end

.path_to_binaryObject



105
106
107
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun.rb', line 105

def self.path_to_binary
  new({}).path_to_binary
end

.terminate_instance!(o = {}) ⇒ Object

Terminate an instance by id



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

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

Instance Method Details

#after_launch_instance(inst = nil) ⇒ Object



109
110
111
112
113
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun.rb', line 109

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

#after_launched(force = false) ⇒ Object

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



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

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



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

def before_shutdown
end

#describe_instance(o = {}) ⇒ Object



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

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

#describe_instances(o = {}) ⇒ Object



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

def describe_instances(o={})
  running_instances
end

#image_idObject



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

def image_id
  next_unused_vmx_file
end

#launch_new_instance!(o = {}) ⇒ Object



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

def launch_new_instance!(o={})
  raise "No available vmx files given!" unless next_unused_vmx_file
  vmx_file = next_unused_vmx_file
  VmwareInstance.new( {:vmx_file  => vmx_file, 
                       :public_ip => ip(vmx_file),
                       :ip        => ip(vmx_file),
                       :keypair   => keypair
                      }.merge(o)
                    ).launch!
end

#terminate_instance!(o = {}) ⇒ Object



72
73
74
75
76
77
# File 'lib/poolparty/net/remoter_bases/vmrun/vmrun.rb', line 72

def terminate_instance!(o={})
  set_vars_from_options o
  VmwareInstance.new( :vmx_file => last_unused_vmx_file, 
                      :keypair => keypair
                    ).terminate!(terminate_options)
end

#vmx_files(n = nil) ⇒ Object



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

def vmx_files(n=nil)
  if n.nil?
    dsl_options[:vmx_files] || vmx_hash.keys
  else
    dsl_options[:vmx_files] = n
  end
end