Class: Lab::Drivers::WorkstationVixrDriver
- Inherits:
-
VmDriver
- Object
- VmDriver
- Lab::Drivers::WorkstationVixrDriver
show all
- Defined in:
- lib/lab/driver/workstation_vixr_driver.rb
Instance Attribute Summary collapse
Attributes inherited from VmDriver
#credentials, #os, #tools, #vmid
Instance Method Summary
collapse
Methods inherited from VmDriver
#register, #resume, #unregister
Constructor Details
#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)
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 @os = os
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
|
Instance Attribute Details
#location ⇒ Object
Returns the value of attribute location.
15
16
17
|
# File 'lib/lab/driver/workstation_vixr_driver.rb', line 15
def location
@location
end
|
#type ⇒ Object
Returns the value of attribute type.
14
15
16
|
# File 'lib/lab/driver/workstation_vixr_driver.rb', line 14
def type
@type
end
|
Instance Method Details
#check_file_exists(file) ⇒ Object
106
107
108
109
|
# File 'lib/lab/driver/workstation_vixr_driver.rb', line 106
def check_file_exists(file)
file = filter_input(file)
file_exists?(file)
end
|
#cleanup ⇒ Object
115
116
117
|
# File 'lib/lab/driver/workstation_vixr_driver.rb', line 115
def cleanup
end
|
#copy_from(from, to) ⇒ Object
94
95
96
97
98
|
# File 'lib/lab/driver/workstation_vixr_driver.rb', line 94
def copy_from(from, to)
from = filter_input(from)
to = filter_input(to)
cp_from_host(from,to)
end
|
#copy_to(from, to) ⇒ Object
100
101
102
103
104
|
# File 'lib/lab/driver/workstation_vixr_driver.rb', line 100
def copy_to(from, to)
from = filter_input(from)
to = filter_input(to)
vm.cp_to_guest(from,to)
end
|
#create_directory(directory) ⇒ Object
111
112
113
|
# File 'lib/lab/driver/workstation_vixr_driver.rb', line 111
def create_directory(directory)
directory = filter_input(directory)
end
|
#create_snapshot(snapshot) ⇒ Object
71
72
73
74
|
# File 'lib/lab/driver/workstation_vixr_driver.rb', line 71
def create_snapshot(snapshot)
snapshot = filter_input(snapshot)
system_command("ssh #{@user}@#{@host} vmrun -T ws snapshot \\\'#{@location}\\\' #{snapshot} nogui")
end
|
#delete_snapshot(snapshot) ⇒ Object
81
82
83
84
|
# File 'lib/lab/driver/workstation_vixr_driver.rb', line 81
def delete_snapshot(snapshot)
snapshot = filter_input(snapshot)
system_command("ssh #{@user}@#{@host} vmrun -T ws deleteSnapshot \\\'#{@location}\\\' #{snapshot} nogui" )
end
|
#pause ⇒ Object
63
64
65
|
# File 'lib/lab/driver/workstation_vixr_driver.rb', line 63
def pause
vm.pause
end
|
#reset ⇒ Object
67
68
69
|
# File 'lib/lab/driver/workstation_vixr_driver.rb', line 67
def reset
vm.reset
end
|
#revert_snapshot(snapshot) ⇒ Object
76
77
78
79
|
# File 'lib/lab/driver/workstation_vixr_driver.rb', line 76
def revert_snapshot(snapshot)
snapshot = filter_input(snapshot)
system_command("ssh #{@user}@#{@host} vmrun -T ws revertToSnapshot \\\'#{@location}\\\' #{snapshot} nogui")
end
|
#run_command(command) ⇒ Object
87
88
89
90
91
92
|
# File 'lib/lab/driver/workstation_vixr_driver.rb', line 87
def run_command(command)
command = filter_input(command)
if vm.login(@vm_user,@vm_pass)
vm.run_prog(command)
end
end
|
#running? ⇒ Boolean
119
120
121
|
# File 'lib/lab/driver/workstation_vixr_driver.rb', line 119
def running?
vm.running?
end
|
#start ⇒ Object
51
52
53
|
# File 'lib/lab/driver/workstation_vixr_driver.rb', line 51
def start
vm.power_on
end
|
#stop ⇒ Object
55
56
57
|
# File 'lib/lab/driver/workstation_vixr_driver.rb', line 55
def stop
vm.power_off
end
|
#suspend ⇒ Object
59
60
61
|
# File 'lib/lab/driver/workstation_vixr_driver.rb', line 59
def suspend
vm.suspend
end
|