From 245dc56c548bd9be46771b6e90444360ed72b86d Mon Sep 17 00:00:00 2001 From: mcabrerizo Date: Mon, 20 Feb 2017 13:43:09 +0100 Subject: [PATCH] F #4913: Add missing backtrace to rescue clause in VMM/DS actions --- src/datastore_mad/remotes/vcenter/clone | 3 ++- src/datastore_mad/remotes/vcenter/cp | 2 +- src/datastore_mad/remotes/vcenter/mkfs | 2 +- src/datastore_mad/remotes/vcenter/stat | 2 +- .../remotes/vcenter_downloader.rb | 2 +- src/datastore_mad/remotes/vcenter_uploader.rb | 2 +- .../lib/vcenter_driver/virtual_machine.rb | 18 +++++++++--------- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/datastore_mad/remotes/vcenter/clone b/src/datastore_mad/remotes/vcenter/clone index e5fdd74a24..6705b9e81a 100755 --- a/src/datastore_mad/remotes/vcenter/clone +++ b/src/datastore_mad/remotes/vcenter/clone @@ -76,6 +76,7 @@ begin puts ds.copy_virtual_disk(src_path, target_ds_name, target_path) rescue Exception => e - STDERR.puts "Error cloning img #{src_path}. Reason: #{e.message}" + STDERR.puts "Error cloning img #{src_path}."\ + " Reason: \"#{e.message}\"\n#{e.backtrace}" exit -1 end \ No newline at end of file diff --git a/src/datastore_mad/remotes/vcenter/cp b/src/datastore_mad/remotes/vcenter/cp index 9b07f99878..8633f87a17 100755 --- a/src/datastore_mad/remotes/vcenter/cp +++ b/src/datastore_mad/remotes/vcenter/cp @@ -77,7 +77,7 @@ if VCenterDriver::FileHelper.is_remote_or_needs_unpack?(img_path) temp_file = File.join(temp_folder, File.basename(target_path)) # Create tmp directory - FileUtils.mkdir_p(temp_folder) if !File.directory?(temp_folder) + FileUtils.mkdir_p(temp_folder) # Specify downloader args downsh_args = " " diff --git a/src/datastore_mad/remotes/vcenter/mkfs b/src/datastore_mad/remotes/vcenter/mkfs index 522bf7d8fe..3cec932448 100755 --- a/src/datastore_mad/remotes/vcenter/mkfs +++ b/src/datastore_mad/remotes/vcenter/mkfs @@ -82,6 +82,6 @@ begin puts ds.create_virtual_disk(img_name, size, adapter_type, disk_type) rescue Exception => e STDERR.puts "Error creating virtual disk #{img_src}."\ - " Reason: #{e.message}" + " Reason: \"#{e.message}\"\n#{e.backtrace}" exit -1 end diff --git a/src/datastore_mad/remotes/vcenter/stat b/src/datastore_mad/remotes/vcenter/stat index 618c89e8d6..9db2c3d02b 100755 --- a/src/datastore_mad/remotes/vcenter/stat +++ b/src/datastore_mad/remotes/vcenter/stat @@ -68,7 +68,7 @@ if img_path.start_with? "vcenter://" rescue Exception => e STDERR.puts "Error calculating image #{img_path} size."\ - " Reason: #{e.message}" + " Reason: \"#{e.message}\"\n#{e.backtrace}" exit -1 end else diff --git a/src/datastore_mad/remotes/vcenter_downloader.rb b/src/datastore_mad/remotes/vcenter_downloader.rb index 46d30c2b5e..87077e8a25 100755 --- a/src/datastore_mad/remotes/vcenter_downloader.rb +++ b/src/datastore_mad/remotes/vcenter_downloader.rb @@ -92,6 +92,6 @@ begin end rescue Exception => e STDERR.puts "Cannot download image #{u.path} from datastore #{ds_name} "\ - "on #{hostname}. Reason: #{e.message}" + "on #{hostname}. Reason: \"#{e.message}\"\n#{e.backtrace}" exit -1 end diff --git a/src/datastore_mad/remotes/vcenter_uploader.rb b/src/datastore_mad/remotes/vcenter_uploader.rb index 35901aa1d4..761ae4c870 100755 --- a/src/datastore_mad/remotes/vcenter_uploader.rb +++ b/src/datastore_mad/remotes/vcenter_uploader.rb @@ -50,7 +50,7 @@ begin puts target_path rescue Exception => e STDERR.puts "Cannot upload image to datastore #{ds_name} "\ - "Reason: #{e.message}" + "Reason: \"#{e.message}\"\n#{e.backtrace}" exit -1 end 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 9d9e0c758d..846d987ad4 100644 --- a/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb +++ b/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb @@ -272,7 +272,7 @@ class VirtualMachine :spec => clone_spec).wait_for_completion rescue Exception => e if !e.message.start_with?('DuplicateName') - raise "Cannot clone VM Template: #{e.message}" + raise "Cannot clone VM Template: #{e.message}\n#{e.backtrace}" end vm_folder = cluster.get_dc.vm_folder @@ -501,7 +501,7 @@ class VirtualMachine begin @item.ReconfigVM_Task(:spec => spec).wait_for_completion rescue Exception => e - raise "Cannot create snapshot for VM: #{e.message}" + raise "Cannot create snapshot for VM: #{e.message}\n#{e.backtrace}" end end @@ -644,7 +644,7 @@ class VirtualMachine begin @item.ReconfigVM_Task(:spec => spec).wait_for_completion rescue Exception => e - raise "Cannot attach NIC to VM: #{e.message}" + raise "Cannot attach NIC to VM: #{e.message}\n#{e.backtrace}" end end @@ -687,7 +687,7 @@ class VirtualMachine begin @item.ReconfigVM_Task(:spec => spec_hash).wait_for_completion rescue Exception => e - raise "Cannot detach NIC from VM: #{e.message}" + raise "Cannot detach NIC from VM: #{e.message}\n#{e.backtrace}" end end @@ -755,7 +755,7 @@ class VirtualMachine begin @item.ReconfigVM_Task(:spec => spec).wait_for_completion rescue Exception => e - raise "Cannot attach DISK to VM: #{e.message}" + raise "Cannot attach DISK to VM: #{e.message}\n#{e.backtrace}" end end @@ -783,7 +783,7 @@ class VirtualMachine begin @item.ReconfigVM_Task(:spec => spec_hash).wait_for_completion rescue Exception => e - raise "Cannot detach DISK to VM: #{e.message}" + raise "Cannot detach DISK to VM: #{e.message}\n#{e.backtrace}" end end @@ -1000,7 +1000,7 @@ class VirtualMachine begin @item.CreateSnapshot_Task(snapshot_hash).wait_for_completion rescue Exception => e - raise "Cannot create snapshot for VM: #{e.message}" + raise "Cannot create snapshot for VM: #{e.message}\n#{e.backtrace}" end return snapshot_name @@ -1018,7 +1018,7 @@ class VirtualMachine revert_snapshot_hash = { :_this => snapshot } snapshot.RevertToSnapshot_Task(revert_snapshot_hash).wait_for_completion rescue Exception => e - raise "Cannot revert snapshot of VM: #{e.message}" + raise "Cannot revert snapshot of VM: #{e.message}\n#{e.backtrace}" end end @@ -1037,7 +1037,7 @@ class VirtualMachine } snapshot.RemoveSnapshot_Task(delete_snapshot_hash).wait_for_completion rescue Exception => e - raise "Cannot delete snapshot of VM: #{e.message}" + raise "Cannot delete snapshot of VM: #{e.message}\n#{e.backtrace}" end end