Skip to content
Snippets Groups Projects
Commit 40183dc0 authored by Jan David Mol's avatar Jan David Mol
Browse files

Task #10801: Move claim annotation to separate function

parent b7eadf1f
No related branches found
No related tags found
No related merge requests found
...@@ -348,17 +348,8 @@ class ResourceAssigner(): ...@@ -348,17 +348,8 @@ class ResourceAssigner():
self._sendStateChange(task, 'error') self._sendStateChange(task, 'error')
return return
if claims: if claims:
# add start/endtime to claims # Complete the claims by annotating them with task information
for claim in claims: self.tieClaimsToTask(claims, task)
claim['starttime'] = task['starttime']
claim['endtime'] = task['endtime']
if claim['resource_type_id'] == self.resource_types['storage']:
# FIXME: find proper way to extend storage time with a year
# 2016-09-27 scisup would like to be involved in chosing these kind of defaults
# and what to do after the claim expires
# we now choose a default period of a year, and do nothing if the claim expires
claim['endtime'] += timedelta(days=365)
logger.info('doAssignment: inserting %d claims in the radb: %s', len(claims), claims) logger.info('doAssignment: inserting %d claims in the radb: %s', len(claims), claims)
try: try:
...@@ -395,6 +386,21 @@ class ResourceAssigner(): ...@@ -395,6 +386,21 @@ class ResourceAssigner():
# send notification that the task was scheduled # send notification that the task was scheduled
self._sendStateChange(task, 'scheduled') self._sendStateChange(task, 'scheduled')
def tieClaimsToTask(self, claims, task):
""" Complete a set of claims by annotating them with task-related information. """
# add start/endtime to claims
for claim in claims:
claim['starttime'] = task['starttime']
claim['endtime'] = task['endtime']
if claim['resource_type_id'] == self.resource_types['storage']:
# FIXME: find proper way to extend storage time with a year
# 2016-09-27 scisup would like to be involved in chosing these kind of defaults
# and what to do after the claim expires
# we now choose a default period of a year, and do nothing if the claim expires
claim['endtime'] += timedelta(days=365)
def _sendStateChange(self, task, status): def _sendStateChange(self, task, status):
if status == 'scheduled' or status == 'conflict' or status == 'error': if status == 'scheduled' or status == 'conflict' or status == 'error':
content={'radb_id': task['id'], 'otdb_id':task['otdb_id'], 'mom_id': task['mom_id']} content={'radb_id': task['id'], 'otdb_id':task['otdb_id'], 'mom_id': task['mom_id']}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment