Method: Lab::Drivers::WorkstationVixrDriver#initialize

Defined in:
lib/lab/driver/workstation_vixr_driver.rb

#initialize(vmid, location, os = nil, tools = false, credentials = nil) ⇒ WorkstationVixrDriver

Returns a new instance of WorkstationVixrDriver.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/lab/driver/workstation_vixr_driver.rb', line 17

def initialize(vmid, location, os=nil, tools=false, credentials=nil)

  # We have to treat this differently, as it's not in the same tree
  begin
    require 'vixr'
  rescue LoadError
    puts   "WARNING: Library pro_vixr not found. To resolve this error, please\n" + 
      "         install the vixr gem. Latest is available here:\n" +
      "https://github.com/rhythmx/vixr ."
    raise "Unable to create vixr driver"
  end
  
  @vmid = filter_command(vmid)
  @location = filter_command(location)

  if !File.exist?(@location)
    raise ArgumentError,"Couldn't find: " + location
  end

  @credentials = credentials
  @tools = tools  # not used in command lines, no filter
  @os = os  # not used in command lines, no filter

  # TODO - Currently only implemented for the first set
  if @credentials.count > 0
    @vm_user = filter_input(@credentials[0]['user']) || "\'\'"
    @vm_pass = filter_input(@credentials[0]['pass']) || "\'\'"
  end
  
  host = VixR.connect()
  vm = host.open_vmx(@location)
  
end