Fix sessions: session_tag
1- Remove session_tag override 2- cast session tag to int while checking Change-Id: Ie44a4826f0bc2d8614cb5eedd6a622a30b6b6e23
This commit is contained in:
@@ -157,11 +157,11 @@ class Session(resource.BaseResource):
|
||||
|
||||
@property
|
||||
def session_tag(self):
|
||||
return self.doc.get('session_tag', 0)
|
||||
return int(self.doc.get('session_tag', 0))
|
||||
|
||||
@session_tag.setter
|
||||
def session_tag(self, value):
|
||||
self.doc['session_tag'] = value
|
||||
self.doc['session_tag'] = int(value)
|
||||
|
||||
def execute_action(self, action, params):
|
||||
if action == 'start':
|
||||
@@ -206,11 +206,15 @@ class Session(resource.BaseResource):
|
||||
and sets the need_update member to notify that the stored
|
||||
document needs to be updated
|
||||
"""
|
||||
job_tag = int(job_tag)
|
||||
self.session_tag = int(self.session_tag)
|
||||
now = int(time.time())
|
||||
time_since_last_start = now - self.doc.get('time_start', 0)
|
||||
|
||||
if job_tag > self.session_tag:
|
||||
raise freezer_api_exc.BadDataFormat('requested tag value too high')
|
||||
raise freezer_api_exc.BadDataFormat(
|
||||
'requested tag value too high. Session Tag: {0} '
|
||||
'Job Tag: {1}'.format(self.session_tag, job_tag))
|
||||
|
||||
if time_since_last_start <= self.doc.get('hold_off', 60):
|
||||
# session has been started not so long ago
|
||||
|
||||
@@ -187,7 +187,7 @@ class SessionDoc(object):
|
||||
doc.update({
|
||||
'user_id': user_id,
|
||||
'session_id': uuid.uuid4().hex,
|
||||
'session_tag': 0,
|
||||
'session_tag': doc.get('session_tag', 0),
|
||||
'status': 'active',
|
||||
'last_start': '',
|
||||
'jobs': []
|
||||
|
||||
Reference in New Issue
Block a user