Skip to content

Commit

Permalink
Merge pull request #62 from pkliczewski/master
Browse files Browse the repository at this point in the history
disconnect_storage should be called once
(cherry picked from commit c1257ddd0e200d76a316de03261bf92c2a8cfbfa)

https://bugzilla.redhat.com/show_bug.cgi?id=1479481
  • Loading branch information
oourfali authored and simaishi committed Aug 8, 2017
1 parent c3d20fa commit 1a0907b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions app/models/manageiq/providers/redhat/infra_manager/vm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,25 @@ def parent_cluster
alias ems_cluster parent_cluster

def disconnect_storage(_s = nil)
unless active?
return
end
vm_disks = collect_disks
return unless active?

if vm_disks.blank?
storage = nil
else
vm_storages = ([storage] + storages).compact.uniq
storage = vm_storages.select { |store| !vm_disks.include?(store.ems_ref) }
end
vm_storages = ([storage] + storages).compact.uniq
return if vm_storages.empty?

vm_disks = collect_disks
storage = vm_disks.blank? ? nil : vm_storages.select { |store| !vm_disks.include?(store.ems_ref) }

super(storage)
end

def collect_disks
return [] if hardware.nil?
disks = hardware.disks.map { |disk| "#{disk.storage.ems_ref}/disks/#{disk.filename}" }
ext_management_system.ovirt_services.collect_disks_by_hrefs(disks)
disks = hardware.disks.map do |disk|
unless disk.storage.nil?
"#{disk.storage.ems_ref}/disks/#{disk.filename}"
end
end
ext_management_system.ovirt_services.collect_disks_by_hrefs(disks.compact)
end

def disconnect_inv
Expand Down

0 comments on commit 1a0907b

Please sign in to comment.