Scott Seago
2009-May-20 16:28 UTC
[Ovirt-devel] [PATCH server] don't add nil key to failures hash for PartialSuccessError handling.
In addition, removed unnecessary 'rescue' clauses and fixed a bug in a prior fix for this problem for the Permission and Network controllers. Signed-off-by: Scott Seago <sseago at redhat.com> --- src/app/controllers/application.rb | 2 +- src/app/controllers/network_controller.rb | 2 +- src/app/controllers/permission_controller.rb | 6 ++---- src/app/controllers/resources_controller.rb | 5 ++--- src/app/controllers/storage_controller.rb | 6 +++--- src/app/controllers/vm_controller.rb | 5 ++--- 6 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/app/controllers/application.rb b/src/app/controllers/application.rb index 040b8a3..e50f71e 100644 --- a/src/app/controllers/application.rb +++ b/src/app/controllers/application.rb @@ -77,7 +77,7 @@ class ApplicationController < ActionController::Base def handle_partial_success_error(error) failures_arr = error.failures.collect do |resource, reason| - if resource + if resource.respond_to?(:display_name) resource.display_name + ": " + reason else reason diff --git a/src/app/controllers/network_controller.rb b/src/app/controllers/network_controller.rb index eca8fab..c477c56 100644 --- a/src/app/controllers/network_controller.rb +++ b/src/app/controllers/network_controller.rb @@ -81,7 +81,7 @@ class NetworkController < ApplicationController successes << @network # PermissionError and ActionError are expected rescue Exception => ex - failures[@network.nil? network_id : @network] = ex.message + failures[@network.nil? ? network_id : @network] = ex.message end end unless failures.empty? diff --git a/src/app/controllers/permission_controller.rb b/src/app/controllers/permission_controller.rb index 9a62c62..da5286b 100644 --- a/src/app/controllers/permission_controller.rb +++ b/src/app/controllers/permission_controller.rb @@ -51,7 +51,7 @@ class PermissionController < ApplicationController successes << @permission # PermissionError and ActionError are expected rescue Exception => ex - failures[@permission.nil? permission_id : @permission] = ex.message + failures[@permission.nil? ? permission_id : @permission] = ex.message end end unless failures.empty? @@ -72,9 +72,7 @@ class PermissionController < ApplicationController successes << @permission # PermissionError expected rescue Exception => ex - failures[@permission.nil? permission_id : @permission] = ex.message - rescue Exception => ex - failures[@permission] = ex.message + failures[@permission.nil? ? permission_id : @permission] = ex.message end end unless failures.empty? diff --git a/src/app/controllers/resources_controller.rb b/src/app/controllers/resources_controller.rb index 6990df7..efd3cb6 100644 --- a/src/app/controllers/resources_controller.rb +++ b/src/app/controllers/resources_controller.rb @@ -80,10 +80,9 @@ class ResourcesController < PoolController begin svc_destroy(pool_id) successes << @pool - rescue PermissionError => perm_error - failures[@pool] = perm_error.message + # PermissionError expected rescue Exception => ex - failures[@pool] = ex.message + failures[@pool.nil? ? pool_id : @pool] = ex.message end end unless failures.empty? diff --git a/src/app/controllers/storage_controller.rb b/src/app/controllers/storage_controller.rb index dac2a6b..9a91288 100644 --- a/src/app/controllers/storage_controller.rb +++ b/src/app/controllers/storage_controller.rb @@ -135,10 +135,10 @@ class StorageController < ApplicationController begin svc_destroy(storage_pool_id) successes << @storage_pool - rescue PermissionError => perm_error - failures[@storage_pool] = perm_error.message + # PermissionError expected rescue Exception => ex - failures[@storage_pool] = ex.message + failures[@storage_pool.nil? ? storage_pool_id : + @storage_pool] = ex.message end end unless failures.empty? diff --git a/src/app/controllers/vm_controller.rb b/src/app/controllers/vm_controller.rb index 8165a85..4f38cc4 100644 --- a/src/app/controllers/vm_controller.rb +++ b/src/app/controllers/vm_controller.rb @@ -94,10 +94,9 @@ class VmController < ApplicationController begin svc_destroy(vm_id) successes << @vm - rescue PermissionError => perm_error - failures[@vm] = perm_error.message + # PermissionError expected rescue Exception => ex - failures[@vm] = ex.message + failures[@vm.nil? ? vm_id : @vm] = ex.message end end unless failures.empty? -- 1.6.0.6
David Lutterkort
2009-May-20 17:54 UTC
[Ovirt-devel] [PATCH server] don't add nil key to failures hash for PartialSuccessError handling.
On Wed, 2009-05-20 at 16:28 +0000, Scott Seago wrote:> In addition, removed unnecessary 'rescue' clauses and fixed a bug in a > prior fix for this problem for the Permission and Network controllers. > > Signed-off-by: Scott Seago <sseago at redhat.com>ACK. David
Reasonably Related Threads
- [PATCH server] final cleanup for service layer refactoring.
- [PATCH server] use service layer for Network controller.
- [PATCH server] Fix errors in controller tests.
- [PATCH server] Add svc_vm_actions method to VmService.
- [PATCH server] add network QMF apis. (still in progress)