Revision 81295aa9 src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb
src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb | ||
---|---|---|
779 | 779 |
!device.class.ancestors.index(RbVmomi::VIM::VirtualEthernetCard).nil? |
780 | 780 |
end |
781 | 781 |
|
782 |
def device_change_disks |
|
782 |
def device_change_disks
|
|
783 | 783 |
disks = [] |
784 | 784 |
one_item.each("TEMPLATE/DISK") { |disk| disks << disk if !disk["OPENNEBULA_MANAGED"] } |
785 | 785 |
|
... | ... | |
787 | 787 |
@item["config.hardware.device"].each do |d| |
788 | 788 |
if is_disk_or_cdrom?(d) |
789 | 789 |
disks.each do |disk| |
790 |
img_name = VCenterDriver::FileHelper.get_img_name(disk, one_item['ID']) |
|
791 |
ds = get_effective_ds(disk) |
|
792 |
ds_name = ds['name'] |
|
790 |
backing = d.backing |
|
793 | 791 |
|
794 |
if d.backing.respond_to?(:fileName) && |
|
795 |
"[#{ds_name}] #{img_name}" == d.backing.fileName |
|
792 |
while backing.respond_to?(:parent) |
|
793 |
break if backing.parent.nil? |
|
794 |
backing = backing.parent |
|
795 |
end |
|
796 | 796 |
|
797 |
disks.delete(disk) |
|
797 |
if backing.respond_to?(:fileName) |
|
798 |
# Check if we are dealing with the unmanaged disks present in the template when cloned |
|
799 |
if disk["OPENNEBULA_MANAGED"] && disk["OPENNEBULA_MANAGED"] == "NO" |
|
800 |
img_name = one_item["USER_TEMPLATE/VCENTER_TEMPLATE_DISK_#{disk["DISK_ID"]}"] |
|
801 |
if img_name && backing.fileName == img_name |
|
802 |
disks.delete(disk) |
|
803 |
break |
|
804 |
end |
|
805 |
end |
|
806 |
|
|
807 |
# Alright let's see if we can find other devices only with the expected image name |
|
808 |
img_name = VCenterDriver::FileHelper.get_img_name(disk, one_item['ID'], self['name']) |
|
809 |
ds = get_effective_ds(disk) |
|
810 |
ds_name = ds['name'] |
|
811 |
if backing.fileName == "[#{ds_name}] #{img_name}" |
|
812 |
disks.delete(disk) |
|
813 |
break |
|
814 |
end |
|
798 | 815 |
end |
799 | 816 |
end |
800 | 817 |
end |
... | ... | |
885 | 902 |
end |
886 | 903 |
end |
887 | 904 |
|
888 |
# Get vcenter device representing DISK object (hotplug) |
|
905 |
# Get vcenter device representing DISK object (hotplug)
|
|
889 | 906 |
def disk_attached_to_vm(disk) |
890 |
img_name = VCenterDriver::FileHelper.get_img_name(disk, one_item['ID']) |
|
891 |
ds = get_effective_ds(disk) |
|
892 |
ds_name = ds['name'] |
|
893 |
|
|
907 |
img_name = "" |
|
894 | 908 |
device_found = nil |
895 | 909 |
@item["config.hardware.device"].each do |d| |
896 | 910 |
if is_disk_or_cdrom?(d) |
... | ... | |
902 | 916 |
backing = backing.parent |
903 | 917 |
end |
904 | 918 |
|
905 |
if backing.respond_to?(:fileName) && backing.fileName == "[#{ds_name}] #{img_name}" |
|
906 |
device_found = d |
|
907 |
break |
|
919 |
if backing.respond_to?(:fileName) |
|
920 |
# Check if we are dealing with the unmanaged disks present in the template when cloned |
|
921 |
if disk["OPENNEBULA_MANAGED"] && disk["OPENNEBULA_MANAGED"] == "NO" |
|
922 |
img_name = one_item["USER_TEMPLATE/VCENTER_TEMPLATE_DISK_#{disk["DISK_ID"]}"] |
|
923 |
if img_name && backing.fileName == img_name |
|
924 |
device_found = d |
|
925 |
break |
|
926 |
end |
|
927 |
else |
|
928 |
# Alright let's see if we can find other devices only with the expected image name |
|
929 |
img_name = VCenterDriver::FileHelper.get_img_name(disk, one_item['ID'], self['name']) |
|
930 |
ds = get_effective_ds(disk) |
|
931 |
ds_name = ds['name'] |
|
932 |
if backing.fileName == "[#{ds_name}] #{img_name}" |
|
933 |
device_found = d |
|
934 |
break |
|
935 |
end |
|
936 |
end |
|
908 | 937 |
end |
909 | 938 |
end |
910 | 939 |
end |
Also available in: Unified diff