Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
e87b125c
Commit
e87b125c
authored
Apr 29, 2013
by
Giorgos Korfiatis
Browse files
quotaholder: Rename counters to usage_min, usage_max
parent
615de8f9
Changes
4
Hide whitespace changes
Inline
Side-by-side
snf-astakos-app/astakos/im/quotas.py
View file @
e87b125c
...
...
@@ -39,16 +39,16 @@ from django.db.models import Q
def
from_holding
(
holding
):
limit
,
imported_min
,
imported
_max
=
holding
limit
,
usage_min
,
usage
_max
=
holding
body
=
{
'limit'
:
limit
,
'usage'
:
imported
_max
,
'pending'
:
imported_max
-
imported
_min
,
'usage'
:
usage
_max
,
'pending'
:
usage_max
-
usage
_min
,
}
return
body
def
limits_only
(
holding
):
limit
,
imported_min
,
imported
_max
=
holding
limit
,
usage_min
,
usage
_max
=
holding
return
limit
...
...
snf-astakos-app/astakos/quotaholder/callpoint.py
View file @
e87b125c
...
...
@@ -62,7 +62,7 @@ def get_quota(holders=None, sources=None, resources=None):
quotas
=
{}
for
holding
in
holdings
:
key
=
(
holding
.
holder
,
holding
.
source
,
holding
.
resource
)
value
=
(
holding
.
limit
,
holding
.
imported
_min
,
holding
.
imported
_max
)
value
=
(
holding
.
limit
,
holding
.
usage
_min
,
holding
.
usage
_max
)
quotas
[
key
]
=
value
return
quotas
...
...
@@ -186,8 +186,8 @@ def _log_provision(commission, provision, holding, log_time, reason):
'source'
:
holding
.
source
,
'resource'
:
holding
.
resource
,
'limit'
:
holding
.
limit
,
'
imported
_min'
:
holding
.
imported
_min
,
'
imported
_max'
:
holding
.
imported
_max
,
'
usage
_min'
:
holding
.
usage
_min
,
'
usage
_max'
:
holding
.
usage
_max
,
'delta_quantity'
:
provision
.
quantity
,
'issue_time'
:
commission
.
issue_time
,
'log_time'
:
log_time
,
...
...
snf-astakos-app/astakos/quotaholder/commission.py
View file @
e87b125c
...
...
@@ -38,7 +38,7 @@ class Operation(object):
@
staticmethod
def
assertions
(
holding
):
assert
(
holding
.
imported
_min
<=
holding
.
imported
_max
)
assert
(
holding
.
usage
_min
<=
holding
.
usage
_max
)
@
classmethod
def
_prepare
(
cls
,
holding
,
quantity
,
check
=
True
):
...
...
@@ -80,11 +80,11 @@ class Import(Operation):
@
classmethod
def
_prepare
(
cls
,
holding
,
quantity
,
check
=
True
):
imported
_max
=
holding
.
imported
_max
new_
imported_max
=
imported
_max
+
quantity
usage
_max
=
holding
.
usage
_max
new_
usage_max
=
usage
_max
+
quantity
limit
=
holding
.
limit
if
check
and
new_
imported
_max
>
limit
:
if
check
and
new_
usage
_max
>
limit
:
holder
=
holding
.
holder
resource
=
holding
.
resource
m
=
(
"%s has not enough capacity of %s."
%
(
holder
,
resource
))
...
...
@@ -92,14 +92,14 @@ class Import(Operation):
raise
NoCapacityError
(
m
,
provision
=
provision
,
limit
=
limit
,
usage
=
imported
_max
)
usage
=
usage
_max
)
holding
.
imported
_max
=
new_
imported
_max
holding
.
usage
_max
=
new_
usage
_max
holding
.
save
()
@
classmethod
def
_finalize
(
cls
,
holding
,
quantity
):
holding
.
imported
_min
+=
quantity
holding
.
usage
_min
+=
quantity
holding
.
save
()
...
...
@@ -107,10 +107,10 @@ class Release(Operation):
@
classmethod
def
_prepare
(
cls
,
holding
,
quantity
,
check
=
True
):
imported
_min
=
holding
.
imported
_min
new_
imported_min
=
imported
_min
-
quantity
usage
_min
=
holding
.
usage
_min
new_
usage_min
=
usage
_min
-
quantity
if
check
and
new_
imported
_min
<
0
:
if
check
and
new_
usage
_min
<
0
:
holder
=
holding
.
holder
resource
=
holding
.
resource
m
=
(
"%s attempts to release more %s than it contains."
%
...
...
@@ -118,14 +118,14 @@ class Release(Operation):
provision
=
cls
.
provision
(
holding
,
quantity
,
importing
=
False
)
raise
NoQuantityError
(
m
,
provision
=
provision
,
available
=
imported
_min
)
available
=
usage
_min
)
holding
.
imported
_min
=
new_
imported
_min
holding
.
usage
_min
=
new_
usage
_min
holding
.
save
()
@
classmethod
def
_finalize
(
cls
,
holding
,
quantity
):
holding
.
imported
_max
-=
quantity
holding
.
usage
_max
-=
quantity
holding
.
save
()
...
...
snf-astakos-app/astakos/quotaholder/models.py
View file @
e87b125c
...
...
@@ -47,8 +47,8 @@ class Holding(Model):
resource
=
CharField
(
max_length
=
4096
,
null
=
False
)
limit
=
intDecimalField
()
imported
_min
=
intDecimalField
(
default
=
0
)
imported
_max
=
intDecimalField
(
default
=
0
)
usage
_min
=
intDecimalField
(
default
=
0
)
usage
_max
=
intDecimalField
(
default
=
0
)
objects
=
ForUpdateManager
()
...
...
@@ -104,8 +104,8 @@ class ProvisionLog(Model):
source
=
CharField
(
max_length
=
4096
,
null
=
True
)
resource
=
CharField
(
max_length
=
4096
)
limit
=
intDecimalField
()
imported
_min
=
intDecimalField
()
imported
_max
=
intDecimalField
()
usage
_min
=
intDecimalField
()
usage
_max
=
intDecimalField
()
delta_quantity
=
intDecimalField
()
reason
=
CharField
(
max_length
=
4096
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment