Skip to content

Commit

Permalink
Merge pull request #497 from agrare/add_supports_terminate_feature
Browse files Browse the repository at this point in the history
Add supports terminate feature
  • Loading branch information
chessbyte authored May 29, 2020
2 parents c79c3b0 + ba9b1f5 commit d48b57f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ module ManageIQ::Providers::Redhat::InfraManager::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
with_provider_object(&:destroy)
end
Expand Down
23 changes: 20 additions & 3 deletions spec/models/manageiq/providers/redhat/infra_manager/vm_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
describe ManageIQ::Providers::Redhat::InfraManager::Vm do
let(:ip_address) { '192.168.1.31' }
let(:ems) { FactoryBot.create(:ems_redhat) }
let(:host) { FactoryBot.create(:host_redhat, :ext_management_system => ems) }
let(:vm) { FactoryBot.create(:vm_redhat, :ext_management_system => ems, :host => host) }

context "#is_available?" do
let(:ems) { FactoryBot.create(:ems_redhat) }
let(:host) { FactoryBot.create(:host_redhat, :ext_management_system => ems) }
let(:vm) { FactoryBot.create(:vm_redhat, :ext_management_system => ems, :host => host) }
let(:power_state_on) { "up" }
let(:power_state_suspended) { "down" }

Expand Down Expand Up @@ -149,6 +149,23 @@
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_redhat) }

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

describe "#unregister" do
before do
_guid, _server, zone = EvmSpecHelper.create_guid_miq_server_zone
Expand Down

0 comments on commit d48b57f

Please sign in to comment.