diff --git a/SAS/ResourceAssignment/ResourceAssigner/lib/assignment.py b/SAS/ResourceAssignment/ResourceAssigner/lib/assignment.py index da923d87816494f3e7f77b817cb12600e32d244d..dccbbb3d8ca006de9fd28997e3210a3026541834 100755 --- a/SAS/ResourceAssignment/ResourceAssigner/lib/assignment.py +++ b/SAS/ResourceAssignment/ResourceAssigner/lib/assignment.py @@ -348,17 +348,8 @@ class ResourceAssigner(): self._sendStateChange(task, 'error') return if claims: - # 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) + # Complete the claims by annotating them with task information + self.tieClaimsToTask(claims, task) logger.info('doAssignment: inserting %d claims in the radb: %s', len(claims), claims) try: @@ -395,6 +386,21 @@ class ResourceAssigner(): # send notification that the task was 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): if status == 'scheduled' or status == 'conflict' or status == 'error': content={'radb_id': task['id'], 'otdb_id':task['otdb_id'], 'mom_id': task['mom_id']}