Skip to content
GitLab
Explore
Sign in
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
3e8de401
Commit
3e8de401
authored
8 years ago
by
Jorrit Schaap
Browse files
Options
Downloads
Patches
Plain Diff
Task #8887: added TaskGetStatus
parent
d9239d58
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
SAS/OTDB_Services/TreeService.py
+14
-0
14 additions, 0 deletions
SAS/OTDB_Services/TreeService.py
SAS/ResourceAssignment/RAtoOTDBTaskSpecificationPropagator/lib/otdbrpc.py
+6
-39
6 additions, 39 deletions
...gnment/RAtoOTDBTaskSpecificationPropagator/lib/otdbrpc.py
with
20 additions
and
39 deletions
SAS/OTDB_Services/TreeService.py
+
14
−
0
View file @
3e8de401
...
...
@@ -222,6 +222,15 @@ def TaskCreate(input_dict, db_connection):
# When we are here we always have a task, so do the key updates
return
TaskSetSpecification
({
'
OtdbID
'
:
otdb_id
,
'
Specification
'
:
input_dict
[
'
Specification
'
]},
db_connection
)
# Task Get State
def
TaskGetStatus
(
otdb_id
,
db_connection
):
result
=
db_connection
.
query
(
"""
select treestate.id, treestate.name from otdbtree
inner join treestate on treestate.id = otdbtree.state
where otdbtree.treeid = %s
"""
%
(
otdb_id
,)).
getresult
()
if
result
:
return
{
'
OtdbID
'
:
otdb_id
,
'
status_id
'
:
result
[
0
][
0
],
'
status
'
:
result
[
0
][
1
]}
return
{
'
OtdbID
'
:
otdb_id
,
'
status_id
'
:
-
1
,
'
status
'
:
'
unknown
'
}
# Task Set State
def
TaskSetStatus
(
input_dict
,
db_connection
):
...
...
@@ -552,6 +561,7 @@ class PostgressMessageHandler(MessageHandlerInterface):
self
.
service2MethodMap
=
{
"
TaskGetSpecification
"
:
self
.
_TaskGetSpecification
,
"
TaskCreate
"
:
self
.
_TaskCreate
,
"
TaskGetStatus
"
:
self
.
_TaskGetStatus
,
"
TaskSetStatus
"
:
self
.
_TaskSetStatus
,
"
TaskSetSpecification
"
:
self
.
_TaskSetSpecification
,
"
TaskPrepareForScheduling
"
:
self
.
_TaskPrepareForScheduling
,
...
...
@@ -585,6 +595,10 @@ class PostgressMessageHandler(MessageHandlerInterface):
logger
.
info
(
"
_TaskCreate({})
"
.
format
(
kwargs
))
return
TaskCreate
(
kwargs
,
self
.
connection
)
def
_TaskGetStatus
(
self
,
**
kwargs
):
logger
.
info
(
"
_TaskGetStatus({})
"
.
format
(
kwargs
))
return
TaskGetStatus
(
kwargs
.
get
(
'
otdb_id
'
),
self
.
connection
)
def
_TaskSetStatus
(
self
,
**
kwargs
):
logger
.
info
(
"
_TaskSetStatus({})
"
.
format
(
kwargs
))
return
TaskSetStatus
(
kwargs
,
self
.
connection
)
...
...
This diff is collapsed.
Click to expand it.
SAS/ResourceAssignment/RAtoOTDBTaskSpecificationPropagator/lib/otdbrpc.py
+
6
−
39
View file @
3e8de401
...
...
@@ -57,12 +57,15 @@ class OTDBRPC(RPCWrapper):
raise
OTDBPRCException
(
"
TaskCreate failed for MoM ID %i
"
%
(
mom_id
,))
return
{
"
mom_id
"
:
answer
[
"
MomID
"
],
"
otdb_id
"
:
answer
[
"
OtdbID
"
]}
def
taskGetStatus
(
self
,
otdb_id
):
return
self
.
rpc
(
'
TaskGetStatus
'
,
otdb_id
=
otdb_id
)[
'
status
'
]
def
taskSetStatus
(
self
,
otdb_id
=
None
,
new_status
=
""
,
update_timestamps
=
True
):
answer
=
self
.
rpc
(
'
TaskSetStatus
'
,
OtdbID
=
otdb_id
,
NewStatus
=
new_status
,
UpdateTimestamps
=
update_timestamps
)
if
not
answer
[
"
Success
"
]:
raise
OTDBPRCException
(
"
TaskSetStatus failed for %i
"
%
(
otdb_id
,))
return
{
"
mom_id
"
:
answer
[
"
MomID
"
],
"
otdb_id
"
:
answer
[
"
OtdbID
"
]}
def
taskSetSpecification
(
self
,
otdb_id
=
None
,
specification
=
{}):
answer
=
self
.
rpc
(
'
TaskSetSpecification
'
,
OtdbID
=
otdb_id
,
Specification
=
specification
)
if
"
Errors
"
in
answer
:
...
...
@@ -103,44 +106,8 @@ class OTDBRPC(RPCWrapper):
def
do_tests
(
busname
=
DEFAULT_OTDB_SERVICE_BUSNAME
,
servicename
=
DEFAULT_OTDB_SERVICENAME
):
with
OTDBPRC
(
busname
=
busname
,
servicename
=
servicename
)
as
rpc
:
#for i in range(0, 10):
#taskId = rpc.insertTask(1234, 5678, 'active', 'OBSERVATION', 1)['id']
#rcId = rpc.insertResourceClaim(1, taskId, datetime.datetime.utcnow(), datetime.datetime.utcnow() + datetime.timedelta(hours=1), 'CLAIMED', 1, 10, 'einstein', -1)['id']
#print rpc.getResourceClaim(rcId)
#rpc.updateResourceClaim(rcId, starttime=datetime.datetime.utcnow(), endtime=datetime.datetime.utcnow() + datetime.timedelta(hours=2), status='ALLOCATED')
#print rpc.getResourceClaim(rcId)
#print
#tasks = rpc.getTasks()
#for t in tasks:
#print rpc.getTask(t['id'])
#for i in range(4,9):
#rcId = rpc.insertResourceClaim(i, t['id'], datetime.datetime.utcnow(), datetime.datetime.utcnow() + datetime.timedelta(hours=1), 'CLAIMED', 1, 10, 'einstein', -1)['id']
##print rpc.deleteTask(t['id'])
##print rpc.getTasks()
##print rpc.getResourceClaims()
#print
#taskId = tasks[0]['id']
#print 'taskId=', taskId
#print rpc.getResourceClaimsForTask(taskId)
#print rpc.updateResourceClaimsForTask(taskId, starttime=datetime.datetime.utcnow(), endtime=datetime.datetime.utcnow() + datetime.timedelta(hours=3))
#print rpc.getResourceClaimsForTask(taskId)
#print rpc.getTasks()
#print rpc.getResourceClaims()
#print rpc.getResources()
#print rpc.getResourceGroups()
#print rpc.getResourceGroupMemberships()
#rpc.deleteTask(taskId)
#print rpc.getTasks()
#print rpc.getResourceClaims()
pass
with
OTDBRPC
(
busname
=
busname
,
servicename
=
servicename
,
broker
=
'
10.149.96.6
'
)
as
rpc
:
print
rpc
.
taskGetStatus
(
452728
)
if
__name__
==
'
__main__
'
:
logging
.
basicConfig
(
format
=
'
%(asctime)s %(levelname)s %(message)s
'
,
level
=
logging
.
INFO
)
...
...
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