Skip to content

Commit

Permalink
Remove v3 api form SSA
Browse files Browse the repository at this point in the history
Remove the usage of the ovirt gem and version 3 api from the SSA

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1535782
  • Loading branch information
Boris Odnopozov committed Jul 28, 2019
1 parent 7eb1f90 commit de7eb0e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
Expand Up @@ -151,7 +151,7 @@ def connect_to_ems(ost)
$log.info "#{log_header}: Connecting to [#{ems_display_text}] for VM:[#{@vm_cfg_file}]"

begin
ost.miqRhevm = ext_management_system.rhevm_inventory(:force_v3 => true)
ost.miqRhevm = ManageIQ::Providers::Redhat::Inventory::Collector.new(ext_management_system, nil)
$log.info "Connection to [#{ems_display_text}] completed for VM:[#{@vm_cfg_file}] in [#{Time.now - st}] seconds"
rescue Timeout::Error => err
msg = "#{log_header}: Connection to [#{ems_display_text}] timed out for VM:[#{@vm_cfg_file}] with error [#{err}] after [#{Time.now - st}] seconds"
Expand Down
36 changes: 36 additions & 0 deletions app/models/manageiq/providers/redhat/inventory/collector.rb
Expand Up @@ -157,4 +157,40 @@ def collect_dc_domains(dc)
connection.follow_link(dc.storage_domains)
end
end

def collect_vm_disks(vm)
manager.with_provider_connection(VERSION_HASH) do |connection|
disk_attachments = connection.follow_link(vm.disk_attachments)
disk_attachments.collect do |disk_attachment|
connection.follow_link(disk_attachment.disk)
end
end
end

def vm_or_template_by_path(path)
uuid = ::File.basename(path, '.*')
vm = vm_by_uuid(uuid)
vm = template_by_uuid(uuid) if vm.blank?
vm
end

def vm_by_uuid(uuid)
manager.with_provider_connection(VERSION_HASH) do |connection|
begin
connection.system_service.vms_service.vm_service(uuid).get
rescue OvirtSDK4::Error # when 404
nil
end
end
end

def template_by_uuid(uuid)
manager.with_provider_connection(VERSION_HASH) do |connection|
begin
connection.system_service.templates_service.template_service(uuid).get
rescue OvirtSDK4::Error # when 404
nil
end
end
end
end

0 comments on commit de7eb0e

Please sign in to comment.