Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into action_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
QuanMPhm committed Jan 25, 2024
2 parents a53be9e + ef320a7 commit 95aeb1d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/coldfront_plugin_cloud/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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}."
Expand Down
3 changes: 3 additions & 0 deletions src/coldfront_plugin_cloud/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 95aeb1d

Please sign in to comment.