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.
6 7 8 |
# File 'app/helpers/ovirt_compute_resource_helper.rb', line 6 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
10 11 12 13 14 15 16 17 |
# File 'app/helpers/ovirt_compute_resource_helper.rb', line 10 def ovirt_storage_domains_for_select(compute_resource) compute_resource.storage_domains.map do |sd| avail = sd.available.to_i / 1.gigabyte used = sd.used.to_i / 1.gigabyte OpenStruct.new({ id: sd.id, label: "#{sd.name} (" + _('Available') + ": #{avail} GiB, " + _('Used') + ": #{used} GiB)" }) end end |
#ovirt_vms_data ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/helpers/ovirt_compute_resource_helper.rb', line 19 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 # rubocop:disable Rails/OutputSafety end |