veewee 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/README.md +1 -1
- data/doc/definition.md +18 -0
- data/doc/kvm.md +28 -1
- data/doc/template.md +53 -2
- data/lib/veewee/command/fusion.rb +37 -3
- data/lib/veewee/command/vagrant/basebox.rb +2 -0
- data/lib/veewee/command/vagrant/winrm.rb +39 -0
- data/lib/veewee/command/vbox.rb +18 -0
- data/lib/veewee/definition.rb +13 -3
- data/lib/veewee/error.rb +3 -0
- data/lib/veewee/provider/core/box.rb +7 -0
- data/lib/veewee/provider/core/box/build.rb +34 -14
- data/lib/veewee/provider/core/box/copy.rb +17 -0
- data/lib/veewee/provider/core/box/exec.rb +31 -12
- data/lib/veewee/provider/core/box/floppy.rb +1 -0
- data/lib/veewee/provider/core/box/halt.rb +7 -3
- data/lib/veewee/provider/core/box/validate_tags.rb +8 -2
- data/lib/veewee/provider/core/box/wincp.rb +120 -0
- data/lib/veewee/provider/core/box/winrm.rb +59 -0
- data/lib/veewee/provider/core/helper/comm.rb +47 -0
- data/lib/veewee/provider/core/helper/web.rb +20 -9
- data/lib/veewee/provider/core/helper/winrm.rb +167 -0
- data/lib/veewee/provider/kvm/box/create.rb +59 -3
- data/lib/veewee/provider/kvm/provider.rb +6 -6
- data/lib/veewee/provider/parallels/box/helper/buildinfo.rb +1 -1
- data/lib/veewee/provider/virtualbox/box.rb +1 -0
- data/lib/veewee/provider/virtualbox/box/build.rb +4 -2
- data/lib/veewee/provider/virtualbox/box/create.rb +32 -12
- data/lib/veewee/provider/virtualbox/box/helper/buildinfo.rb +6 -3
- data/lib/veewee/provider/virtualbox/box/helper/create.rb +20 -5
- data/lib/veewee/provider/virtualbox/box/helper/winrm_options.rb +31 -0
- data/lib/veewee/provider/virtualbox/box/up.rb +33 -12
- data/lib/veewee/provider/virtualbox/box/winrm.rb +13 -0
- data/lib/veewee/provider/vmfusion/box.rb +2 -0
- data/lib/veewee/provider/vmfusion/box/add_share.rb +18 -0
- data/lib/veewee/provider/vmfusion/box/build.rb +3 -1
- data/lib/veewee/provider/vmfusion/box/create.rb +7 -2
- data/lib/veewee/provider/vmfusion/box/helper/buildinfo.rb +9 -6
- data/lib/veewee/provider/vmfusion/box/helper/ip.rb +1 -1
- data/lib/veewee/provider/vmfusion/box/helper/winrm_options.rb +21 -0
- data/lib/veewee/provider/vmfusion/box/template.rb +7 -3
- data/lib/veewee/provider/vmfusion/box/template.vmx.erb +6 -0
- data/lib/veewee/provider/vmfusion/box/winrm.rb +12 -0
- data/lib/veewee/provider/vmfusion/provider.rb +7 -1
- data/lib/veewee/version.rb +1 -1
- data/templates/CentOS-5.6-x86_64-netboot-packages/definition.rb +16 -0
- data/templates/CentOS-5.6-x86_64-netboot-packages/ks.cfg +47 -0
- data/templates/CentOS-5.6-x86_64-netboot-packages/postinstall.sh +61 -0
- data/templates/Debian-7.0-b3-amd64-netboot/base.sh +27 -0
- data/templates/Debian-7.0-b3-amd64-netboot/chef.sh +2 -0
- data/templates/Debian-7.0-b3-amd64-netboot/cleanup-virtualbox.sh +4 -0
- data/templates/Debian-7.0-b3-amd64-netboot/cleanup.sh +17 -0
- data/templates/Debian-7.0-b3-amd64-netboot/definition.rb +51 -0
- data/templates/Debian-7.0-b3-amd64-netboot/preseed.cfg +313 -0
- data/templates/Debian-7.0-b3-amd64-netboot/puppet.sh +2 -0
- data/templates/Debian-7.0-b3-amd64-netboot/ruby.sh +10 -0
- data/templates/Debian-7.0-b3-amd64-netboot/vagrant.sh +25 -0
- data/templates/Debian-7.0-b3-amd64-netboot/virtualbox.sh +13 -0
- data/templates/Debian-7.0-b3-amd64-netboot/zerodisk.sh +3 -0
- data/templates/Fedora-18-i386/definition.rb +17 -0
- data/templates/Fedora-18-i386/ks.cfg +75 -0
- data/templates/Fedora-18-i386/postinstall.sh +38 -0
- data/templates/Fedora-18-x86_64/definition.rb +17 -0
- data/templates/Fedora-18-x86_64/ks.cfg +75 -0
- data/templates/Fedora-18-x86_64/postinstall.sh +38 -0
- data/templates/OracleLinux-6.3-x86_64-DVD/base.sh +30 -0
- data/templates/OracleLinux-6.3-x86_64-DVD/chef.sh +3 -0
- data/templates/OracleLinux-6.3-x86_64-DVD/cleanup.sh +5 -0
- data/templates/OracleLinux-6.3-x86_64-DVD/definition.rb +40 -0
- data/templates/OracleLinux-6.3-x86_64-DVD/ks.cfg +42 -0
- data/templates/OracleLinux-6.3-x86_64-DVD/puppet.sh +12 -0
- data/templates/OracleLinux-6.3-x86_64-DVD/ruby.sh +3 -0
- data/templates/OracleLinux-6.3-x86_64-DVD/vagrant.sh +18 -0
- data/templates/OracleLinux-6.3-x86_64-DVD/virtualbox.sh +8 -0
- data/templates/OracleLinux-6.3-x86_64-DVD/zerodisk.sh +3 -0
- data/templates/funtoo-latest-x86_64/definition.rb +37 -0
- data/templates/funtoo-latest-x86_64/postinstall.sh +401 -0
- data/templates/openbsd50_amd64/definition.rb +3 -2
- data/templates/openbsd50_amd64/postinstall.sh +4 -4
- data/templates/openbsd50_i386/definition.rb +4 -4
- data/templates/openbsd52_amd64/README +28 -0
- data/templates/openbsd52_amd64/definition.rb +85 -0
- data/templates/openbsd52_amd64/postinstall.sh +81 -0
- data/templates/openbsd52_i386/README +28 -0
- data/templates/openbsd52_i386/definition.rb +85 -0
- data/templates/openbsd52_i386/postinstall.sh +81 -0
- data/templates/windows-2008R1-serverstandard-amd64/Autounattend.xml +6 -6
- data/templates/windows-2008R1-serverweb-amd64/install-winrm.bat +1 -1
- data/templates/windows-2008R2-serverstandard-amd64-winrm/Autounattend.xml +224 -0
- data/templates/windows-2008R2-serverstandard-amd64-winrm/README.md +87 -0
- data/templates/windows-2008R2-serverstandard-amd64-winrm/definition.rb +33 -0
- data/templates/windows-2008R2-serverstandard-amd64-winrm/install-chef.bat +2 -0
- data/templates/windows-2008R2-serverstandard-amd64-winrm/install-vbox.bat +4 -0
- data/templates/windows-2008R2-serverstandard-amd64-winrm/oracle-cert.cer +0 -0
- data/templates/windows-2008R2-serverstandard-amd64-winrm/postinstall.sh +74 -0
- data/templates/windows-7-enterprise-amd64-winrm/Autounattend.xml +227 -0
- data/templates/windows-7-enterprise-amd64-winrm/README.md +52 -0
- data/templates/windows-7-enterprise-amd64-winrm/definition.rb +27 -0
- data/templates/windows-7-enterprise-amd64-winrm/install-chef.bat +2 -0
- data/templates/windows-7-enterprise-amd64-winrm/install-fusion.bat +18 -0
- data/templates/windows-7-enterprise-amd64-winrm/install-puppet.bat +4 -0
- data/templates/windows-7-enterprise-amd64-winrm/install-vbox.bat +4 -0
- data/templates/windows-7-enterprise-amd64-winrm/oracle-cert.cer +0 -0
- data/templates/windows-7-enterprise-amd64-winrm/postinstall.bat +74 -0
- data/validation/veewee-windows.feature +34 -0
- data/veewee.gemspec +1 -1
- metadata +73 -7
@@ -5,6 +5,10 @@ module Veewee
|
|
5
5
|
|
6
6
|
def build(options={})
|
7
7
|
|
8
|
+
if definition.nil?
|
9
|
+
raise Veewee::Error,"Could not find the definition. Make sure you are one level above the definitions directory when you execute the build command."
|
10
|
+
end
|
11
|
+
|
8
12
|
# Requires valid definition
|
9
13
|
|
10
14
|
ui.info "Building Box #{name} with Definition #{definition.name}:"
|
@@ -74,6 +78,7 @@ module Veewee
|
|
74
78
|
sleep 2
|
75
79
|
end
|
76
80
|
|
81
|
+
|
77
82
|
self.transfer_buildinfo(options)
|
78
83
|
|
79
84
|
# Filtering post install files based upon --postinstall-include and --postinstall--exclude
|
@@ -81,9 +86,13 @@ module Veewee
|
|
81
86
|
|
82
87
|
self.handle_postinstall(options)
|
83
88
|
|
84
|
-
ui.success "The box #{name} was
|
89
|
+
ui.success "The box #{name} was build succesfully!"
|
85
90
|
ui.info "You can now login to the box with:"
|
86
|
-
|
91
|
+
if (definition.winrm_user && definition.winrm_password)
|
92
|
+
env.ui.info winrm_command_string
|
93
|
+
else
|
94
|
+
env.ui.info ssh_command_string
|
95
|
+
end
|
87
96
|
|
88
97
|
return self
|
89
98
|
end
|
@@ -165,11 +174,11 @@ module Veewee
|
|
165
174
|
kickstartfiles=definition.kickstart_file
|
166
175
|
|
167
176
|
if kickstartfiles.nil? || kickstartfiles.length == 0
|
168
|
-
ui.info "Skipping webserver as no kickstartfile was specified"
|
177
|
+
env.ui.info "Skipping webserver as no kickstartfile was specified"
|
178
|
+
else
|
179
|
+
env.ui.info "Starting a webserver #{definition.kickstart_ip}:#{definition.kickstart_port}\n"
|
169
180
|
end
|
170
181
|
|
171
|
-
ui.info "Starting a webserver #{definition.kickstart_ip}:#{definition.kickstart_port}\n"
|
172
|
-
|
173
182
|
# Check if the kickstart is an array or a single string
|
174
183
|
if kickstartfiles.is_a?(String)
|
175
184
|
# Let's turn it into an array
|
@@ -197,17 +206,23 @@ module Veewee
|
|
197
206
|
definition.postinstall_files.each do |postinstall_file|
|
198
207
|
# Filenames of postinstall_files are relative to their definition
|
199
208
|
filename=File.join(definition.path,postinstall_file)
|
200
|
-
self.
|
201
|
-
|
209
|
+
self.copy_to_box(filename,File.basename(filename))
|
210
|
+
if not (definition.winrm_user && definition.winrm_password)
|
211
|
+
self.exec("chmod +x \"#{File.basename(filename)}\"")
|
212
|
+
end
|
202
213
|
end
|
203
214
|
|
204
215
|
# Prepare a pre_poinstall file if needed (not nil , or not empty)
|
205
216
|
unless definition.pre_postinstall_file.to_s.empty?
|
206
217
|
pre_filename=File.join(definition.path, definition.pre_postinstall_file)
|
207
|
-
self.
|
208
|
-
|
209
|
-
|
210
|
-
|
218
|
+
self.copy_to_box(filename,File.basename(pre_filename))
|
219
|
+
if (definition.winrm_user && definition.winrm_password)
|
220
|
+
# not implemented on windows yet
|
221
|
+
else
|
222
|
+
self.exec("chmod +x \"#{File.basename(pre_filename)}\"")
|
223
|
+
# Inject the call to the real script by executing the first argument (it will be the postinstall script file name to be executed)
|
224
|
+
self.exec("execute=\"\\n# We must execute the script passed as the first argument\\n\\$1\" && printf \"%b\\n\" \"$execute\" >> #{File.basename(pre_filename)}")
|
225
|
+
end
|
211
226
|
end
|
212
227
|
|
213
228
|
# Now iterate over the postinstall files
|
@@ -218,14 +233,19 @@ module Veewee
|
|
218
233
|
unless File.basename(postinstall_file).start_with?("_")
|
219
234
|
|
220
235
|
unless definition.pre_postinstall_file.to_s.empty?
|
236
|
+
raise 'not implemented on windows yet' if (definition.winrm_user && definition.winrm_password)
|
221
237
|
# Filename of pre_postinstall_file are relative to their definition
|
222
238
|
pre_filename=File.join(definition.path, definition.pre_postinstall_file)
|
223
239
|
# Upload the pre postinstall script if not already transfered
|
224
240
|
command = "./" + File.basename(pre_filename)
|
225
241
|
command = sudo(command) + " ./"+File.basename(filename)
|
226
242
|
else
|
227
|
-
|
228
|
-
|
243
|
+
if (definition.winrm_user && definition.winrm_password)
|
244
|
+
# no sudo on windows, batch files only please?
|
245
|
+
self.exec(File.basename(filename))
|
246
|
+
else
|
247
|
+
self.exec(sudo("./"+File.basename(filename)))
|
248
|
+
end
|
229
249
|
end
|
230
250
|
|
231
251
|
self.exec(command)
|
@@ -249,7 +269,7 @@ module Veewee
|
|
249
269
|
infofile.puts "#{info[:content]}"
|
250
270
|
infofile.rewind
|
251
271
|
infofile.close
|
252
|
-
self.
|
272
|
+
self.copy_to_box(infofile.path,info[:filename])
|
253
273
|
infofile.delete
|
254
274
|
rescue RuntimeError => ex
|
255
275
|
ui.error("Error transfering file #{info[:filename]} failed, possible not enough permissions to write? #{ex}",:prefix => false)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Veewee
|
2
|
+
module Provider
|
3
|
+
module Core
|
4
|
+
module BoxCommand
|
5
|
+
|
6
|
+
def copy_to_box(localfile,remotefile,options={})
|
7
|
+
raise Veewee::Error,"Box is not running" unless self.running?
|
8
|
+
if definition.winrm_user && definition.winrm_password # prefer winrm
|
9
|
+
self.wincp(localfile,remotefile,options)
|
10
|
+
else
|
11
|
+
self.scp(localfile,remotefile,options)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end # Module
|
15
|
+
end # Module
|
16
|
+
end # Module
|
17
|
+
end # Module
|
@@ -8,25 +8,44 @@ module Veewee
|
|
8
8
|
"ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p #{ssh_options[:port]} -l #{definition.ssh_user} #{self.ip_address}"
|
9
9
|
end
|
10
10
|
|
11
|
+
def winrm_command_string
|
12
|
+
"knife winrm -m #{self.ip_address} -P #{winrm_options[:port]} -x #{definition.winrm_user}" +
|
13
|
+
" -P #{definition.winrm_password} COMMAND"
|
14
|
+
end
|
15
|
+
|
11
16
|
def exec(command,options={})
|
12
17
|
raise Veewee::Error,"Box is not running" unless self.running?
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
result=self.ssh_execute(self.ip_address,command,new_options)
|
18
|
+
if definition.winrm_user && definition.winrm_password
|
19
|
+
begin
|
20
|
+
new_options=winrm_options.merge(options)
|
21
|
+
self.when_winrm_login_works(self.ip_address,winrm_options.merge(options)) do
|
22
|
+
result = self.winrm_execute(self.ip_address,command,new_options)
|
19
23
|
return result
|
20
|
-
rescue RuntimeError => ex
|
21
|
-
error= "Error executing command #{command} : #{ex}"
|
22
|
-
error+="\n#{ex.backtrace.join("\n")}" unless ex.backtrace.empty?
|
23
|
-
raise Veewee::SshError, error
|
24
24
|
end
|
25
|
+
rescue RuntimeError => ex
|
26
|
+
env.ui.error "Error executing command #{command} : #{ex}"
|
27
|
+
raise Veewee::WinrmError, ex
|
28
|
+
end
|
29
|
+
else # definition.ssh_user && definition.ssh_password
|
30
|
+
begin
|
31
|
+
new_options=ssh_options.merge(options)
|
32
|
+
self.when_ssh_login_works(self.ip_address,new_options) do
|
33
|
+
begin
|
34
|
+
env.logger.info "About to execute remote command #{command} on box #{name} - #{self.ip_address} - #{new_options}"
|
35
|
+
result=self.ssh_execute(self.ip_address,command,new_options)
|
36
|
+
return result
|
37
|
+
rescue RuntimeError => ex
|
38
|
+
env.ui.error "Error executing command #{command} : #{ex}"
|
39
|
+
raise Veewee::SshError, ex
|
40
|
+
end
|
41
|
+
end
|
42
|
+
rescue Net::SSH::AuthenticationFailed => ex # may want to catch winrm auth fails as well
|
43
|
+
env.ui.error "Authentication failure"
|
44
|
+
raise Veewee::SshError, "Authentication failure\n"+ex
|
25
45
|
end
|
26
|
-
rescue Net::SSH::AuthenticationFailed => ex
|
27
|
-
raise Veewee::SshError, "Authentication failure\n"+ex
|
28
46
|
end
|
29
47
|
|
48
|
+
|
30
49
|
end
|
31
50
|
end # Module
|
32
51
|
end # Module
|
@@ -9,9 +9,13 @@ module Veewee
|
|
9
9
|
if options["force"]==true
|
10
10
|
self.poweroff
|
11
11
|
else
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
if definition.winrm_user && definition.winrm_password # prefer winrm
|
13
|
+
self.exec("#{definition.shutdown_cmd}")
|
14
|
+
else
|
15
|
+
self.exec("echo '#{definition.shutdown_cmd}' > /tmp/shutdown.sh")
|
16
|
+
self.exec("chmod +x /tmp/shutdown.sh")
|
17
|
+
self.exec(sudo("/tmp/shutdown.sh"))
|
18
|
+
end
|
15
19
|
end
|
16
20
|
else
|
17
21
|
raise Veewee::Error,"Box is not running"
|
@@ -6,7 +6,7 @@ module Veewee
|
|
6
6
|
def validate_tags(tags,options)
|
7
7
|
|
8
8
|
unless self.exists?
|
9
|
-
ui.error "Error:: You tried to validate box '#{name}' but it does not
|
9
|
+
ui.error "Error:: You tried to validate box '#{name}' but it does not exist"
|
10
10
|
exit -1
|
11
11
|
end
|
12
12
|
|
@@ -31,7 +31,13 @@ module Veewee
|
|
31
31
|
ENV['VEEWEE_BOXNAME']=@name
|
32
32
|
ENV['VEEWEE_PROVIDER']=@provider.name
|
33
33
|
|
34
|
-
|
34
|
+
if definition.winrm_user && definition.winrm_password # prefer winrm
|
35
|
+
featurefile="veewee-windows.feature"
|
36
|
+
else
|
37
|
+
featurefile="veewee.feature"
|
38
|
+
end
|
39
|
+
|
40
|
+
feature_path=File.join(File.dirname(__FILE__),"..","..","..","..","..","validation",featurefile)
|
35
41
|
|
36
42
|
features=Array.new
|
37
43
|
features[0]=feature_path
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'veewee/provider/core/helper/winrm'
|
2
|
+
module Veewee
|
3
|
+
module Provider
|
4
|
+
module Core
|
5
|
+
module BoxCommand
|
6
|
+
|
7
|
+
def wincp(localfile,remotefile,options={})
|
8
|
+
raise Veewee::Error,"Box is not running" unless self.running?
|
9
|
+
|
10
|
+
# Calculate an available kickstart port which we will use for wincp
|
11
|
+
definition.kickstart_port = "7000" if definition.kickstart_port.nil?
|
12
|
+
guessed_port=guess_free_port(definition.kickstart_port.to_i,7199).to_s
|
13
|
+
if guessed_port.to_s!=definition.kickstart_port
|
14
|
+
env.ui.warn "Changing wincp port from #{definition.kickstart_port} to #{guessed_port}"
|
15
|
+
definition.kickstart_port=guessed_port.to_s
|
16
|
+
end
|
17
|
+
|
18
|
+
if self.exec("cmd.exe /C dir #{wget_vbs_file} > %TEMP%\\null",{:exitcode=>"*"}).status != 0
|
19
|
+
env.ui.warn "Creating wget.vbs"
|
20
|
+
create_wget_vbs_command do |command_chunk, chunk_num|
|
21
|
+
self.exec("cmd.exe /C echo \"Rendering '#{wget_vbs_file}' chunk #{chunk_num}\" && #{command_chunk}")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
env.ui.warn "Spinning up a wait_for_http_request on http://#{host_ip_as_seen_by_guest}:#{definition.kickstart_port}#{localfile}"
|
27
|
+
webthread=allow_for_http_request(localfile,{
|
28
|
+
:port => definition.kickstart_port,
|
29
|
+
:host => definition.kickstart_ip,
|
30
|
+
:timeout => definition.kickstart_timeout,
|
31
|
+
:web_dir => '/'
|
32
|
+
})
|
33
|
+
|
34
|
+
begin
|
35
|
+
self.when_winrm_login_works(self.ip_address,winrm_options.merge(options)) do
|
36
|
+
env.ui.info "Going to try and copy #{localfile} to #{remotefile.inspect}"
|
37
|
+
self.exec("cmd.exe /C cscript %TEMP%\\wget.vbs /url:http://#{host_ip_as_seen_by_guest}:#{definition.kickstart_port}#{localfile} /path:#{remotefile}")
|
38
|
+
# while true do
|
39
|
+
# sleep 0.1 # used to debug
|
40
|
+
# end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
def wget_vbs_file
|
47
|
+
"%TEMP%\\\\wget.vbs"
|
48
|
+
end
|
49
|
+
|
50
|
+
def create_wget_vbs_command(&block)
|
51
|
+
bootstrap_bat = []
|
52
|
+
chunk_num = 0
|
53
|
+
wget_vbs.each_line do |line|
|
54
|
+
# escape WIN BATCH special chars
|
55
|
+
line.gsub!(/[(<|>)^]/).each{|m| "^#{m}"}
|
56
|
+
# windows commands are limited to 2047 characters
|
57
|
+
if((bootstrap_bat + [line]).join(" && ").size > 2047 )
|
58
|
+
yield bootstrap_bat.join(" && "), chunk_num += 1
|
59
|
+
bootstrap_bat = []
|
60
|
+
end
|
61
|
+
bootstrap_bat << ">> #{wget_vbs_file} (echo.#{line.chomp.strip})"
|
62
|
+
end
|
63
|
+
yield bootstrap_bat.join(" && "), chunk_num += 1
|
64
|
+
bootstrap_bat = []
|
65
|
+
end
|
66
|
+
|
67
|
+
def wget_vbs
|
68
|
+
wget_vbs = <<-WGET
|
69
|
+
url = WScript.Arguments.Named("url")
|
70
|
+
path = WScript.Arguments.Named("path")
|
71
|
+
Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")
|
72
|
+
Set wshShell = CreateObject( "WScript.Shell" )
|
73
|
+
Set objUserVariables = wshShell.Environment("USER")
|
74
|
+
|
75
|
+
'http proxy is optional
|
76
|
+
'attempt to read from HTTP_PROXY env var first
|
77
|
+
On Error Resume Next
|
78
|
+
|
79
|
+
If NOT (objUserVariables("HTTP_PROXY") = "") Then
|
80
|
+
objXMLHTTP.setProxy 2, objUserVariables("HTTP_PROXY")
|
81
|
+
|
82
|
+
'fall back to named arg
|
83
|
+
ElseIf NOT (WScript.Arguments.Named("proxy") = "") Then
|
84
|
+
objXMLHTTP.setProxy 2, WScript.Arguments.Named("proxy")
|
85
|
+
End If
|
86
|
+
|
87
|
+
On Error Goto 0
|
88
|
+
|
89
|
+
objXMLHTTP.open "GET", url, false
|
90
|
+
objXMLHTTP.send()
|
91
|
+
If objXMLHTTP.Status = 200 Then
|
92
|
+
Set objADOStream = CreateObject("ADODB.Stream")
|
93
|
+
objADOStream.Open
|
94
|
+
objADOStream.Type = 1
|
95
|
+
objADOStream.Write objXMLHTTP.ResponseBody
|
96
|
+
objADOStream.Position = 0
|
97
|
+
Set objFSO = Createobject("Scripting.FileSystemObject")
|
98
|
+
If objFSO.Fileexists(path) Then objFSO.DeleteFile path
|
99
|
+
Set objFSO = Nothing
|
100
|
+
objADOStream.SaveToFile path
|
101
|
+
objADOStream.Close
|
102
|
+
Set objADOStream = Nothing
|
103
|
+
End if
|
104
|
+
Set objXMLHTTP = Nothing
|
105
|
+
WGET
|
106
|
+
#escape_and_echo(win_wget)
|
107
|
+
wget_vbs
|
108
|
+
end
|
109
|
+
|
110
|
+
# escape WIN BATCH special chars
|
111
|
+
# and prefixes each line with an
|
112
|
+
# echo
|
113
|
+
def escape_and_echo(file_contents)
|
114
|
+
file_contents.gsub(/^(.*)$/, 'echo.\1').gsub(/([(<|>)^])/, '^\1')
|
115
|
+
end
|
116
|
+
|
117
|
+
end # Module
|
118
|
+
end # Module
|
119
|
+
end # Module
|
120
|
+
end # Module
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'veewee/provider/core/helper/winrm'
|
2
|
+
module Veewee
|
3
|
+
module Provider
|
4
|
+
module Core
|
5
|
+
module BoxCommand
|
6
|
+
|
7
|
+
|
8
|
+
def winrm(command=nil,options={})
|
9
|
+
|
10
|
+
raise Veewee::Error,"Box is not running" unless self.running?
|
11
|
+
winrm_options={:user => definition.winrm_user,:password => definition.winrm_password, :port => definition.winrm_host_port, :exitcode => '*'}
|
12
|
+
|
13
|
+
if (command.nil?)
|
14
|
+
env.ui.info "This is a simple interactive shell"
|
15
|
+
env.ui.info "To exit interactive mode, use 'quit!'"
|
16
|
+
|
17
|
+
while 1
|
18
|
+
command = ui.ask("veewee>")
|
19
|
+
case command.strip
|
20
|
+
when 'quit!'
|
21
|
+
env.ui.info 'Bye!'
|
22
|
+
break
|
23
|
+
else
|
24
|
+
winrm_execute(self.ip_address,command,winrm_options.merge(options))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
else
|
28
|
+
winrm_execute(self.ip_address,command,winrm_options.merge(options))
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
def winrm_options(options)
|
36
|
+
|
37
|
+
command_options = [
|
38
|
+
#"-q", #Suppress warning messages
|
39
|
+
# "-T", #Pseudo-terminal will not be allocated because stdin is not a terminal.
|
40
|
+
"-p #{winrm_options[:port]}",
|
41
|
+
"-o UserKnownHostsFile=/dev/null",
|
42
|
+
"-t -o StrictHostKeyChecking=no",
|
43
|
+
"-o IdentitiesOnly=yes",
|
44
|
+
"-o VerifyHostKeyDNS=no"
|
45
|
+
]
|
46
|
+
if !(definition.winrm_key.nil? || definition.winrm_key.length!="")
|
47
|
+
command_options << "-i #{definition.winrm_key}"
|
48
|
+
end
|
49
|
+
commandline_options="#{command_options.join(" ")} ".strip
|
50
|
+
|
51
|
+
user_option=definition.winrm_user.nil? ? "" : "-l #{definition.winrm_user}"
|
52
|
+
|
53
|
+
return "#{commandline_options} #{user_option}"
|
54
|
+
end
|
55
|
+
end # Module
|
56
|
+
end # Module
|
57
|
+
end # Module
|
58
|
+
end # Module
|
59
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Veewee
|
2
|
+
module Provider
|
3
|
+
module Core
|
4
|
+
module Helper
|
5
|
+
|
6
|
+
module Comm
|
7
|
+
|
8
|
+
def comm_method
|
9
|
+
if (definition.winrm_user && definition.winrm_password)
|
10
|
+
:winrm
|
11
|
+
else
|
12
|
+
:ssh
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def when_comm_login_works(ip="127.0.0.1", options = { } , &block)
|
17
|
+
case comm_method
|
18
|
+
when :winrm
|
19
|
+
when_winrm_login_works(ip,options,block)
|
20
|
+
when :ssh
|
21
|
+
when_ssh_login_works(ip,options,block)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def comm_transfer_file(host,filename,destination = '.' , options = {})
|
26
|
+
case comm_method
|
27
|
+
when :winrm
|
28
|
+
winrm_transfer_file(host,filename,destination,options)
|
29
|
+
when :ssh
|
30
|
+
ssh_transfer_file(host,filename,destination,options)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def comm_execute(host,command, options = { :progress => "on"} )
|
35
|
+
case comm_method
|
36
|
+
when :winrm
|
37
|
+
winrm_execute(host,command, options )
|
38
|
+
when :ssh
|
39
|
+
ssh_execute(host,command, options )
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end #Class
|
44
|
+
end #Module
|
45
|
+
end #Module
|
46
|
+
end #Module
|
47
|
+
end #Module
|