Skip to content

Commit

Permalink
Convert shelve operations to use SupportsFeatureMixin
Browse files Browse the repository at this point in the history
  • Loading branch information
chessbyte committed Jun 4, 2021
1 parent 616e28e commit 9a8abae
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 24 deletions.
10 changes: 2 additions & 8 deletions app/models/vm/operations/power.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ module Vm::Operations::Power
end

supports_not :pause
supports_not :shelve
supports_not :shelve_offload
end

def vm_powered_on?
Expand All @@ -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
16 changes: 0 additions & 16 deletions app/models/vm_or_template/operations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit 9a8abae

Please sign in to comment.