foreman/app/helpers/compute_resources_helper.rb @ 82e47ae0
334d0359 | Amos Benari | module ComputeResourcesHelper
|
|
include LookupKeysHelper
|
|||
def vm_state s
|
|||
82e47ae0 | Amos Benari | s ? " Off" : " On"
|
|
334d0359 | Amos Benari | end
|
|
def vm_power_class s
|
|||
82e47ae0 | Amos Benari | "class='label #{s ? "label-success" : ""}'"
|
|
334d0359 | Amos Benari | end
|
|
def vm_power_action vm
|
|||
opts = hash_for_power_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => vm.identity)
|
|||
82e47ae0 | Amos Benari | html = vm.ready? ? { :confirm => 'Are you sure?', :class => "btn btn-small btn-danger" } : { :class => "btn btn-small btn-info" }
|
|
334d0359 | Amos Benari | ||
82e47ae0 | Amos Benari | display_link_if_authorized "Power#{vm_state(vm.ready?)}", opts, html.merge(:method => :put)
|
|
334d0359 | Amos Benari | end
|
|
def memory_options max_memory
|
|||
gb = 1024*1024*1024
|
|||
opts = [0.25, 0.5, 0.75, 1, 2, 4, 8, 16]
|
|||
f37934af | Ohad Levy | opts.map{|n| [number_to_human_size(n*gb), (n*gb).to_i] unless n > (max_memory / gb)}.compact
|
|
334d0359 | Amos Benari | end
|
|
end
|