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

Add supports terminate feature #598

Merged
merged 1 commit into from
May 29, 2020
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ module ManageIQ::Providers::Openstack::CloudManager::Vm::Operations
include_concern 'Relocation'
include_concern 'Snapshot'

included do
supports :terminate do
unsupported_reason_add(:terminate, unsupported_reason(:control)) unless supports_control?
end
end

def raw_destroy
raise "VM has no #{ui_lookup(:table => "ext_management_systems")}, unable to destroy VM" unless ext_management_system
with_notification(:vm_destroy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,21 @@
expect(vm.raw_power_state).to eq("ACTIVE")
end
end

describe "#supports_terminate?" do
context "when connected to a provider" do
it "returns true" do
expect(vm.supports_terminate?).to be_truthy
end
end

context "when not connected to a provider" do
let(:archived_vm) { FactoryBot.create(:vm_openstack) }

it "returns false" do
expect(archived_vm.supports_terminate?).to be_falsey
expect(archived_vm.unsupported_reason(:terminate)).to eq("The VM is not connected to an active Provider")
end
end
end
end