AttributeType

Bases: TimeStampedModel

An attribute type indicates the data type of the attribute. Examples include Date, Float, Int, Text, and Yes/No.

Attributes:
  • name (str) –

    name of attribute data type

Resource

Bases: TimeStampedModel

A resource is something a center maintains and provides access to for the community. Examples include Budgetstorage, Server, and Software License.

Attributes:
  • parent_resource (Resource) –

    used for the Cluster Partition resource type as these partitions fall under a main cluster

  • resource_type (ResourceType) –

    the type of resource (Cluster, Storage, etc.)

  • name (str) –

    name of resource

  • description (str) –

    description of what the resource does and is used for

  • is_available (bool) –

    indicates whether or not the resource is available for users to request an allocation for

  • is_public (bool) –

    indicates whether or not users can see the resource

  • requires_payment (bool) –

    indicates whether or not users have to pay to use this resource

  • allowed_groups (Group) –

    uses the Django Group model to allow certain user groups to request the resource

  • allowed_users (User) –

    links Django Users that are allowed to request the resource to the resource

status property

Returns:
  • str

    the status of the resource

get_attribute

Parameters:
  • name (str) –

    name of the resource attribute type

  • expand (bool, default: True ) –

    indicates whether or not to return the expanded value with attributes/parameters for attributes with a base type of 'Attribute Expanded Text'

  • typed (bool, default: True ) –

    indicates whether or not to convert the attribute value to an int/ float/ str based on the base AttributeType name

  • extra_allocations (list[Allocation], default: [] ) –

    allocations which are available to reference in the attribute list in addition to those associated with this ResourceAttribute

Returns:
  • str

    the value of the first attribute found for this resource with the specified name

get_attribute_list

Parameters:
  • name (str) –

    name of the resource

  • expand (bool, default: True ) –

    indicates whether or not to return the expanded value with attributes/parameters for attributes with a base type of 'Attribute Expanded Text'

  • typed (bool, default: True ) –

    indicates whether or not to convert the attribute value to an int/ float/ str based on the base AttributeType name

  • extra_allocations (list[Allocation], default: [] ) –

    allocations which are available to reference in the attribute list in addition to those associated with this ResourceAttribute

Returns:
  • list

    the list of values of the attributes found with specified name

get_missing_resource_attributes

Parameters:
  • required (bool, default: False ) –

    indicates whether or not to get only the missing resource attributes that are required (if True, get only required missing attributes; else, get required and non-required missing attributes)

Returns:
  • list[ResourceAttribute]: a list of resource attributes that do not already exist for this resource

get_ondemand_status

Returns:
  • str

    If the resource has OnDemand status or not

ResourceAttribute

Bases: TimeStampedModel

A resource attribute class links a resource attribute type and a resource.

Attributes:
  • resource_attribute_type (ResourceAttributeType) –

    resource attribute type to link

  • resource (Resource) –

    resource to link

  • value (str) –

    value of the resource attribute

clean

Validates the resource and raises errors if the resource is invalid.

expanded_value

Parameters:
  • typed (bool, default: True ) –

    indicates whether or not to convert the attribute value to an int/ float/ str based on the base AttributeType name (unrecognized values not converted, so will return str)

  • extra_allocations (list[Allocation], default: [] ) –

    allocations which are available to reference in the attribute list in addition to those associated with this ResourceAttribute

Returns:
  • int, float, str: the value of the attribute after attribute expansion

For attributes with attribute type of 'Attribute Expanded Text' we look for an attribute with same name suffixed with '_attriblist' (this should be ResourceAttribute of the Resource associated with the attribute). If the attriblist attribute is found, we use it to generate a dictionary to use to expand the attribute value, and the expanded value is returned.

If the expansion fails, or if no attriblist attribute is found, or if the attribute type is not 'Attribute Expanded Text', we just return the raw value.

typed_value

Returns:
  • int, float, str: the value of the attribute with proper type and is used for computing expanded_value() (coerced into int or float for attributes with Int or Float types; if it fails or the attribute is of any other type, it is coerced into a str)

ResourceAttributeType

Bases: TimeStampedModel

A resource attribute type indicates the type of the attribute. Examples include slurm_specs and slurm_cluster.

Attributes:
  • attribute_type (AttributeType) –

    indicates the AttributeType of the attribute

  • name (str) –

    name of resource attribute type

  • is_required (bool) –

    indicates whether or not the attribute is required

  • is_value_unique (bool) –

    indicates whether or not the value is unique

Note: the is_unique_per_resource field is rarely used, hence documentation does not exist.

ResourceType

Bases: TimeStampedModel

A resource type class links a resource and its value.

Attributes:
  • name (str) –

    name of resource type

  • description (str) –

    description of resource type

active_count property

Returns:
  • int

    the number of active resources of that type

inactive_count property

Returns:
  • int

    the number of inactive resources of that type