diff --git a/src/tm_mad/vcenter/delete b/src/tm_mad/vcenter/delete index bf233dd88d..6cc0403186 100755 --- a/src/tm_mad/vcenter/delete +++ b/src/tm_mad/vcenter/delete @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # ---------------------------------------------------------------------------- # -# Copyright 2002-2016, OpenNebula Project, OpenNebula Systems # +# Copyright 2002-2017, OpenNebula Project, OpenNebula Systems # # # # Licensed under the Apache License, Version 2.0 (the "License"); you may # # not use this file except in compliance with the License. You may obtain # @@ -69,14 +69,13 @@ if path.match(/disk\.\d+$/) # Detach and remove the disk # Get DS ref + dsid = img_path.split("/")[-3] # get dsid from path one_ds = VCenterDriver::VIHelper.one_item(OpenNebula::Datastore, dsid) ds_ref = one_ds['TEMPLATE/VCENTER_DS_REF'] - # Get image path + # Get disk info disk_id = img_path.split(".")[-1] - disk = one_vm.retrieve_xmlelements("TEMPLATE/DISK[DISK_ID=#{disk_id}]").first - img_path = VCenterDriver::FileHelper.get_img_name(disk, vmid) begin if !vm.has_snapshots? @@ -85,7 +84,7 @@ if path.match(/disk\.\d+$/) vm.one_item = one_vm # detach the disk - vm.detach_disk(disk) + ds_ref, img_path = vm.detach_disk(disk) # delete the disk ds = VCenterDriver::Datastore.new_from_ref(ds_ref, vi_client) @@ -112,6 +111,6 @@ else " Reason: #{e.message}\n#{e.backtrace}" exit -1 ensure - vi_client.close_connection + vi_client.close_connection if vi_client end end