Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/coldfront_plugin_cloud/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
)
]
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
Loading