Module: OvirtComputeResourceHelper

Defined in:
app/helpers/ovirt_compute_resource_helper.rb

Instance Method Summary collapse

Instance Method Details

#ovirt_fake_vms_countObject

Really counting vms is as expensive as loading them all, especially when a filter is in place. So we create a fake count to get table pagination to work.



4
5
6
# File 'app/helpers/ovirt_compute_resource_helper.rb', line 4

def ovirt_fake_vms_count
  params['start'].to_i + 1 + [@vms.length, params['length'].to_i].min
end

#ovirt_storage_domains_for_select(compute_resource) ⇒ Object



8
9
10
# File 'app/helpers/ovirt_compute_resource_helper.rb', line 8

def ovirt_storage_domains_for_select(compute_resource)
  compute_resource.storage_domains.map { |sd| OpenStruct.new({ id: sd.id, label: "#{sd.name} (" + _("Available") + ": #{sd.available.to_i / 1.gigabyte} GiB, " + _("Used") + ": #{sd.used.to_i / 1.gigabyte} GiB)" }) }
end

#ovirt_vms_dataObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/helpers/ovirt_compute_resource_helper.rb', line 12

def ovirt_vms_data
  data = @vms.map do |vm|
    [
      link_to_if_authorized(html_escape(vm.name), hash_for_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => vm.id).merge(:auth_object => @compute_resource, :auth_action => 'view', :authorizer => authorizer)),
      vm.cores,
      number_to_human_size(vm.memory),
      "<span #{vm_power_class(vm.ready?)}>#{vm_state(vm)}</span>",
      action_buttons(vm_power_action(vm, authorizer),
        vm_import_action(vm), vm_associate_link(vm),
        display_delete_if_authorized(hash_for_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => vm.id).merge(:auth_object => @compute_resource, :authorizer => authorizer))),
    ]
  end
  JSON.fast_generate(data).html_safe
end