Skip to content

Commit

Permalink
Remove using ovirt gem
Browse files Browse the repository at this point in the history
There were still places using the ovirt gem that uses the V3 rhv api.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1535782
  • Loading branch information
Boris Odnopozov committed Sep 2, 2019
1 parent 4a2cf3e commit d487a19
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions lib/metadata/VmConfig/VmConfig.rb
Expand Up @@ -478,10 +478,15 @@ def files(miqvm = nil)
end
elsif miqvm.rhevm
# First add the VM's active disk files.
miqvm.rhevmVm.disks.each { |disk| @files << rhevm_disk_file_entry(disk) }
disks = miqvm.rhevm.collect_vm_disks(miqvm.rhevmVm)
disks.each { |disk| @files << rhevm_disk_file_entry(disk) }
# Then add the files associtaed with inactive snapshots.
miqvm.rhevmVm.snapshots.each do |snap|
snap.disks.each { |disk| @files << rhevm_disk_file_entry(disk) unless snap[:type] == 'active' }
miqvm.rhevm.collect_snapshots(miqvm.rhevmVm).each do |snap|
next if snap.snapshot_type == 'active'

miqvm.rhevm.collect_disks_of_snapshot(snap).each do |disk|
@files << rhevm_disk_file_entry(disk)
end
end
end
rescue => err
Expand All @@ -493,12 +498,10 @@ def files(miqvm = nil)
end

def rhevm_disk_file_entry(disk)
storage_domain = disk[:storage_domains].first
storage_id = storage_domain && storage_domain[:id]
disk_key = disk[:image_id].blank? ? :id : :image_id
fullPath = storage_id && File.join('/dev', storage_id, disk[disk_key])

{:path => fullPath, :name => disk[disk_key], :size => disk[:actual_size].to_i}
storage_id = disk.storage_domains.first&.id
disk_id = disk.image_id || disk.id
full_path = storage_id && File.join('/dev', storage_id, disk_id)
{:path => full_path, :name => disk_id, :size => disk.actual_size.to_i}
end
private :rhevm_disk_file_entry

Expand Down Expand Up @@ -545,12 +548,12 @@ def disk_files(miqvm = nil)
end
end
elsif miqvm.rhevmVm
miqvm.rhevmVm.disks.each do |disk|
storage_domain = disk[:storage_domains].first
storage_id = storage_domain && storage_domain[:id]
disk_key = disk[:image_id].blank? ? :id : :image_id
fullPath = storage_id && File.join('/dev', storage_id, disk[disk_key])
d = {:path => fullPath, :name => disk[:name].to_s, :size => disk[:size].to_i}
disks = miqvm.rhevm.collect_vm_disks(miqvm.rhevmVm)
disks.each do |disk|
storage_id = disk.storage_domains.first&.id
disk_id = disk.image_id || disk.id
full_path = storage_id && File.join('/dev', storage_id, disk_id)
d = {:path => full_path, :name => disk.name.to_s, :size => disk.actual_size.to_i}
@disk_files << d
end
end
Expand Down

0 comments on commit d487a19

Please sign in to comment.