Revision b1813f28

View differences:

src/tm_mad/vcenter/mvds
1 1
#!/usr/bin/env ruby
2 2

  
3 3
# ---------------------------------------------------------------------------- #
4
# Copyright 2002-2016, OpenNebula Project, OpenNebula Systems                  #
4
# Copyright 2002-2017, OpenNebula Project, OpenNebula Systems                  #
5 5
#                                                                              #
6 6
# Licensed under the Apache License, Version 2.0 (the "License"); you may      #
7 7
# not use this file except in compliance with the License. You may obtain      #
......
57 57
disk_id = img_path.split(".")[-1]
58 58

  
59 59
disk = one_vm.retrieve_xmlelements("TEMPLATE/DISK[DISK_ID=#{disk_id}]").first
60
img_path = VCenterDriver::FileHelper.get_img_name(disk, vmid)
61 60

  
62 61
begin
63 62
    vi_client = VCenterDriver::VIClient.new_from_host(host_id)
......
66 65
    vm.one_item = one_vm
67 66

  
68 67
    vm.detach_disk(disk) if !vm.has_snapshots?
68

  
69 69
rescue Exception => e
70
    STDERR.puts "Error detaching virtual disk #{img_path} from vm #{vmid}."\
70
    STDERR.puts "Error detaching virtual disk #{disk_id} from vm #{vmid}."\
71 71
                " Reason: #{e.message}\n#{e.backtrace}"
72 72
    exit -1
73 73
ensure
74
    vi_client.close_connection
74
    vi_client.close_connection if vi_client
75 75
end

Also available in: Unified diff