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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
66e53277
Commit
66e53277
authored
8 years ago
by
Jorrit Schaap
Browse files
Options
Downloads
Patches
Plain Diff
Task #8887: fix in resource_usages
parent
7c4bc6ca
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SAS/ResourceAssignment/ResourceAssignmentDatabase/radb.py
+21
-24
21 additions, 24 deletions
SAS/ResourceAssignment/ResourceAssignmentDatabase/radb.py
with
21 additions
and
24 deletions
SAS/ResourceAssignment/ResourceAssignmentDatabase/radb.py
+
21
−
24
View file @
66e53277
...
...
@@ -1334,30 +1334,27 @@ class RADatabase:
resources
=
self
.
getResources
(
resource_ids
=
resource_ids
,
include_availability
=
True
)
for
resource
in
resources
:
try
:
resource_id
=
resource
[
'
id
'
]
resource_usages
=
all_usages
[
resource_id
]
# copy resource capacities
resource_usages
[
'
total_capacity
'
]
=
0
resource_usages
[
'
available_capacity
'
]
=
0
resource_usages
[
'
used_capacity
'
]
=
0
resource_usages
[
'
misc_used_capacity
'
]
=
0
if
'
total_capacity
'
in
resource
:
resource_usages
[
'
total_capacity
'
]
=
resource
[
'
total_capacity
'
]
if
'
available_capacity
'
in
resource
:
resource_usages
[
'
available_capacity
'
]
=
resource
[
'
available_capacity
'
]
if
'
used_capacity
'
in
resource
:
resource_usages
[
'
used_capacity
'
]
=
resource
[
'
used_capacity
'
]
# and compute unaccounted-for usage,
# which is the actual used_capacity minus the currently allocated total claim size
utcnow
=
datetime
.
utcnow
()
allocated_usages
=
resource_usages
[
'
usages
'
].
get
(
'
allocated
'
,
[])
past_allocated_usages
=
sorted
([
au
for
au
in
allocated_usages
if
au
[
'
timestamp
'
]
<=
utcnow
])
if
past_allocated_usages
:
currently_allocated_usage
=
past_allocated_usages
[
-
1
]
resource_usages
[
'
misc_used_capacity
'
]
=
resource
[
'
used_capacity
'
]
-
currently_allocated_usage
[
'
value
'
]
except
:
pass
resource_id
=
resource
[
'
id
'
]
resource_usages
=
all_usages
[
resource_id
]
# copy resource capacities
for
item
in
[
'
total_capacity
'
,
'
available_capacity
'
,
'
used_capacity
'
]:
try
:
resource_usages
[
item
]
=
0
if
item
in
resource
:
resource_usages
[
item
]
=
resource
[
item
]
if
item
==
'
used_capacity
'
:
# and compute unaccounted-for usage,
# which is the actual used_capacity minus the currently allocated total claim size
# defaults to used_capacity if no currently allocated total claim size
resource_usages
[
'
misc_used_capacity
'
]
=
resource
[
'
used_capacity
'
]
utcnow
=
datetime
.
utcnow
()
allocated_usages
=
resource_usages
[
'
usages
'
].
get
(
'
allocated
'
,
[])
past_allocated_usages
=
sorted
([
au
for
au
in
allocated_usages
if
au
[
'
timestamp
'
]
<=
utcnow
])
if
past_allocated_usages
:
currently_allocated_usage
=
past_allocated_usages
[
-
1
]
resource_usages
[
'
misc_used_capacity
'
]
=
resource
[
'
used_capacity
'
]
-
currently_allocated_usage
[
'
value
'
]
except
Exception
as
e
:
logger
.
error
(
e
)
all_usages_list
=
all_usages
.
values
()
return
all_usages_list
...
...
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