Skip to content

Commit

Permalink
Merge pull request #223 from masayag/unregistervm
Browse files Browse the repository at this point in the history
Support Unregister VM
(cherry picked from commit f0dfe4f)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1552671
  • Loading branch information
pkliczewski authored and simaishi committed Mar 7, 2018
1 parent 7956b9b commit 1c5ef88
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
Expand Up @@ -505,6 +505,10 @@ def update_sysprep!(content)
def destroy
remove
end

def unregister
remove(:detach_only => true)
end
end

class TemplateProxyDecorator < SimpleDelegator
Expand Down
Expand Up @@ -8,4 +8,8 @@ module ManageIQ::Providers::Redhat::InfraManager::Vm::Operations
def raw_destroy
with_provider_object(&:destroy)
end

def raw_unregister
with_provider_object(&:unregister)
end
end
20 changes: 20 additions & 0 deletions spec/models/manageiq/providers/redhat/infra_manager/vm_spec.rb
Expand Up @@ -199,4 +199,24 @@
end
end
end

describe "#unregister" do
before do
_guid, _server, zone = EvmSpecHelper.create_guid_miq_server_zone
@ems = FactoryGirl.create(:ems_redhat_with_authentication, :zone => zone)
@vm = FactoryGirl.create(:vm_redhat, :ext_management_system => @ems)
@vm_proxy = double("OvirtSDK4::Vm.new")
@vm_service = double("OvirtSDK4::Vm")
end

context "v4" do
it "unregisters a vm via v4 api" do
allow(@ems).to receive(:highest_supported_api_version).and_return(4)
allow(@vm).to receive(:with_provider_object).and_yield(@vm_service)
allow(@vm_service).to receive(:unregister).and_return(nil)

@vm.raw_unregister
end
end
end
end

0 comments on commit 1c5ef88

Please sign in to comment.