Module: OvirtComputeResourceHelper
- Defined in:
- app/helpers/ovirt_compute_resource_helper.rb
Instance Method Summary collapse
-
#ovirt_fake_vms_count ⇒ Object
Really counting vms is as expensive as loading them all, especially when a filter is in place.
- #ovirt_storage_domains_for_select(compute_resource) ⇒ Object
- #ovirt_vms_data ⇒ Object
Instance Method Details
#ovirt_fake_vms_count ⇒ Object
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_data ⇒ Object
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| [ (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 => )), vm.cores, number_to_human_size(vm.memory), "<span #{vm_power_class(vm.ready?)}>#{vm_state(vm)}</span>", (vm_power_action(vm, ), vm_import_action(vm), vm_associate_link(vm), (hash_for_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => vm.id).merge(:auth_object => @compute_resource, :authorizer => ))), ] end JSON.fast_generate(data).html_safe end |