mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
B #5409: Add check to avoid changing disks
in vCenter VMs if they have snapshots
This commit is contained in:
parent
4fc6623a64
commit
8348f361ad
@ -2415,6 +2415,15 @@ end
|
||||
|
||||
# Attach DISK to VM (hotplug)
|
||||
def attach_disk(disk)
|
||||
# Adding a new disk in newer vSphere versions
|
||||
# automatically cleans all system snapshots
|
||||
# https://github.com/OpenNebula/one/issues/5409
|
||||
if snapshots? or one_snapshots?
|
||||
error_message = 'Existing sytem snapshots, cannot change disks. '
|
||||
error_message << 'Please remove all snapshots and try again.'
|
||||
raise error_message
|
||||
end
|
||||
|
||||
spec_hash = {}
|
||||
device_change = []
|
||||
|
||||
@ -2596,6 +2605,12 @@ end
|
||||
def detach_disk(disk)
|
||||
return unless disk.exists?
|
||||
|
||||
if snapshots? or one_snapshots?
|
||||
error_message = 'Existing sytem snapshots, cannot change disks. '
|
||||
error_message << 'Please remove all snapshots and try again.'
|
||||
raise error_message
|
||||
end
|
||||
|
||||
spec_hash = {}
|
||||
spec_hash[:extraConfig] = [disk.config(:delete)]
|
||||
spec_hash[:deviceChange] = [{
|
||||
@ -2881,6 +2896,15 @@ end
|
||||
self['rootSnapshot'] && !self['rootSnapshot'].empty?
|
||||
end
|
||||
|
||||
def one_snapshots?
|
||||
begin
|
||||
!one_item['TEMPLATE/SNAPSHOT'].nil?
|
||||
rescue StandardError
|
||||
# one_item may not be retrieved if deploy_id hasn't been set
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def instantiated_as_persistent?
|
||||
begin
|
||||
!one_item['TEMPLATE/CLONING_TEMPLATE_ID'].nil?
|
||||
|
Loading…
x
Reference in New Issue
Block a user