lib/veewee/provider/core/box/wincp.rb in veewee-0.3.12 vs lib/veewee/provider/core/box/wincp.rb in veewee-0.4.0
- old
+ new
@@ -1,6 +1,8 @@
+require 'to_slug'
require 'veewee/provider/core/helper/winrm'
+
module Veewee
module Provider
module Core
module BoxCommand
@@ -8,35 +10,39 @@
raise Veewee::Error,"Box is not running" unless self.running?
if self.exec("cmd.exe /C dir #{wget_vbs_file} > NUL",{:exitcode=>"*"}).status != 0
env.ui.warn "Creating wget.vbs"
create_wget_vbs_command do |command_chunk, chunk_num|
- self.exec("cmd.exe /C echo \"Rendering '#{wget_vbs_file}' chunk #{chunk_num}\" && #{command_chunk}")
+ self.exec(%Q!cmd.exe /C echo "Rendering #{wget_vbs_file} chunk #{chunk_num}" && #{command_chunk}!)
end
end
-
# Calculate an available kickstart port which we will use for wincp
definition.kickstart_port = "7000" if definition.kickstart_port.nil?
guessed_port=guess_free_port(definition.kickstart_port.to_i,7199).to_s
if guessed_port.to_s!=definition.kickstart_port
env.ui.warn "Changing wincp port from #{definition.kickstart_port} to #{guessed_port}"
definition.kickstart_port=guessed_port.to_s
end
- env.ui.warn "Spinning up a wait_for_http_request on http://#{host_ip_as_seen_by_guest}:#{definition.kickstart_port}#{localfile}"
- webthread=allow_for_http_request(localfile,{
- :port => definition.kickstart_port,
- :host => definition.kickstart_ip,
- :timeout => definition.kickstart_timeout,
- :web_dir => '/'
- })
+ urlpath = localfile.to_slug
+ urlpath = urlpath.start_with?('/') ? urlpath : '/' + urlpath
+ env.ui.warn "Spinning up an allow_for_http_request on http://#{host_ip_as_seen_by_guest}:#{definition.kickstart_port}#{localfile} at URL #{urlpath}"
+ allow_for_http_request(
+ localfile,
+ urlpath,
+ {
+ :port => definition.kickstart_port,
+ :host => definition.kickstart_ip,
+ :timeout => definition.kickstart_timeout,
+ }
+ )
begin
self.when_winrm_login_works(self.ip_address,winrm_options.merge(options)) do
env.ui.info "Going to try and copy #{localfile} to #{remotefile.inspect}"
- self.exec("cmd.exe /C cscript %TEMP%\\wget.vbs /url:http://#{host_ip_as_seen_by_guest}:#{definition.kickstart_port}#{localfile} /path:#{remotefile}")
+ self.exec("cmd.exe /C cscript %TEMP%\\wget.vbs /url:http://#{host_ip_as_seen_by_guest}:#{definition.kickstart_port}#{urlpath} /path:#{remotefile}")
# while true do
# sleep 0.1 # used to debug
# end
end
end
@@ -70,17 +76,17 @@
path = WScript.Arguments.Named("path")
Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")
Set wshShell = CreateObject( "WScript.Shell" )
Set objUserVariables = wshShell.Environment("USER")
-'http proxy is optional
-'attempt to read from HTTP_PROXY env var first
+rem http proxy is optional
+rem attempt to read from HTTP_PROXY env var first
On Error Resume Next
If NOT (objUserVariables("HTTP_PROXY") = "") Then
objXMLHTTP.setProxy 2, objUserVariables("HTTP_PROXY")
-'fall back to named arg
+rem fall back to named arg
ElseIf NOT (WScript.Arguments.Named("proxy") = "") Then
objXMLHTTP.setProxy 2, WScript.Arguments.Named("proxy")
End If
On Error Goto 0