Revision e1907152
Added by Dmitri Dolguikh almost 10 years ago
app/helpers/compute_resources_vms_helper.rb | ||
---|---|---|
module ComputeResourcesVmsHelper
|
||
|
||
def vm_power_actions(vm)
|
||
def vm_power_actions(host, vm)
|
||
button_group(
|
||
if vm
|
||
html_opts = vm.ready? ? {:confirm => _('Are you sure?'), :class => "btn btn-danger"} : {:class => "btn btn-success"}
|
||
link_to_if_authorized _("Power%s") % state(vm.ready?), hash_for_power_host_path(:power_action => vm.ready? ? :stop : :start).merge(:auth_object => vm, :permission => 'power_hosts'),
|
||
link_to_if_authorized _("Power%s") % state(vm.ready?), hash_for_power_host_path(:power_action => vm.ready? ? :stop : :start).merge(:auth_object => host, :permission => 'power_hosts'),
|
||
html_opts.merge(:method => :put)
|
||
else
|
||
link_to(_("Unknown Power State"), '#', :disabled => true, :class => "btn btn-warning")
|
||
... | ... | |
)
|
||
end
|
||
|
||
def vm_console(vm)
|
||
def vm_console(host, vm)
|
||
if vm && vm.ready?
|
||
link_to_if_authorized(_("Console"), hash_for_console_host_path().merge(:auth_object => vm, :permission => 'console_hosts'),
|
||
link_to_if_authorized(_("Console"), hash_for_console_host_path().merge(:auth_object => host, :permission => 'console_hosts'),
|
||
{ :class => "btn btn-info" })
|
||
else
|
||
link_to(_("Console"), '#', {:disabled=> true, :class => "btn btn-info"})
|
Also available in: Unified diff
fixes #5994: Power and Console buttons are available to non-admin users with appropriate permissions
(cherry picked from commit 5aac54d7dbf15147c07d91d08b50f16496a291ae)