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 #584

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 @@ -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