Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixup URL generation under windows when retreiving files from guest #627

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/veewee/provider/core/box/wincp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 9 additions & 10 deletions lib/veewee/provider/core/helper/web.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down