Skip to content

Commit

Permalink
Use utility function vm_powered_on? instead manual comparison
Browse files Browse the repository at this point in the history
With this commit we replace manual comparison of status with
utility function. The logic is a bit more bullet-proof now since
we now only prevent VM delete when VM is "ON" while we originally
only allowed delete when VM was "OFF". So effectively we now allow
VM delete even if status is e.g. "unknown" which I think should succeed.

Signed-off-by: Miha Pleško <miha.plesko@xlab.si>
  • Loading branch information
miha-plesko committed Mar 2, 2018
1 parent e1fcf19 commit ffe13b2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module ManageIQ::Providers::Vmware::CloudManager::Vm::Operations

included do
supports :terminate do
unsupported_reason_add(:terminate, "The VM is powered on") unless current_state == "off"
unsupported_reason_add(:terminate, "The VM is powered on") if vm_powered_on?
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
let(:state) { :standby_guest }
include_examples "Vm operation is not available"
end

context("with :terminate") do
let(:state) { :terminate }
include_examples "Vm operation is available when not powered on"
end
end

context "when destroyed" do
Expand Down

0 comments on commit ffe13b2

Please sign in to comment.