summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrey Morris <trey.morris@rackspace.com>2010-12-29 13:33:51 -0600
committerTrey Morris <trey.morris@rackspace.com>2010-12-29 13:33:51 -0600
commit0afb4a06dcb94ae41d04b3d78304746b0cc5b26f (patch)
tree15acd853b027a38a32b3049697b0dc8e5a85548f
parentb6e5c68d65701b840006cea49367879ee88c9b80 (diff)
refactor
-rw-r--r--nova/api/openstack/servers.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py
index 8b837e6fc..292a664b7 100644
--- a/nova/api/openstack/servers.py
+++ b/nova/api/openstack/servers.py
@@ -58,14 +58,15 @@ def checks_lock(function):
req = args[2]
context = req.environ['nova.context']
except:
- logging.error(_("CheckLock: argument error"))
-
- # if locked and admin call function, otherwise 404
- if(compute_api.ComputeAPI().get_lock(context, _id)):
- if(req.environ['nova.context'].is_admin):
- function(*args, **kwargs)
- # return 404
- return faults.Fault(exc.HTTPUnprocessableEntity())
+ logging.error(_("CheckLock: argument error: |%s|, |%s|"), args,
+ kwargs)
+ # if admin or unlocked call function, otherwise 404
+ locked = compute_api.ComputeAPI().get_lock(context, _id)
+ admin = req.environ['nova.context'].is_admin
+ if(admin or not locked):
+ return function(*args, **kwargs)
+
+ return faults.Fault(exc.HTTPNotFound())
return decorated_function