From 69affff890e6b83d4ced8cde03c16c27f5fa6115 Mon Sep 17 00:00:00 2001 From: Marcel Hild Date: Wed, 22 Feb 2017 09:35:09 +0100 Subject: [PATCH] Changing ordering of checks of snapshot operations are supported only run specific checks if snapshorts are supported at all --- .../vm_or_template/operations/snapshot.rb | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/app/models/vm_or_template/operations/snapshot.rb b/app/models/vm_or_template/operations/snapshot.rb index 01aa72030f4..39d1746ad6c 100644 --- a/app/models/vm_or_template/operations/snapshot.rb +++ b/app/models/vm_or_template/operations/snapshot.rb @@ -3,27 +3,29 @@ module VmOrTemplate::Operations::Snapshot included do supports :snapshot_create do - unless supports_snapshots? - unsupported_reason_add(:snapshot_create, _("Create Snapshot operation not supported")) - end - unless supports_control? - unsupported_reason_add(:snapshot_create, unsupported_reason(:control)) - end - if !snapshots.blank? && snapshots.first.get_current_snapshot.nil? - unsupported_reason_add(:snapshot_create, _("At least one snapshot has to be active to create a new snapshot for this VM")) + if supports_snapshots? + if !snapshots.blank? && snapshots.first.get_current_snapshot.nil? + unsupported_reason_add(:snapshot_create, _("At least one snapshot has to be active to create a new snapshot for this VM")) + end + unless supports_control? + unsupported_reason_add(:snapshot_create, unsupported_reason(:control)) + end + else + unsupported_reason_add(:snapshot_create, _("Operation not supported")) end end supports :remove_snapshot do - unless supports_snapshots? + if supports_snapshots? + if snapshots.size <= 0 + unsupported_reason_add(:remove_snapshot, _("No snapshots available for this VM")) + end + unless supports_control? + unsupported_reason_add(:remove_snapshot, unsupported_reason(:control)) + end + else unsupported_reason_add(:remove_snapshot, _("Operation not supported")) end - if snapshots.size <= 0 - unsupported_reason_add(:remove_snapshot, _("No snapshots available for this VM")) - end - unless supports_control? - unsupported_reason_add(:remove_snapshot, unsupported_reason(:control)) - end end supports :remove_all_snapshots do