summaryrefslogtreecommitdiffstats
path: root/nova/context.py
diff options
context:
space:
mode:
authorDan Smith <danms@us.ibm.com>2012-07-26 09:11:05 -0700
committerDan Smith <danms@us.ibm.com>2012-08-02 10:20:27 -0700
commit0c0e47b6ca2b88481891f742ee0e11cdef21c957 (patch)
treebc7e1b9d706d7eb4aec86e9fb6f778713f5a296c /nova/context.py
parent8583ce6bc0a6184c7f866bfd1ebfa7443da4b5f6 (diff)
downloadnova-0c0e47b6ca2b88481891f742ee0e11cdef21c957.tar.gz
nova-0c0e47b6ca2b88481891f742ee0e11cdef21c957.tar.xz
nova-0c0e47b6ca2b88481891f742ee0e11cdef21c957.zip
Check instance lock in compute/api
This adds a check for the instance lock in compute/api.py, which: 1. Helps avoid the need to call into the manager just to be stopped by the lock there 2. Returns a failure to the user right away when an operation cannot be completed due to the lock 3. Avoids the potential for task_state to get into an unhappy state because a user unknowingly attempts an action whilst an instance is locked 4. Avoids the manager from having to re-do the lock check by stuffing a flag into RequestContext when the check has already been done by api.py Various tests needed to be fixed up in order to pass fake instances with the locked attribute. We could make the decorator ignore instances without it, but I think it's more explicit to push that requirement into the tests. This fixes bug 872541 Change-Id: I1127e31d86a061a93a64ee1eb4a4d900d8bf49b5
Diffstat (limited to 'nova/context.py')
-rw-r--r--nova/context.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/nova/context.py b/nova/context.py
index 5712193fb..66697b567 100644
--- a/nova/context.py
+++ b/nova/context.py
@@ -45,7 +45,7 @@ class RequestContext(object):
roles=None, remote_address=None, timestamp=None,
request_id=None, auth_token=None, overwrite=True,
quota_class=None, user_name=None, project_name=None,
- service_catalog=None, **kwargs):
+ service_catalog=None, instance_lock_checked=False, **kwargs):
"""
:param read_deleted: 'no' indicates deleted records are hidden, 'yes'
indicates deleted records are visible, 'only' indicates that
@@ -81,6 +81,7 @@ class RequestContext(object):
self.request_id = request_id
self.auth_token = auth_token
self.service_catalog = service_catalog
+ self.instance_lock_checked = instance_lock_checked
# NOTE(markmc): this attribute is currently only used by the
# rs_limits turnstile pre-processor.
@@ -123,7 +124,8 @@ class RequestContext(object):
'quota_class': self.quota_class,
'user_name': self.user_name,
'service_catalog': self.service_catalog,
- 'project_name': self.project_name}
+ 'project_name': self.project_name,
+ 'instance_lock_checked': self.instance_lock_checked}
@classmethod
def from_dict(cls, values):