mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-20 20:02:38 +09:00
F #4913: Get img_path for deletion from detach_disk action
This commit is contained in:
1 parent
93f270887f
commit
6142c4e08e
1 file changed
+5
-6
@@ -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
|
||||
Reference in new issue
Block a user