heat.engine.constraints module

heat.engine.constraints module

class heat.engine.constraints.AllowedPattern(pattern, description=None)[source]

Bases: heat.engine.constraints.Constraint

Constrain values to a predefined regular expression pattern.

Serializes to JSON as:

{
    'allowed_pattern': <pattern>,
    'description': <description>
}
valid_types = ('STRING',)
class heat.engine.constraints.AllowedValues(allowed, description=None)[source]

Bases: heat.engine.constraints.Constraint

Constrain values to a predefined set.

Serializes to JSON as:

{
    'allowed_values': [<allowed1>, <allowed2>, ...],
    'description': <description>
}
valid_types = ('STRING', 'INTEGER', 'NUMBER', 'BOOLEAN', 'LIST')
class heat.engine.constraints.AnyIndexDict(value)[source]

Bases: _abcoll.Mapping

A Mapping that returns the same value for any integer index.

Used for storing the schema for a list. When converted to a dictionary, it contains a single item with the key ‘*’.

ANYTHING = '*'
class heat.engine.constraints.BaseCustomConstraint[source]

Bases: object

A base class for validation using API clients.

It will provide a better error message, and reduce a bit of duplication. Subclass must provide expected_exceptions and implement validate_with_client.

error(value)[source]
expected_exceptions = (<class 'heat.common.exception.EntityNotFound'>,)
resource_client_name = None
resource_getter_name = None
validate(value, context)[source]
validate_with_client(client, resource_id)[source]
class heat.engine.constraints.Constraint(description=None)[source]

Bases: _abcoll.Mapping

Parent class for constraints on allowable values for a Property.

Constraints are serializable to dictionaries following the HOT input Parameter constraints schema using dict().

DESCRIPTION = 'description'
validate(value, schema=None, context=None)[source]
class heat.engine.constraints.CustomConstraint(name, description=None, environment=None)[source]

Bases: heat.engine.constraints.Constraint

A constraint delegating validation to an external class.

custom_constraint
valid_types = ('STRING', 'INTEGER', 'NUMBER', 'BOOLEAN', 'LIST')
class heat.engine.constraints.Length(min=None, max=None, description=None)[source]

Bases: heat.engine.constraints.Range

Constrain the length of values within a range.

Serializes to JSON as:

{
    'length': {'min': <min>, 'max': <max>},
    'description': <description>
}
valid_types = ('STRING', 'LIST', 'MAP')
class heat.engine.constraints.Modulo(step=None, offset=None, description=None)[source]

Bases: heat.engine.constraints.Constraint

Constrain values to modulo.

Serializes to JSON as:

{
    'modulo': {'step': <step>, 'offset': <offset>},
    'description': <description>
}
OFFSET = 'offset'
STEP = 'step'
valid_types = ('INTEGER', 'NUMBER')
class heat.engine.constraints.Range(min=None, max=None, description=None)[source]

Bases: heat.engine.constraints.Constraint

Constrain values within a range.

Serializes to JSON as:

{
    'range': {'min': <min>, 'max': <max>},
    'description': <description>
}
MAX = 'max'
MIN = 'min'
valid_types = ('INTEGER', 'NUMBER')
class heat.engine.constraints.Schema(data_type, description=None, default=None, schema=None, required=False, constraints=None, label=None, immutable=False)[source]

Bases: _abcoll.Mapping

Schema base class for validating properties or parameters.

Schema objects are serializable to dictionaries following a superset of the HOT input Parameter schema using dict().

Serialises to JSON in the form:

{
    'type': 'list',
    'required': False
    'constraints': [
        {
            'length': {'min': 1},
            'description': 'List must not be empty'
        }
    ],
    'schema': {
        '*': {
            'type': 'string'
        }
    },
    'description': 'An example list property.'
}
ANY = 'Any'
BOOLEAN = 'Boolean'
BOOLEAN_TYPE = 'BOOLEAN'
CONSTRAINTS = 'constraints'
DEFAULT = 'default'
DESCRIPTION = 'description'
IMMUTABLE = 'immutable'
INTEGER = 'Integer'
INTEGER_TYPE = 'INTEGER'
KEYS = ('type', 'description', 'default', 'schema', 'required', 'constraints', 'immutable')
LIST = 'List'
LIST_TYPE = 'LIST'
MAP = 'Map'
MAP_TYPE = 'MAP'
NUMBER = 'Number'
NUMBER_TYPE = 'NUMBER'
REQUIRED = 'required'
SCHEMA = 'schema'
STRING = 'String'
STRING_TYPE = 'STRING'
TYPE = 'type'
TYPES = ('Integer', 'String', 'Number', 'Boolean', 'Map', 'List', 'Any')
TYPE_KEYS = ('INTEGER', 'STRING', 'NUMBER', 'BOOLEAN', 'MAP', 'LIST')
set_default(default=None)[source]

Set the default value for this Schema object.

static str_to_num(value)[source]

Convert a string representation of a number into a numeric type.

to_schema_type(value)[source]

Returns the value in the schema’s data type.

validate(context=None)[source]

Validates the schema.

This method checks if the schema itself is valid, and if the default value - if present - complies to the schema’s constraints.

validate_constraints(value, context=None, skipped=None)[source]
Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.