Skip to content

Commit

Permalink
Merge pull request #584 from agrare/add_supports_terminate_feature
Browse files Browse the repository at this point in the history
Add supports terminate feature

(cherry picked from commit 2058f6c)
  • Loading branch information
chessbyte authored and simaishi committed May 29, 2020
1 parent bc69e90 commit bafcba3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module ManageIQ::Providers::Vmware::CloudManager::Vm::Operations

included do
supports :terminate do
unsupported_reason_add(:terminate, unsupported_reason(:control)) unless supports_control?
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 @@ -9,6 +9,12 @@ def raw_set_custom_field(attribute, value)
run_command_via_parent(:vm_set_custom_field, :attribute => attribute, :value => value)
end

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

def raw_clone(name, folder, pool = nil, host = nil, datastore = nil, powerOn = false, template_flag = false, transform = nil, config = nil, customization = nil, disk = nil)
folder_mor = folder.ems_ref_obj if folder.respond_to?(:ems_ref_obj)
pool_mor = pool.ems_ref_obj if pool.respond_to?(:ems_ref_obj)
Expand Down
17 changes: 17 additions & 0 deletions spec/models/manageiq/providers/vmware/infra_manager/vm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,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_vmware, :host => host) }

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

context "vim" do
let(:ems) { FactoryBot.create(:ems_vmware) }
let(:provider_object) do
Expand Down

0 comments on commit bafcba3

Please sign in to comment.