Commit 403d89cc authored by Giorgos Korfiatis's avatar Giorgos Korfiatis

astakos: Modify resource project default

Add support in resource-modify for changing the project_default.
parent b972ec61
......@@ -42,12 +42,15 @@ from ._common import style_options, check_style, units
class Command(BaseCommand):
args = "<resource name>"
help = "Modify a resource's default base quota and boolean flags."
help = "Modify a resource's quota defaults and boolean flags."
option_list = BaseCommand.option_list + (
make_option('--base-default',
metavar='<limit>',
help="Specify default base quota"),
help="Specify default quota for base projects"),
make_option('--project-default',
metavar='<limit>',
help="Specify default quota for non-base projects"),
make_option('--unit-style',
default='mb',
help=("Specify display unit for resource values "
......@@ -68,6 +71,7 @@ class Command(BaseCommand):
actions = {
'base_default': self.change_base_default,
'project_default': self.change_project_default,
'api_visible': self.set_api_visible,
'ui_visible': self.set_ui_visible,
}
......@@ -116,6 +120,10 @@ class Command(BaseCommand):
limit = self.parse_limit(limit)
register.update_base_default(resource, limit)
def change_project_default(self, resource, limit):
limit = self.parse_limit(limit)
register.update_project_default(resource, limit)
def parse_limit(self, limit):
try:
return units.parse(limit)
......
......@@ -126,6 +126,18 @@ def update_base_default(resource, base_default):
% (resource.name, base_default))
def update_project_default(resource, project_default):
old_project_default = resource.project_default
if project_default == old_project_default:
logger.info("Resource %s has project default %s; no need to update."
% (resource.name, project_default))
else:
resource.project_default = project_default
resource.save()
logger.info("Updated resource %s with project default %s."
% (resource.name, project_default))
def resources_to_dict(resources):
resource_dict = {}
for r in resources:
......
......@@ -643,18 +643,28 @@ class Astakos(SynnefoComponent):
]
def set_default_quota(self):
cmd = "snf-manage resource-modify --base-default"
return [
"%s 40G pithos.diskspace" % cmd,
"%s 2 astakos.pending_app" % cmd,
"%s 4 cyclades.vm" % cmd,
"%s 40G cyclades.disk" % cmd,
"%s 16G cyclades.total_ram" % cmd,
"%s 8G cyclades.ram" % cmd,
"%s 32 cyclades.total_cpu" % cmd,
"%s 16 cyclades.cpu" % cmd,
"%s 4 cyclades.network.private" % cmd,
"%s 4 cyclades.floating_ip" % cmd,
cmd = "snf-manage resource-modify"
return [
"%s --base-default 40G pithos.diskspace" % cmd,
"%s --base-default 2 astakos.pending_app" % cmd,
"%s --base-default 4 cyclades.vm" % cmd,
"%s --base-default 40G cyclades.disk" % cmd,
"%s --base-default 16G cyclades.total_ram" % cmd,
"%s --base-default 8G cyclades.ram" % cmd,
"%s --base-default 32 cyclades.total_cpu" % cmd,
"%s --base-default 16 cyclades.cpu" % cmd,
"%s --base-default 4 cyclades.network.private" % cmd,
"%s --base-default 4 cyclades.floating_ip" % cmd,
"%s --project-default 0 pithos.diskspace" % cmd,
"%s --project-default 0 astakos.pending_app" % cmd,
"%s --project-default 0 cyclades.vm" % cmd,
"%s --project-default 0 cyclades.disk" % cmd,
"%s --project-default inf cyclades.total_ram" % cmd,
"%s --project-default 0 cyclades.ram" % cmd,
"%s --project-default inf cyclades.total_cpu" % cmd,
"%s --project-default 0 cyclades.cpu" % cmd,
"%s --project-default 0 cyclades.network.private" % cmd,
"%s --project-default 0 cyclades.floating_ip" % cmd,
]
def modify_all_quota(self):
......
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