lab 0.1.5 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/config/test_lab.yml +11 -0
- data/config/test_targets.yml +21 -0
- data/lib/lab/controller/dynagen_controller.rb +6 -6
- data/lib/lab/controller/remote_esx_controller.rb +51 -51
- data/lib/lab/controller/remote_esxi_controller.rb +62 -0
- data/lib/lab/controller/remote_workstation_controller.rb +12 -12
- data/lib/lab/controller/virtualbox_controller.rb +16 -16
- data/lib/lab/controller/workstation_controller.rb +9 -9
- data/lib/lab/controller/workstation_vixr_controller.rb +9 -9
- data/lib/lab/controllers.rb +1 -3
- data/lib/lab/driver/dynagen_driver.rb +32 -32
- data/lib/lab/driver/fog_driver.rb +144 -144
- data/lib/lab/driver/remote_esxi_driver.rb +177 -0
- data/lib/lab/driver/remote_workstation_driver.rb +181 -181
- data/lib/lab/driver/virtualbox_driver.rb +132 -132
- data/lib/lab/driver/vm_driver.rb +177 -177
- data/lib/lab/driver/workstation_driver.rb +218 -218
- data/lib/lab/driver/workstation_vixr_driver.rb +108 -108
- data/lib/lab/drivers.rb +1 -1
- data/lib/lab/modifier/backtrack5_modifier.rb +8 -8
- data/lib/lab/modifier/dos_modifier.rb +3 -3
- data/lib/lab/modifier/test_modifier.rb +6 -6
- data/lib/lab/version.rb +1 -1
- data/lib/lab/vm.rb +242 -242
- data/lib/lab/vm_controller.rb +217 -211
- data/src/Gemfile +4 -0
- data/src/README.md +80 -0
- data/src/Rakefile +1 -0
- data/src/TODO +15 -0
- data/src/config/test_lab.yml +11 -0
- data/src/config/test_targets.yml +21 -0
- data/src/lab.gemspec +35 -0
- data/src/lib/lab.rb +2 -0
- data/src/lib/lab/controller/dynagen_controller.rb +14 -0
- data/src/lib/lab/controller/fog_controller.rb +6 -0
- data/src/lib/lab/controller/remote_esxi_controller.rb +62 -0
- data/src/lib/lab/controller/remote_workstation_controller.rb +22 -0
- data/src/lib/lab/controller/virtualbox_controller.rb +25 -0
- data/src/lib/lab/controller/vsphere_controller.rb +18 -0
- data/src/lib/lab/controller/workstation_controller.rb +17 -0
- data/src/lib/lab/controller/workstation_vixr_controller.rb +19 -0
- data/src/lib/lab/controllers.rb +9 -0
- data/src/lib/lab/driver/dynagen_driver.rb +47 -0
- data/src/lib/lab/driver/fog_driver.rb +104 -0
- data/src/lib/lab/driver/remote_esxi_driver.rb +177 -0
- data/src/lib/lab/driver/remote_workstation_driver.rb +197 -0
- data/src/lib/lab/driver/virtualbox_driver.rb +142 -0
- data/src/lib/lab/driver/vm_driver.rb +195 -0
- data/src/lib/lab/driver/vsphere_driver.rb +120 -0
- data/src/lib/lab/driver/workstation_driver.rb +234 -0
- data/src/lib/lab/driver/workstation_vixr_driver.rb +126 -0
- data/src/lib/lab/drivers.rb +9 -0
- data/src/lib/lab/modifier/backtrack5_modifier.rb +16 -0
- data/src/lib/lab/modifier/dos_modifier.rb +14 -0
- data/src/lib/lab/modifier/test_modifier.rb +16 -0
- data/src/lib/lab/modifiers.rb +3 -0
- data/src/lib/lab/version.rb +3 -0
- data/src/lib/lab/vm.rb +269 -0
- data/src/lib/lab/vm_controller.rb +275 -0
- data/src/test/.gitkeep +0 -0
- metadata +51 -12
- data/lib/lab/driver/remote_esx_driver.rb +0 -177
@@ -11,114 +11,114 @@ module Drivers
|
|
11
11
|
|
12
12
|
class WorkstationVixrDriver < VmDriver
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
14
|
+
attr_accessor :type
|
15
|
+
attr_accessor :location
|
16
|
+
|
17
|
+
def initialize(vmid, location, os=nil, tools=false, credentials=nil)
|
18
|
+
|
19
|
+
# We have to treat this differently, as it's not in the same tree
|
20
|
+
begin
|
21
|
+
require 'vixr'
|
22
|
+
rescue LoadError
|
23
|
+
puts "WARNING: Library pro_vixr not found. To resolve this error, please\n" +
|
24
|
+
" install the vixr gem. Latest is available here:\n" +
|
25
|
+
"https://github.com/rhythmx/vixr ."
|
26
|
+
raise "Unable to create vixr driver"
|
27
|
+
end
|
28
|
+
|
29
|
+
@vmid = filter_command(vmid)
|
30
|
+
@location = filter_command(location)
|
31
|
+
|
32
|
+
if !File.exist?(@location)
|
33
|
+
raise ArgumentError,"Couldn't find: " + location
|
34
|
+
end
|
35
|
+
|
36
|
+
@credentials = credentials
|
37
|
+
@tools = tools # not used in command lines, no filter
|
38
|
+
@os = os # not used in command lines, no filter
|
39
|
+
|
40
|
+
# TODO - Currently only implemented for the first set
|
41
|
+
if @credentials.count > 0
|
42
|
+
@vm_user = filter_input(@credentials[0]['user']) || "\'\'"
|
43
|
+
@vm_pass = filter_input(@credentials[0]['pass']) || "\'\'"
|
44
|
+
end
|
45
|
+
|
46
|
+
host = VixR.connect()
|
47
|
+
vm = host.open_vmx(@location)
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
def start
|
52
|
+
vm.power_on
|
53
|
+
end
|
54
|
+
|
55
|
+
def stop
|
56
|
+
vm.power_off
|
57
|
+
end
|
58
|
+
|
59
|
+
def suspend
|
60
|
+
vm.suspend
|
61
|
+
end
|
62
|
+
|
63
|
+
def pause
|
64
|
+
vm.pause
|
65
|
+
end
|
66
|
+
|
67
|
+
def reset
|
68
|
+
vm.reset
|
69
|
+
end
|
70
|
+
|
71
|
+
def create_snapshot(snapshot)
|
72
|
+
snapshot = filter_input(snapshot)
|
73
|
+
system_command("ssh #{@user}@#{@host} vmrun -T ws snapshot \\\'#{@location}\\\' #{snapshot} nogui")
|
74
|
+
end
|
75
|
+
|
76
|
+
def revert_snapshot(snapshot)
|
77
|
+
snapshot = filter_input(snapshot)
|
78
|
+
system_command("ssh #{@user}@#{@host} vmrun -T ws revertToSnapshot \\\'#{@location}\\\' #{snapshot} nogui")
|
79
|
+
end
|
80
|
+
|
81
|
+
def delete_snapshot(snapshot)
|
82
|
+
snapshot = filter_input(snapshot)
|
83
|
+
system_command("ssh #{@user}@#{@host} vmrun -T ws deleteSnapshot \\\'#{@location}\\\' #{snapshot} nogui" )
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
def run_command(command)
|
88
|
+
command = filter_input(command)
|
89
|
+
if vm.login(@vm_user,@vm_pass)
|
90
|
+
vm.run_prog(command)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def copy_from(from, to)
|
95
|
+
from = filter_input(from)
|
96
|
+
to = filter_input(to)
|
97
|
+
cp_from_host(from,to)
|
98
|
+
end
|
99
|
+
|
100
|
+
def copy_to(from, to)
|
101
|
+
from = filter_input(from)
|
102
|
+
to = filter_input(to)
|
103
|
+
vm.cp_to_guest(from,to)
|
104
|
+
end
|
105
|
+
|
106
|
+
def check_file_exists(file)
|
107
|
+
file = filter_input(file)
|
108
|
+
file_exists?(file)
|
109
|
+
end
|
110
|
+
|
111
|
+
def create_directory(directory)
|
112
|
+
directory = filter_input(directory)
|
113
|
+
end
|
114
|
+
|
115
|
+
def cleanup
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
def running?
|
120
|
+
vm.running?
|
121
|
+
end
|
122
122
|
|
123
123
|
end
|
124
124
|
|
data/lib/lab/drivers.rb
CHANGED
@@ -3,6 +3,6 @@ require 'driver/virtualbox_driver'
|
|
3
3
|
require 'driver/fog_driver'
|
4
4
|
require 'driver/dynagen_driver'
|
5
5
|
require 'driver/remote_workstation_driver'
|
6
|
-
require 'driver/
|
6
|
+
require 'driver/remote_esxi_driver'
|
7
7
|
#require 'driver/qemu_driver'
|
8
8
|
#require 'driver/qemudo_driver'
|
@@ -2,14 +2,14 @@ module Lab
|
|
2
2
|
module Modifier
|
3
3
|
module Backtrack5
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
def nmap(options)
|
6
|
+
run_command("nmap #{filter_input(options)}")
|
7
|
+
end
|
8
|
+
|
9
|
+
def testssl(site)
|
10
|
+
run_command("/pentest/scanners/testssl/testssl.sh #{filter_input(site)}")
|
11
|
+
end
|
12
|
+
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -4,13 +4,13 @@
|
|
4
4
|
module Lab
|
5
5
|
module Modifier
|
6
6
|
module Test
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
def install_nmap
|
8
|
+
run_command("sudo apt-get install nmap")
|
9
|
+
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
def nmap(options)
|
12
|
+
run_command("nmap #{filter_input(options)}")
|
13
|
+
end
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
data/lib/lab/version.rb
CHANGED
data/lib/lab/vm.rb
CHANGED
@@ -4,250 +4,250 @@
|
|
4
4
|
|
5
5
|
module Lab
|
6
6
|
class Vm
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
7
|
+
|
8
|
+
attr_accessor :vmid
|
9
|
+
attr_accessor :hostname
|
10
|
+
attr_accessor :name
|
11
|
+
attr_accessor :description
|
12
|
+
attr_accessor :location
|
13
|
+
attr_accessor :driver
|
14
|
+
attr_accessor :credentials
|
15
|
+
attr_accessor :tools
|
16
|
+
attr_accessor :type
|
17
|
+
attr_accessor :user
|
18
|
+
attr_accessor :host
|
19
|
+
attr_accessor :os
|
20
|
+
attr_accessor :arch
|
21
|
+
|
22
|
+
## Initialize takes a vm configuration hash of the form
|
23
|
+
## - vmid (unique identifier)
|
24
|
+
## driver (vm technology)
|
25
|
+
## user (if applicable - remote system)
|
26
|
+
## host (if applicable - remote system)
|
27
|
+
## pass (if applicable - remote system)
|
28
|
+
## location (file / uri)
|
29
|
+
## credentials (of the form [ {'user'=>"user",'pass'=>"pass", 'admin' => false}, ... ])
|
30
|
+
## os (currently only linux / windows)
|
31
|
+
## arch (currently only 32 / 64
|
32
|
+
|
33
|
+
def initialize(config = {})
|
34
|
+
|
35
|
+
# TODO - This is a mess. clean up, and pass stuff down to drivers
|
36
|
+
# and then rework the code that uses this api.
|
37
|
+
@vmid = config['vmid'].to_s
|
38
|
+
raise "Invalid VMID" unless @vmid
|
39
|
+
|
40
|
+
# Grab the hostname if specified, otherwise use the vmid
|
41
|
+
# VMID will be different in the case of ESX
|
42
|
+
@hostname = config['hostname']
|
43
|
+
if !@hostname
|
44
|
+
@hostname = @vmid
|
45
|
+
end
|
46
|
+
|
47
|
+
@driver_type = filter_input(config['driver'])
|
48
|
+
@driver_type.downcase!
|
49
|
+
|
50
|
+
@location = filter_input(config['location'])
|
51
|
+
#@name = config['name'] || ""
|
52
|
+
@description = config['description']
|
53
|
+
@tools = config['tools']
|
54
|
+
@os = config['os']
|
55
|
+
@arch = config['arch']
|
56
|
+
@type = filter_input(config['type']) || "unspecified"
|
57
|
+
@credentials = config['credentials'] || []
|
58
|
+
|
59
|
+
# TODO - Currently only implemented for the first set
|
60
|
+
if @credentials.count > 0
|
61
|
+
@vm_user = filter_input(@credentials[0]['user']) || "\'\'"
|
62
|
+
@vm_pass = filter_input(@credentials[0]['pass']) || "\'\'"
|
63
|
+
@vm_keyfile = filter_input(@credentials[0]['keyfile'])
|
64
|
+
end
|
65
|
+
|
66
|
+
# Only applicable to remote systems
|
67
|
+
@user = filter_input(config['user']) || nil
|
68
|
+
@host = filter_input(config['host']) || nil
|
69
|
+
@port = filter_input(config['port']) || nil
|
70
|
+
@pass = filter_input(config['pass']) || nil
|
71
|
+
|
72
|
+
#Only dynagen systems need this
|
73
|
+
@platform = config['platform']
|
74
|
+
|
75
|
+
#Only fog systems need this
|
76
|
+
@fog_config = config['fog_config']
|
77
|
+
|
78
|
+
#puts "Passing driver config: #{config}"
|
79
|
+
|
80
|
+
# Process the correct driver
|
81
|
+
if @driver_type == "workstation"
|
82
|
+
@driver = Lab::Drivers::WorkstationDriver.new(config)
|
83
|
+
elsif @driver_type == "virtualbox"
|
84
|
+
@driver = Lab::Drivers::VirtualBoxDriver.new(config)
|
85
|
+
elsif @driver_type == "fog"
|
86
|
+
@driver = Lab::Drivers::FogDriver.new(config, config['fog_config'])
|
87
|
+
elsif @driver_type == "dynagen"
|
88
|
+
@driver = Lab::Drivers::DynagenDriver.new(config, config['dynagen_config'])
|
89
|
+
elsif @driver_type == "remote_esxi"
|
90
|
+
@driver = Lab::Drivers::RemoteEsxiDriver.new(config)
|
91
|
+
elsif @driver_type == "remote_workstation"
|
92
|
+
@driver = Lab::Drivers::RemoteWorkstationDriver.new(config)
|
93
|
+
#elsif @driver_type == "qemu"
|
94
|
+
# @driver = Lab::Drivers::QemuDriver.new
|
95
|
+
#elsif @driver_type == "qemudo"
|
96
|
+
# @driver = Lab::Drivers::QemudoDriver.new
|
97
|
+
else
|
98
|
+
raise "Unknown Driver Type"
|
99
|
+
end
|
100
|
+
|
101
|
+
# Load in a list of modifiers. These provide additional methods
|
102
|
+
# Currently it is up to the user to verify that
|
103
|
+
# modifiers are properly used with the correct VM image.
|
104
|
+
#
|
105
|
+
# If not, the results are likely to be disasterous.
|
106
|
+
@modifiers = config['modifiers']
|
107
|
+
|
108
|
+
if @modifiers
|
109
|
+
begin
|
110
|
+
@modifiers.each { |modifier| self.class.send(:include, eval("Lab::Modifier::#{modifier}"))}
|
111
|
+
rescue Exception => e
|
112
|
+
# modifier likely didn't exist
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def running?
|
118
|
+
@driver.running?
|
119
|
+
end
|
120
|
+
|
121
|
+
def location
|
122
|
+
@driver.location
|
123
|
+
end
|
124
|
+
|
125
|
+
def start
|
126
|
+
@driver.start
|
127
|
+
end
|
128
|
+
|
129
|
+
def stop
|
130
|
+
@driver.stop
|
131
|
+
end
|
132
|
+
|
133
|
+
def pause
|
134
|
+
@driver.pause
|
135
|
+
end
|
136
|
+
|
137
|
+
def suspend
|
138
|
+
@driver.suspend
|
139
|
+
end
|
140
|
+
|
141
|
+
def reset
|
142
|
+
@driver.reset
|
143
|
+
end
|
144
|
+
|
145
|
+
def resume
|
146
|
+
@driver.resume
|
147
|
+
end
|
148
|
+
|
149
|
+
def create_snapshot(snapshot)
|
150
|
+
@driver.create_snapshot(snapshot)
|
151
|
+
end
|
152
|
+
|
153
|
+
def revert_snapshot(snapshot)
|
154
|
+
@driver.revert_snapshot(snapshot)
|
155
|
+
end
|
156
|
+
|
157
|
+
def delete_snapshot(snapshot)
|
158
|
+
@driver.delete_snapshot(snapshot)
|
159
|
+
end
|
160
|
+
|
161
|
+
def revert_and_start(snapshot)
|
162
|
+
@driver.revert_snapshot(snapshot)
|
163
|
+
@driver.start
|
164
|
+
end
|
165
|
+
|
166
|
+
def copy_to(from,to)
|
167
|
+
@driver.copy_to(from,to)
|
168
|
+
end
|
169
|
+
|
170
|
+
def copy_from(from,to)
|
171
|
+
@driver.copy_from(from,to)
|
172
|
+
end
|
173
|
+
|
174
|
+
def run_command(command)
|
175
|
+
@driver.run_command(command)
|
176
|
+
end
|
177
|
+
|
178
|
+
def check_file_exists(file)
|
179
|
+
@driver.check_file_exists(file)
|
180
|
+
end
|
181
|
+
|
182
|
+
def create_directory(directory)
|
183
|
+
@driver.create_directory(directory)
|
184
|
+
end
|
185
|
+
|
186
|
+
def open_uri(uri)
|
187
|
+
# we don't filter the uri, as it's getting tossed into a script
|
188
|
+
# by the driver
|
189
|
+
if @os == "windows"
|
190
|
+
command = "\"C:\\program files\\internet explorer\\iexplore.exe\" #{uri}"
|
191
|
+
else
|
192
|
+
command = "firefox #{uri}"
|
193
|
+
end
|
194
|
+
|
195
|
+
@driver.run_command(command)
|
196
|
+
end
|
197
|
+
|
198
|
+
def to_s
|
199
|
+
return "#{@hostname}"
|
200
|
+
end
|
201
|
+
|
202
|
+
def to_yaml
|
203
|
+
|
204
|
+
# TODO - push this down to the drivers.
|
205
|
+
|
206
|
+
# Standard configuration options
|
207
|
+
out = " - vmid: #{@vmid}\n"
|
208
|
+
out += " driver: #{@driver_type}\n"
|
209
|
+
out += " location: #{@location}\n"
|
210
|
+
out += " type: #{@type}\n"
|
211
|
+
out += " tools: #{@tools}\n"
|
212
|
+
out += " os: #{@os}\n"
|
213
|
+
out += " arch: #{@arch}\n"
|
214
|
+
|
215
|
+
if @user or @host # Remote vm/drivers only
|
216
|
+
out += " user: #{@user}\n"
|
217
|
+
out += " host: #{@host}\n"
|
218
|
+
end
|
219
|
+
|
220
|
+
if @platform
|
221
|
+
out += " platform: #{@platform}\n"
|
222
|
+
end
|
223
|
+
|
224
|
+
if @fog_config
|
225
|
+
out += @fog_config.to_yaml
|
226
|
+
end
|
227
|
+
|
228
|
+
if @dynagen_config
|
229
|
+
out += @dynagen_config.to_yaml
|
230
|
+
end
|
231
|
+
|
232
|
+
out += " credentials:\n"
|
233
|
+
@credentials.each do |credential|
|
234
|
+
out += " - user: #{credential['user']}\n"
|
235
|
+
out += " pass: #{credential['pass']}\n"
|
236
|
+
end
|
237
|
+
|
238
|
+
return out
|
239
|
+
end
|
240
240
|
private
|
241
241
|
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
242
|
+
def filter_input(string)
|
243
|
+
return "" unless string # nil becomes empty string
|
244
|
+
return unless string.class == String # Allow other types
|
245
|
+
|
246
|
+
unless /^[(!)\d*\w*\s*\[\]\{\}\/\\\.\-\"\(\)]*$/.match string
|
247
|
+
raise "WARNING! Invalid character in: #{string}"
|
248
|
+
end
|
249
249
|
|
250
|
-
|
251
|
-
|
250
|
+
string
|
251
|
+
end
|
252
252
|
end
|
253
253
|
end
|