Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
40183dc0
Commit
40183dc0
authored
8 years ago
by
Jan David Mol
Browse files
Options
Downloads
Patches
Plain Diff
Task #10801: Move claim annotation to separate function
parent
b7eadf1f
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
SAS/ResourceAssignment/ResourceAssigner/lib/assignment.py
+17
-11
17 additions, 11 deletions
SAS/ResourceAssignment/ResourceAssigner/lib/assignment.py
with
17 additions
and
11 deletions
SAS/ResourceAssignment/ResourceAssigner/lib/assignment.py
+
17
−
11
View file @
40183dc0
...
@@ -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
'
]}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment