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

Check EmsEvents when disconnecting storage #336

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 @@ -2,6 +2,7 @@ module ManageIQ::Providers::Vmware::InfraManager::VmOrTemplateShared
extend ActiveSupport::Concern
include_concern 'RefreshOnScan'
include_concern 'Scanning'
include_concern 'Disconnect'

POWER_STATES = {
"poweredOn" => "on",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module ManageIQ::Providers::Vmware::InfraManager::VmOrTemplateShared::Disconnect
extend ActiveSupport::Concern

def disconnect_storage
# If the VM was unregistered don't clear the storage because the disks
# are still on the underlying datastore
super unless unregistered?
end

def destroyed?
disconnect_events.last&.event_type == "DestroyVM_Task_Complete"
end

def unregistered?
disconnect_events.last&.event_type == "UnregisterVM_Complete"
end

private

def disconnect_events
ems_events.where(:event_type => disconnect_event_types)
end

def disconnect_event_types
%w(DestroyVM_Task_Complete UnregisterVM_Complete)
end
end