Skip to content

Commit

Permalink
Merge pull request #21260 from chessbyte/use_supports_feature_mixin_f…
Browse files Browse the repository at this point in the history
…or_shelve_operations

Convert shelve operations to use SupportsFeatureMixin
  • Loading branch information
agrare authored Jun 11, 2021
2 parents 5c54ed6 + 9a8abae commit 1425734
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 1425734

Please sign in to comment.