Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing ordering of checks to see if snapshot operations are supported #14014

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions app/models/vm_or_template/operations/snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down