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
a4cbcb6b
Commit
a4cbcb6b
authored
Mar 12, 2013
by
Kostas Papadimitriou
Browse files
Improve ui userquota response
include all available information as retrieved from astakos response
parent
989359e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
snf-cyclades-app/synnefo/ui/views.py
View file @
a4cbcb6b
...
...
@@ -242,27 +242,26 @@ def user_quota(request):
# astakos client backwards compatibility
get_user
(
request
,
settings
.
ASTAKOS_URL
)
vms_limit_for_user
=
\
settings
.
VMS_USER_QUOTA
.
get
(
request
.
user_uniq
,
settings
.
MAX_VMS_PER_USER
)
networks_limit_for_user
=
\
settings
.
NETWORKS_USER_QUOTA
.
get
(
request
.
user_uniq
,
settings
.
MAX_NETWORKS_PER_USER
)
if
request
.
user
and
'usage'
in
request
.
user
:
quota
=
dict
(
zip
([
q
[
'name'
]
for
q
in
request
.
user
[
'usage'
]],
request
.
user
[
'usage'
]))
# TODO: is it ok to use hardcoded resource name ???
if
'cyclades.vm'
in
quota
:
vms_limit_for_user
=
quota
[
'cyclades.vm'
][
'maxValue'
]
if
'cyclades.network.private'
in
quota
:
networks_limit_for_user
=
quota
[
'cyclades.network.private'
][
'maxValue'
]
return
HttpResponse
(
'{"vms_quota":%d, "networks_quota":%d}'
%
(
vms_limit_for_user
,
networks_limit_for_user
),
mimetype
=
"application/json"
)
response
=
json
.
dumps
(
request
.
user
[
'usage'
])
else
:
# hmmm, old astakos ???
# try to mimic astakos response using cyclades quota settings
networks_limit_for_user
=
\
settings
.
NETWORKS_USER_QUOTA
.
get
(
request
.
user_uniq
,
settings
.
MAX_NETWORKS_PER_USER
)
vms_limit_for_user
=
\
settings
.
VMS_USER_QUOTA
.
get
(
request
.
user_uniq
,
settings
.
MAX_NETWORKS_PER_USER
)
usage
=
[{
'name'
:
'cyclades.vm'
,
'maxValue'
:
vms_limit_for_user
},
{
'name'
:
'cyclades.network.private'
,
'maxValue'
:
networks_limit_for_user
}]
response
=
json
.
dumps
(
usage
);
return
HttpResponse
(
response
,
mimetype
=
"application/json"
)
def
js_tests
(
request
):
return
template
(
'tests'
,
request
,
{})
...
...
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