Skip to content

Commit

Permalink
Fix retirevms to account it being called for objects other than VMOrT…
Browse files Browse the repository at this point in the history
…emplate
  • Loading branch information
lgalis committed Apr 3, 2017
1 parent 4425e78 commit e3b7439
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/controllers/application_controller/ci_processing.rb
Expand Up @@ -215,7 +215,8 @@ def ownership_update
# Retire 1 or more VMs
def retirevms
assert_privileges(params[:pressed])
vms = find_checked_ids_with_rbac(VmOrTemplate)
klass = get_class_from_controller_param(params[:controller])
vms = find_checked_ids_with_rbac(klass)
if !%w(orchestration_stack service).include?(request.parameters["controller"]) && !%w(orchestration_stacks).include?(params[:display]) &&
VmOrTemplate.find(vms).any? { |vm| !vm.supports_retire? }
add_flash(_("Set Retirement Date does not apply to selected %{model}") %
Expand Down Expand Up @@ -1831,7 +1832,8 @@ def vm_button_operation(method, display_name, partial_after_single_selection = n
request.parameters["controller"]) # showing a list

# FIXME retrieving vms from DB two times
vms = find_checked_ids_with_rbac(VmOrTemplate)
klass = get_class_from_controller_param(request.parameters["controller"])
vms = find_checked_ids_with_rbac(klass)
if method == 'retire_now' &&
!%w(orchestration_stack service).include?(request.parameters["controller"]) &&
VmOrTemplate.find(vms).any? { |vm| !vm.supports_retire? }
Expand Down

0 comments on commit e3b7439

Please sign in to comment.