From 9a8abaed33a9a7b9da586729814da14fe8adada9 Mon Sep 17 00:00:00 2001 From: Oleg Barenboim Date: Fri, 4 Jun 2021 14:54:14 -0400 Subject: [PATCH] Convert shelve operations to use SupportsFeatureMixin --- app/models/vm/operations/power.rb | 10 ++-------- app/models/vm_or_template/operations.rb | 16 ---------------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/app/models/vm/operations/power.rb b/app/models/vm/operations/power.rb index 2f648966739..3003b2ebba1 100644 --- a/app/models/vm/operations/power.rb +++ b/app/models/vm/operations/power.rb @@ -19,6 +19,8 @@ module Vm::Operations::Power end supports_not :pause + supports_not :shelve + supports_not :shelve_offload end def vm_powered_on? @@ -32,12 +34,4 @@ def validate_stop def validate_pause validate_vm_control_powered_on end - - def validate_shelve - validate_unsupported("Shelve Operation") - end - - def validate_shelve_offload - validate_unsupported("Shelve Offload Operation") - end end diff --git a/app/models/vm_or_template/operations.rb b/app/models/vm_or_template/operations.rb index e22caee2824..7b4ab061169 100644 --- a/app/models/vm_or_template/operations.rb +++ b/app/models/vm_or_template/operations.rb @@ -106,22 +106,6 @@ def log_user_event(user_event) # UI button validation methods # - def validate_vm_control_shelve_action - unless supports_control? - return {:available => false, :message => unsupported_reason(:control)} - end - return {:available => true, :message => nil} if %w(on off suspended paused).include?(current_state) - {:available => false, :message => "The VM can't be shelved, current state has to be powered on, off, suspended or paused"} - end - - def validate_vm_control_shelve_offload_action - unless supports_control? - return {:available => false, :message => unsupported_reason(:control)} - end - return {:available => true, :message => nil} if %w(shelved).include?(current_state) - {:available => false, :message => "The VM can't be shelved offload, current state has to be shelved"} - end - included do supports :control do msg = if retired?