From dffa2c023e6122e4e226ef0d699167050635789c Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Mon, 26 Feb 2018 10:39:37 +0100 Subject: [PATCH] Blocked in curl 404 --- src/datastore_mad/remotes/vcenter_downloader.rb | 3 +-- .../remotes/lib/vcenter_driver/datastore.rb | 16 +++++++++------- .../lib/vcenter_driver/virtual_machine.rb | 9 ++++++--- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/datastore_mad/remotes/vcenter_downloader.rb b/src/datastore_mad/remotes/vcenter_downloader.rb index ba9ca1e170..7911bbe957 100755 --- a/src/datastore_mad/remotes/vcenter_downloader.rb +++ b/src/datastore_mad/remotes/vcenter_downloader.rb @@ -16,7 +16,7 @@ # limitations under the License. # # ---------------------------------------------------------------------------- # -ONE_LOCATION=ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION) +ONE_LOCATION = ENV['ONE_LOCATION'] unless defined?(ONE_LOCATION) if !ONE_LOCATION RUBY_LIB_LOCATION="/usr/lib/one/ruby" if !defined?(RUBY_LIB_LOCATION) @@ -89,7 +89,6 @@ begin ds.download_to_stdout(img_src) end end - rescue Exception => e STDERR.puts "Cannot download image #{u.path} from datastore #{ds_id} "\ "Reason: \"#{e.message}\"\n#{e.backtrace}" diff --git a/src/vmm_mad/remotes/lib/vcenter_driver/datastore.rb b/src/vmm_mad/remotes/lib/vcenter_driver/datastore.rb index dc4d5b610c..0693382ae4 100644 --- a/src/vmm_mad/remotes/lib/vcenter_driver/datastore.rb +++ b/src/vmm_mad/remotes/lib/vcenter_driver/datastore.rb @@ -60,6 +60,8 @@ class Storage include Memoize + CURLBIN = "curl" + def self.new_from_ref(ref, vi_client) if ref.start_with?('group-') return VCenterDriver::StoragePod.new_from_ref(ref, vi_client) @@ -478,14 +480,14 @@ class Datastore < Storage end def generate_file_url(path) - protocol = self[_connection.http.use_ssl?] ? 'https://' : 'http://' - hostname = self[_connection.http.address] - port = self[_connection.http.port] + protocol = self["_connection.http.use_ssl?"] ? 'https://' : 'http://' + hostname = self["_connection.http.address"] + port = self["_connection.http.port"] dcpath = get_dc_path # This creates the vcenter file URL for uploading or downloading files # e.g: - url = "#{protocol}#{hostname}:#{port}/folder/#{path}?dcPath=#{dcpath}&dsName=#{self[name]}" + url = "#{protocol}#{hostname}:#{port}/folder/#{path}?dcPath=#{dcpath}&dsName=#{self['name']}" return url end @@ -493,7 +495,7 @@ class Datastore < Storage url = generate_file_url(remote_path) pid = spawn(CURLBIN, "-k", '--noproxy', '*', '-f', - "-b", self[_connection.cookie], + "-b", self["_connection.cookie"], url) Process.waitpid(pid, 0) @@ -506,7 +508,7 @@ class Datastore < Storage rout, wout = IO.pipe pid = spawn(CURLBIN, "-I", "-k", '--noproxy', '*', '-f', - "-b", _connection.cookie, + "-b", self["_connection.cookie"], url, :out => wout, :err => '/dev/null') @@ -527,7 +529,7 @@ class Datastore < Storage rout, wout = IO.pipe pid = spawn CURLBIN, "-k", '--noproxy', '*', '-f', - "-b", _connection.cookie, + "-b", self["_connection.cookie"], url, :out => wout, :err => '/dev/null' diff --git a/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb b/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb index 0be327998b..8a6372f763 100644 --- a/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb +++ b/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb @@ -1147,11 +1147,14 @@ class VirtualMachine < Template # @param one_item OpenNebula::VirtualMachine # @param vi_client VCenterDriver::VIClient # @return String vmware ref - def clone_vm(drv_action) + def clone_vm(drv_action, vi_client) + + @vi_client = vi_client + vcenter_name = get_vcenter_name vc_template_ref = drv_action['USER_TEMPLATE/VCENTER_TEMPLATE_REF'] - vc_template = RbVmomi::VIM::VirtualMachine(@vi_client.vim, vc_template_ref) + vc_template = RbVmomi::VIM::VirtualMachine(vi_client.vim, vc_template_ref) ds = get_ds @@ -1160,7 +1163,7 @@ class VirtualMachine < Template if ds.instance_of? RbVmomi::VIM::Datastore use_linked_clones = drv_action['USER_TEMPLATE/VCENTER_LINKED_CLONES'] - if use_linked_clones && use_linked_clones.downcase == "yes" + if use_linked_clones && use_linked_clones.downcase == 'yes' # Check if all disks in template has delta disks disks = vc_template.config .hardware.device.grep(RbVmomi::VIM::VirtualDisk)