Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Commit

Permalink
Fix FileNotFound error on Windows
Browse files Browse the repository at this point in the history
 On Windows, the problem was that the URI detects the root drive (like C:) as the "host" of the URL and strips it out
  • Loading branch information
MichaelPereira committed Mar 30, 2016
1 parent 2bdca6c commit f4f397f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/rbvmomi/utils/deploy.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'open-uri'
require 'nokogiri'
require 'rbvmomi'
require 'os'

# The cached ovf deployer is an optimization on top of regular OVF deployment
# as it is offered by the VIM::OVFManager. Creating a VM becomes a multi-stage
Expand Down Expand Up @@ -105,8 +106,13 @@ def upload_ovf_as_template ovf_url, template_name, opts = {}

# If we're handling a file:// URI we need to strip the scheme as open-uri
# can't handle them.
if URI(ovf_url).scheme == "file" && URI(ovf_url).host.nil?
ovf_url = URI(ovf_url).path
if URI(ovf_url).scheme == "file"
if URI(ovf_url).host.nil?
ovf_url = URI(ovf_url).path
# Handle Windows case where the root drive letter is the "host"
elsif OS.windows?
ovf_url = URI(ovf_url).host + ":" + URI(ovf_url).path
end
end

ovf = open(ovf_url, 'r'){|io| Nokogiri::XML(io.read)}
Expand Down Expand Up @@ -311,4 +317,4 @@ def _wait_for_template_ready vm_folder, vm_name

vm
end
end
end

0 comments on commit f4f397f

Please sign in to comment.