Skip to content

Commit

Permalink
Storage removal
Browse files Browse the repository at this point in the history
Datastores can't be removed if there are relations to hosts or vms.
We need provide a way to check whether datastore removal is supported
(no vm or host relations). When there condition is not met we need
to notify a user that relations needs to be removed first.

This PR fixes:
https://bugzilla.redhat.com/1439380
  • Loading branch information
pkliczewski committed Apr 12, 2017
1 parent 0556af1 commit 2cfe2cf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/controllers/application_controller/ci_processing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2744,9 +2744,15 @@ def configuration_job_delete
# Delete all selected or single displayed datastore(s)
def deletestorages
assert_privileges("storage_delete")
storages = find_checked_ids_with_rbac(Storage)
unless Storage.batch_operation_supported?('delete', storages)
add_flash(_("Only storage without VMs and Hosts can be removed"), :error)
return
end

datastores = []
if %w(show_list storage_list storage_pod_list).include?(@lastaction) || (@lastaction == "show" && @layout != "storage") # showing a list, scan all selected hosts
datastores = find_checked_ids_with_rbac(Storage)
datastores = storages
if datastores.empty?
add_flash(_("No %{model} were selected for %{task}") % {:model => ui_lookup(:tables => "storage"), :task => display_name}, :error)
end
Expand Down

0 comments on commit 2cfe2cf

Please sign in to comment.