diff --git a/src/coldfront_plugin_cloud/attributes.py b/src/coldfront_plugin_cloud/attributes.py index f281145..71268f2 100644 --- a/src/coldfront_plugin_cloud/attributes.py +++ b/src/coldfront_plugin_cloud/attributes.py @@ -23,9 +23,11 @@ # TODO: Migration to rename the OpenStack specific prefix out of these attrs ALLOCATION_PROJECT_ID = 'Allocated Project ID' ALLOCATION_PROJECT_NAME = 'Allocated Project Name' +ALLOCATION_INSTITUTION_SPECIFIC_CODE = 'Institution-Specific Code' ALLOCATION_ATTRIBUTES = [ALLOCATION_PROJECT_ID, - ALLOCATION_PROJECT_NAME] + ALLOCATION_PROJECT_NAME, + ALLOCATION_INSTITUTION_SPECIFIC_CODE] ########################################################### # OpenStack Quota Attributes diff --git a/src/coldfront_plugin_cloud/management/commands/validate_allocations.py b/src/coldfront_plugin_cloud/management/commands/validate_allocations.py index 4e20ab6..a51b27b 100644 --- a/src/coldfront_plugin_cloud/management/commands/validate_allocations.py +++ b/src/coldfront_plugin_cloud/management/commands/validate_allocations.py @@ -51,6 +51,14 @@ def sync_users(project_id, allocation, allocator, apply): return failed_validation + def check_institution_specific_code(self, allocation): + attr = attributes.ALLOCATION_INSTITUTION_SPECIFIC_CODE + isc = allocation.get_attribute(attr) + if not isc: + utils.set_attribute_on_allocation( + allocation, attr, "N/A" + ) + def handle(self, *args, **options): # Openstack Resources first @@ -64,6 +72,7 @@ def handle(self, *args, **options): status=AllocationStatusChoice.objects.get(name='Active') ) for allocation in openstack_allocations: + self.check_institution_specific_code(allocation) allocation_str = f'{allocation.pk} of project "{allocation.project.title}"' msg = f'Starting resource validation for allocation {allocation_str}.' logger.debug(msg) @@ -134,6 +143,7 @@ def handle(self, *args, **options): ) for allocation in openshift_allocations: + self.check_institution_specific_code(allocation) allocation_str = f'{allocation.pk} of project "{allocation.project.title}"' logger.debug( f"Starting resource validation for allocation {allocation_str}." diff --git a/src/coldfront_plugin_cloud/tasks.py b/src/coldfront_plugin_cloud/tasks.py index 8556bfc..4a3c0eb 100644 --- a/src/coldfront_plugin_cloud/tasks.py +++ b/src/coldfront_plugin_cloud/tasks.py @@ -98,6 +98,9 @@ def set_quota_attributes(): utils.set_attribute_on_allocation(allocation, attributes.ALLOCATION_PROJECT_ID, project_id) + utils.set_attribute_on_allocation(allocation, + attributes.ALLOCATION_INSTITUTION_SPECIFIC_CODE, + 'N/A') set_quota_attributes() allocator.create_project_defaults(project_id)