diff --git a/src/coldfront_plugin_cloud/attributes.py b/src/coldfront_plugin_cloud/attributes.py index 725710a5..a35d48c4 100644 --- a/src/coldfront_plugin_cloud/attributes.py +++ b/src/coldfront_plugin_cloud/attributes.py @@ -20,6 +20,18 @@ class CloudAllocationAttribute: is_changeable: bool = True +@dataclass +class CloudProjectAttribute: + """Class for configuring Cloud Project Attributes""" + + name: str + type: str = "Int" + has_usage: bool = False + is_private: bool = False + is_changeable: bool = True + is_unique: bool = True + + RESOURCE_AUTH_URL = "Identity Endpoint URL" RESOURCE_API_URL = "OpenShift API Endpoint URL" RESOURCE_IDENTITY_NAME = "OpenShift Identity Provider Name" @@ -120,3 +132,12 @@ class CloudAllocationAttribute: ALLOCATION_QUOTA_ATTRIBUTES = [ CloudAllocationAttribute(name=QUOTA_GPU), ] + + +PROJECT_IS_EXTERNALLY_FUNDED = "Is Externally Funded" + +PROJECT_ATTRIBUTES = [ + CloudProjectAttribute( + name=PROJECT_IS_EXTERNALLY_FUNDED, type="Yes/No", is_changeable=False + ) +] diff --git a/src/coldfront_plugin_cloud/management/commands/register_cloud_attributes.py b/src/coldfront_plugin_cloud/management/commands/register_cloud_attributes.py index c0bf235e..f20cea8f 100644 --- a/src/coldfront_plugin_cloud/management/commands/register_cloud_attributes.py +++ b/src/coldfront_plugin_cloud/management/commands/register_cloud_attributes.py @@ -4,6 +4,7 @@ from coldfront.core.allocation import models as allocation_models from coldfront.core.resource import models as resource_models +from coldfront.core.project import models as project_models from coldfront_plugin_cloud import attributes @@ -138,9 +139,21 @@ def register_resource_type(self): name="OpenShift Virtualization", description="OpenShift Virtualization" ) + def register_project_attributes(self): + for attr in attributes.PROJECT_ATTRIBUTES: + project_models.ProjectAttributeType.objects.get_or_create( + name=attr.name, + attribute_type=project_models.AttributeType.objects.get(name=attr.type), + has_usage=attr.has_usage, + is_private=attr.is_private, + is_changeable=attr.is_changeable, + is_unique=attr.is_unique, + ) + def handle(self, *args, **options): self.register_resource_type() self.migrate_resource_attributes() self.migrate_allocation_attributes() self.register_resource_attributes() self.register_allocation_attributes() + self.register_project_attributes()