Standalone ECS plugin package for ColdFront.
pip install coldfront-ecs-pluginTo install directly from a GitHub repository (replace ORG/REPO as appropriate):
pip install "git+https://github.com/ORG/REPO.git"For local development from this directory:
pip install -e .Add coldfront_ecs_plugin to INSTALLED_APPS in your ColdFront settings.
Set ECS credentials and endpoint-related settings:
ECS_USERECS_PASSECS_CLIENT_VERSION(optional, defaults to3)
After installation and app enablement:
-
ecs_setup– create ECS-specific attribute typespython manage.py ecs_setup
- What it does
- Creates or updates ResourceAttributeTypes:
url– hostname for the ECS endpoint (no port), used to buildhttps://<host>:4443.replication_group– human-readable replication group (vpool) name (for exampleus1), used to pick the vpool when creating namespaces/buckets.
- Creates or updates AllocationAttributeTypes:
Namespace– logical namespace name to use for an allocation (optional override).Bucket– logical bucket name to use for an allocation (optional override).
- Creates or updates ResourceAttributeTypes:
- What it does not do
- Does not create generic ColdFront types such as
allocated_tb,used_tb,Storage Quota (TB), orQuota_In_Bytes. Those must come from ColdFront’s own management commands (add_resource_defaults,add_allocation_defaults) and are assumed to already exist. - Does not talk to ECS or create any namespaces/buckets; it only ensures database schema needed by the plugin is present.
- Does not create generic ColdFront types such as
- Org-specific assumptions
- Attribute names (
url,replication_group,Namespace,Bucket) are hard-coded to match the organization’s ColdFront convention. If you rename them in your deployment, you must also adjust the plugin.
- Attribute names (
- What it does
-
ecs_sync– pull ECS quota/usage into ColdFrontpython manage.py ecs_sync
- Resource selection
- Looks for
Resourcerows whose name containsecs(case-insensitive) and treats those as ECS resources. This is an organization-specific heuristic; if your ECS resources are named differently, you will need to adjust the filter in the command.
- Looks for
- Per-allocation sync
- For each active
Allocationattached to an ECS resource (status__name="Active"):- Derives the namespace name using:
- Allocation attribute
Namespace(if present), otherwise - A slugified version of
allocation.project.title.
- Allocation attribute
- Derives the bucket name using:
- Allocation attribute
Bucket(if present), otherwise - A slugified
lab-<namespace>-bucket.
- Allocation attribute
- Reads the namespace quota from ECS (in GB) and converts it to:
Storage Quota (TB)(value) – stored on the allocation via anAllocationAttribute.Quota_In_Bytes(value) – stored on the allocation via anAllocationAttribute.
- Reads the bucket usage from ECS billing (size in KB) and updates:
Storage Quota (TB)(usage) –allocation.set_usage("Storage Quota (TB)", …).Quota_In_Bytes(usage) –allocation.set_usage("Quota_In_Bytes", …).
- Derives the namespace name using:
- Any failures when reading a particular namespace or bucket are logged and skipped; other allocations and resources continue to sync.
- For each active
- Per-resource sync
- For each ECS resource, calls
ECSResourceManager.update_resource_usage()which:- Calls the ECS capacity API to compute:
capacity_tb– total provisioned cluster capacity (GB → TB).used_tb–totalProvisioned_gb - totalFree_gb(GB → TB).
- Sums all namespace quotas on that ECS endpoint to compute:
allocated_tb– sum of per-namespace limits in TB (this can exceedcapacity_tbif the cluster is overcommitted).
- Writes these to the backing
Resourceattributes:capacity_tb,used_tb,allocated_tb.
- Calls the ECS capacity API to compute:
- For each ECS resource, calls
- Org-specific assumptions
- Assumes ColdFront’s default storage attributes exist:
AllocationAttributeTypenamedStorage Quota (TB).AllocationAttributeTypenamedQuota_In_Bytes.
- Uses resource name contains
"ecs"as the way to identify ECS resources. This is specific to the reference deployment and may need to be changed in other environments.
- Assumes ColdFront’s default storage attributes exist:
- Resource selection
The plugin hooks into ColdFront’s allocation lifecycle via signals. Signal handlers live in coldfront_ecs_plugin.signals and are registered by the app config.
-
allocation_autocreate→ecs_allocation_autocreate- When it runs
- Triggered when a new allocation is auto-created in ColdFront.
- Only acts if:
allocation_objandresourceare present in the signal kwargs, and- the resource’s
namecontains"ecs"(case-insensitive).
- What it does
- Instantiates
ECSResourceManagerfor the target resource (using the resource’surlattribute and global ECS credentials). - Derives the namespace name from the allocation (see Model assumptions below).
- Derives the bucket name from the allocation.
- Checks whether the namespace already exists on ECS:
- If it does exist, raises
ValueErrorso the UI can show a clear error (prevents accidentally reusing another lab’s namespace).
- If it does exist, raises
- Resolves the replication group (vpool) using:
- The resource’s
replication_groupattribute (replication group name), if set, mapped to a vpool ID, or - The namespace’s
default_data_services_vpool/ the ECS defaults.
- The resource’s
- Creates the namespace on ECS, attaching:
- The resolved replication group / vpool.
- The project/lab name as the namespace’s LDAP group (in the reference organization’s setup).
- If the allocation has a size:
- Attaches a namespace quota equal to that size (in TB) via
update_namespace_quota.
- Attaches a namespace quota equal to that size (in TB) via
- Interprets
automation_specificationsfrom the approval form:nfs_share→ supported; creates the bucket withfilesystem_enabled=True.snapshots,cifs_share, or any other value → unsupported for ECS; raisesValueErrordescribing that these options are not valid for ECS.
- Creates the bucket in that namespace, optionally with a bucket quota mirroring the allocation size.
- Instantiates
- Error handling
- Any failure in the process is logged with
category="integration:ecs". - A
ValueErroris raised with a user-friendly message, which the ColdFront UI can display to the user.
- Any failure in the process is logged with
- Org-specific assumptions
- Uses the project title and lab naming conventions to form namespace and bucket names (
lab-<namespace>-bucket). - Assumes one LDAP group per project; passes the project title as the group when creating namespaces.
- Treats
"ecs"in the resource name as the indicator that a resource is backed by ECS.
- Uses the project title and lab naming conventions to form namespace and bucket names (
- When it runs
-
allocation_autoupdate→ecs_allocation_autoupdate- When it runs
- Triggered when an allocation’s quota is changed via the ColdFront UI.
- Only acts if:
allocation_objandnew_quota_valueare present, and- the first resource on the allocation has
"ecs"in its name.
- What it does
- Instantiates
ECSResourceManagerfor the allocation’s ECS resource. - Derives the namespace name from the allocation.
- Calls
change_namespace_quota(namespace_name, new_quota_tb)to update the namespace’s quota on ECS.
- Instantiates
- Error handling
- On failure, logs details and raises
ValueError("ECS quota update failed …")so that the frontend can surface a clear error during the update workflow.
- On failure, logs details and raises
- Org-specific assumptions
- Same naming conventions and resource selection heuristic as
allocation_autocreate.
- Same naming conventions and resource selection heuristic as
- When it runs
-
ECS Resource URL
- Each ECS
Resourcein ColdFront must have aResourceAttributenamedurlwhose value is the ECS endpoint hostname, without port (for example:https://ecs.example.org). - The plugin uses this to build
token_endpointandecs_endpointas"{url}:4443/login"and"{url}:4443".
- Each ECS
-
Replication group (vpool) for bucket creation
- Creating a bucket requires a valid ECS replication group (vpool) ID. The plugin resolves it in this order:
- The namespace’s default_data_services_vpool, if the namespace exists and has one.
- Resource attribute
replication_group, if set — the attribute value is the replication group name (e.g.us1), not the vpool URN; the plugin looks up the corresponding vpool ID from the cluster viareplication_group_id_from_name.
- If the namespace has no default vpool and no resource attribute is set, autocreate fails with a clear error. Run
ecs_setupto ensure the replication_group attribute type exists, then set that attribute on the ECS resource to the replication group name (e.g.us1) to pin a specific vpool.
- Creating a bucket requires a valid ECS replication group (vpool) ID. The plugin resolves it in this order:
-
Namespace mapping for Allocations
- The ECS namespace for an allocation is resolved as:
- Allocation attribute
Namespace(if present), otherwise - A slugified version of
allocation.project.title.
- Allocation attribute
- The ECS namespace for an allocation is resolved as:
-
Bucket mapping for Allocations
- The ECS bucket name for an allocation is resolved as:
- Allocation attribute
Bucket(if present), otherwise - A slugified
lab-<namespace>-bucket.
- Allocation attribute
- The ECS bucket name for an allocation is resolved as:
-
Quota attributes on Allocations
- The sync and signals logic assume the standard storage attributes exist:
AllocationAttributeTypenamedStorage Quota (TB)AllocationAttributeTypenamedQuota_In_Bytes
ecs_syncmaintains both the value and usage for these attributes.
- The sync and signals logic assume the standard storage attributes exist:
-
Allocation auto-create automation options
- When an allocation is auto-created for an ECS resource, the plugin will:
- create a namespace named after the project (or
Namespaceallocation attribute, if set), - attach a namespace quota based on the allocation size (in TB), and
- create a bucket within that namespace.
- create a namespace named after the project (or
- The
automation_specificationsselected on the allocation approval form are interpreted as:nfs_share: supported for ECS; enables filesystem access on the bucket (filesystem_enabled=True).snapshots,cifs_share, or any other value: not supported for ECS; the plugin will raise a clear error indicating these automation options are not valid for ECS storage.
- A hard error is raised if a namespace with the computed name already exists on ECS for the target resource.
- When an allocation is auto-created for an ECS resource, the plugin will: