diff --git a/lib/veewee/provider/core/box/wincp.rb b/lib/veewee/provider/core/box/wincp.rb index a7d6feaf..dcf1472a 100644 --- a/lib/veewee/provider/core/box/wincp.rb +++ b/lib/veewee/provider/core/box/wincp.rb @@ -23,18 +23,20 @@ def wincp(localfile,remotefile,options={}) 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,{ + localuri = localfile.gsub('\\','/').sub(/([a-zA-Z]):/, '\1') + localuri = localuri.start_with?('/') ? localuri : '/' + localuri + env.ui.warn "Spinning up a wait_for_http_request on http://#{host_ip_as_seen_by_guest}:#{definition.kickstart_port}#{localuri}" + webthread=allow_for_http_request(localfile, localuri,{ :port => definition.kickstart_port, :host => definition.kickstart_ip, :timeout => definition.kickstart_timeout, - :web_dir => '/' + :web_dir => "" }) 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}#{localuri} /path:#{remotefile}") # while true do # sleep 0.1 # used to debug # end diff --git a/lib/veewee/provider/core/helper/web.rb b/lib/veewee/provider/core/helper/web.rb index 1e8da85d..a43c291f 100644 --- a/lib/veewee/provider/core/helper/web.rb +++ b/lib/veewee/provider/core/helper/web.rb @@ -41,33 +41,32 @@ def do_GET(request,response) end module Web - def wait_for_http_request(filename,options) # original blocking - s = server_for_http_request(filename,options) + def wait_for_http_request(filename, fileuri, options) # original blocking + s = server_for_http_request(filename, fileuri, options) s.start end - def allow_for_http_request(filename,options) # start in new thread - s = server_for_http_request(filename,options.merge({:threaded => false})) + def allow_for_http_request(filename, fileuri, options) # start in new thread + s = server_for_http_request(filename, fileuri, options.merge({:threaded => false})) Thread.new { s.start } end - def server_for_http_request(filename,options={:timeout => 10, :web_dir => "", :port => 7125, :threaded => false}) + def server_for_http_request(filename, fileuri, options={:timeout => 10, :web_dir => "", :port => 7125, :threaded => false}) # Calculate the OS equivalent of /dev/null , on windows this is NUL: # http://www.ruby-forum.com/topic/115472 fn = test(?e, '/dev/null') ? '/dev/null' : 'NUL:' webrick_logger=WEBrick::Log.new(fn, WEBrick::Log::INFO) - web_dir=options[:web_dir] - filename=filename s= ::WEBrick::HTTPServer.new( :Port => options[:port], :Logger => webrick_logger, :AccessLog => webrick_logger ) - mount_filename = filename.start_with?('/') ? filename : "/#{filename}" - env.logger.debug("mounting file #{mount_filename}") - s.mount("#{mount_filename}", Veewee::Provider::Core::Helper::Servlet::FileServlet,File.join(web_dir,filename),ui,options[:threaded]) + + env.logger.debug("mounting file #{filename} for file #{fileuri}") + + s.mount("#{fileuri}", Veewee::Provider::Core::Helper::Servlet::FileServlet,filename,ui,options[:threaded]) trap("INT"){ s.shutdown ui.info "Stopping webserver"