Commit bdaaef8c authored by Christos Stavrakakis's avatar Christos Stavrakakis

cyclades: Remove obsolete code for static quotas

Remove the following obsolete settings, since their usage is covered
by Quotaholder:
- MAX_VMS_PER_USER
- MAX_NETWORKS_PER_USER
- VMS_USER_QUOTA
- NETWORKS_USER_QUOTA

Also remove 'cyclades-export-quota' management command.
parent 6554b86a
......@@ -32,6 +32,9 @@ Cyclades
which is equivalent to 'reconcile-resources-cyclades --fix'.
* Rename 'cyclades-reconcile-commissions' management command to
'reconcile-commissions-cyclades'.
* Remove obsolete 'MAX_VMS_PER_USER', 'MAX_NETWORKS_PER_USER',
"VMS_USER_QUOTA" and "NETWORKS_USER_QUOTA" settings, since their usage
is covered by Quotaholder.
Pithos
......
......@@ -45,13 +45,6 @@ In `/etc/synnefo/cyclades.conf` add:
MAX_CIDR_BLOCK = 21
PUBLIC_USE_POOL = True
MAX_VMS_PER_USER = 5
VMS_USER_QUOTA = {
'user@example.com': 20,
}
MAX_NETWORKS_PER_USER = 3
NETWORKS_USER_QUOTA = { 'user@example.com': 10 }
CPU_BAR_GRAPH_URL = 'https://cyclades.example.com/stats/%s/cpu-bar.png'
CPU_TIMESERIES_GRAPH_URL = 'https://cyclades.example.com/stats/%s/cpu-ts.png'
NET_BAR_GRAPH_URL = 'https://cyclades.example.com/stats/%s/net-bar.png'
......
......@@ -70,20 +70,6 @@
## List of backend IDs used *only* for archipelago.
#ARCHIPELAGO_BACKENDS = []
#
## Quota
## Maximum number of VMs a user is allowed to have.
#MAX_VMS_PER_USER = 3
#
## Override maximum number of VMs for specific users.
## e.g. VMS_USER_QUOTA = {'user1@grnet.gr': 5, 'user2@grnet.gr': 10}
#VMS_USER_QUOTA = {}
#
## Maximum number of networks a user is allowed to have.
#MAX_NETWORKS_PER_USER = 5
#
## Override maximum number of private networks for specific users.
## e.g. NETWORKS_USER_QUOTA = {'user1@grnet.gr': 5, 'user2@grnet.gr': 10}
#NETWORKS_USER_QUOTA = {}
#
## URL templates for the stat graphs.
## The API implementation replaces '%s' with the encrypted backend id.
......
# Copyright 2013 GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
#
# 1. Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from django.core.management.base import NoArgsCommand, CommandError
from optparse import make_option
from synnefo import settings
from os import path
class Command(NoArgsCommand):
help = "Export account quota policies"
option_list = NoArgsCommand.option_list + (
make_option(
'--location',
dest='location',
default='exported_quota',
help="Where to save the output file"),
)
def handle_noargs(self, **options):
try:
vms_per_user = settings.VMS_USER_QUOTA
nets_per_user = settings.NETWORKS_USER_QUOTA
except AttributeError as e:
raise CommandError(e)
location = path.abspath(options['location'])
try:
f = open(location, 'w')
except IOError as e:
raise CommandError(e)
INF = str(10**30)
for user, value in vms_per_user.items():
f.write(' '.join([user, "cyclades.vm", "%s" % value, '0', INF,
INF]))
f.write('\n')
for user, value in nets_per_user.items():
f.write(' '.join([user, "cyclades.network.private", "%s" % value,
'0', INF, INF]))
f.write('\n')
f.close()
self.stdout.write("Successfully exported cyclades per-user-quotas to"
" file '%s'\n" % location)
......@@ -70,20 +70,6 @@ BACKEND_PER_USER = {}
# List of backend IDs used *only* for archipelago.
ARCHIPELAGO_BACKENDS = []
# Quota
# Maximum number of VMs a user is allowed to have.
MAX_VMS_PER_USER = 3
# Override maximum number of VMs for specific users.
# e.g. VMS_USER_QUOTA = {'user1@grnet.gr': 5, 'user2@grnet.gr': 10}
VMS_USER_QUOTA = {}
# Maximum number of networks a user is allowed to have.
MAX_NETWORKS_PER_USER = 5
# Override maximum number of private networks for specific users.
# e.g. NETWORKS_USER_QUOTA = {'user1@grnet.gr': 5, 'user2@grnet.gr': 10}
NETWORKS_USER_QUOTA = {}
# URL templates for the stat graphs.
# The API implementation replaces '%s' with the encrypted backend id.
......
......@@ -258,22 +258,7 @@ def machines_console(request):
def user_quota(request):
get_user(request, settings.ASTAKOS_URL, usage=True)
if request.user and 'usage' in request.user:
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)
response = json.dumps(request.user['usage'])
return HttpResponse(response, mimetype="application/json")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment