Commit dea83d05 authored by Giorgos Korfiatis's avatar Giorgos Korfiatis

astakos: Add project default in resources

Add field `project_default' in resources. This will serve as a skeleton to
fill project quota (both project-level and member-level limits) for
resources not specified by the application.

The field is initialized by consulting the default base quota (field
`uplimit'): It is set to inf if uplimit is inf, otherwise it is set to
zero.
parent bfa5735b
......@@ -54,7 +54,9 @@ class Command(ListCommand):
"service_type": ("service_type", "Service type"),
"service_origin": ("service_origin", "Service"),
"unit": ("unit", "Unit of measurement"),
"default_quota": ("limit_with_unit", "Default Quota"),
"base_default": ("limit_with_unit", "Base project default quota"),
"project_default": ("project_limit_with_unit",
"Project default quota"),
"description": ("desc", "Description"),
"api_visible": ("api_visible",
"Resource accessibility through the API"),
......@@ -62,11 +64,8 @@ class Command(ListCommand):
"Resource accessibility through the UI"),
}
fields = ["id", "name", "default_quota", "api_visible", "ui_visible"]
def show_limit(self, resource):
limit = resource.uplimit
return show_resource_value(limit, resource.name, self.unit_style)
fields = ["id", "name", "base_default", "project_default",
"api_visible", "ui_visible"]
def handle_args(self, *args, **options):
self.unit_style = options['unit_style']
......@@ -74,4 +73,7 @@ class Command(ListCommand):
def handle_db_objects(self, rows, *args, **kwargs):
for resource in rows:
resource.limit_with_unit = self.show_limit(resource)
resource.limit_with_unit = show_resource_value(
resource.uplimit, resource.name, self.unit_style)
resource.project_limit_with_unit = show_resource_value(
resource.project_default, resource.name, self.unit_style)
......@@ -233,6 +233,7 @@ class Resource(models.Model):
service_origin = models.CharField(max_length=255, db_index=True)
unit = models.CharField(_('Unit'), null=True, max_length=255)
uplimit = models.BigIntegerField(default=0)
project_default = models.BigIntegerField()
ui_visible = models.BooleanField(default=True)
api_visible = models.BooleanField(default=True)
......
......@@ -85,6 +85,7 @@ def add_resource(resource_dict):
except Resource.DoesNotExist:
r = Resource(name=name,
uplimit=units.PRACTICALLY_INFINITE,
project_default=units.PRACTICALLY_INFINITE,
service_type=service_type,
service_origin=service_origin)
exists = False
......
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