Heat constraints should be refactored to be common across parameters and properties

Bug #1230229 reported by Thomas Spatzier
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Medium
Thomas Spatzier

Bug Description

Currently, a couple of constraint classes (Constraint base class, AllowedValues, ...) are defined in properties.py but constraints are actually common across properties and parameters. At the moment those classes cannot be used in properties.py and parameters.py without having cyclic dependencies.

Suggestion is to factor the constraint classes into a separate file constraints.py so they can be used in both properties.py and parameters.py.

This issues was raised in contect of bug #1224111 but it was decided to move the refactoring into the next release.

Changed in heat:
assignee: nobody → Thomas Spatzier (thomas-spatzier)
Steven Hardy (shardy)
Changed in heat:
milestone: none → icehouse-1
status: New → Triaged
importance: Undecided → Medium
Changed in heat:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat (master)

Fix proposed to branch: master
Review: https://review.openstack.org/58299

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

Reviewed: https://review.openstack.org/58299
Committed: http://github.com/openstack/heat/commit/eae9a2ad3f5d3dcbcbb10c88a55fd81f1fe2dd56
Submitter: Jenkins
Branch: master

commit eae9a2ad3f5d3dcbcbb10c88a55fd81f1fe2dd56
Author: Thomas Spatzier <email address hidden>
Date: Fri Nov 22 20:24:41 2013 +0100

    Factor Schema out of properties.py for re-use

    There is currently some function duplication in Heat for schema
    validation. There is properties.Schema and a ParamSchema class which
    do mostly the same, but each with their own code.
    It would be good to have a common implementation for property and
    parameter validation with only property or parameter specific code
    implemented in sub-classes.
    The current Schema class in properties.py cannot be used in
    parameters.py due to cyclic import dependencies that would arise.

    This patch factors the Schema class and Constraint classes into their
    own file which can then be imported by both properties.py and
    parameters.py. For property schema specific code, a class
    PropertySchema is introduced as derived from the common Schema class.

    The code of the Schema and Constraint classes is unchanged except for
    absolutely refactoring work.

    In a subsequent patch, I plan to provide the code to base ParamSchema
    on the common Schema class.

    Change-Id: I833edd8fad316220f56d6727fe1e3409f8fda6ee
    Partial-Bug: #1230229

Changed in heat:
milestone: icehouse-1 → icehouse-2
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat (master)

Fix proposed to branch: master
Review: https://review.openstack.org/65688

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/67171

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/67183

Changed in heat:
milestone: icehouse-2 → icehouse-3
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

Reviewed: https://review.openstack.org/65688
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=c3dad3f0625172d9ca41605787c0ccef82d60c5f
Submitter: Jenkins
Branch: master

commit c3dad3f0625172d9ca41605787c0ccef82d60c5f
Author: Thomas Spatzier <email address hidden>
Date: Thu Jan 9 14:15:09 2014 +0100

    Enable better sub-classing of common Schema class

    This patch is first in a series of patches to unify the code for
    property and parameter validation based on a common Schema class.

    The current patch refactors the existing Schema class in
    constraints.py so it will in a subsequent patch be easier to
    sub-class it, i.e. to rebase the parameters schema class on it.

    For example, sub-classes will be able to override uppercase/
    lowercase spelling of data type names etc., which will save us
    translation between CFN and HOT specifics in the engine.

    Change-Id: I0418a00f045af590b17500716a74b8cc6ff72409
    Partial-Bug: #1230229
    Implements: blueprint schema-code-consolidation

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Reviewed: https://review.openstack.org/67171
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=c26a43b69849e780a1ac3a68b5f6d4da520d7362
Submitter: Jenkins
Branch: master

commit c26a43b69849e780a1ac3a68b5f6d4da520d7362
Author: Thomas Spatzier <email address hidden>
Date: Wed Jan 15 23:15:52 2014 +0100

    Move param format for template-validate to API

    This patch is second in a series of patches to unify the code for
    property and parameter validation based on a common Schema class.

    The current patch moves the formating of parameters during the
    template-validate API into a new function in the API layer.
    Previously, only a dictionary of internal parameter schema
    objects was returned, which meant a close coupling between
    the engine's internal data structures and the API expected
    format.
    With the new format function in the API, we are able to better
    separate internal data from API formats and can maintain API
    compatibility when refactoring inside the engine.
    In a subsequent patch, we can thus move to a consolidated code
    base for parameter schema validation (based on the common Schema
    class) and don't have to distinguish between CFN and HOT inside
    the engine.

    Change-Id: I302e58906a0b530d967cbae808d0cf6b2fdcb3bc
    Partial-Bug: #1230229
    Implements: blueprint schema-code-consolidation

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Reviewed: https://review.openstack.org/67183
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=009c2a214170f56da166874103e67576ddcc2a34
Submitter: Jenkins
Branch: master

commit 009c2a214170f56da166874103e67576ddcc2a34
Author: Thomas Spatzier <email address hidden>
Date: Wed Jan 15 23:45:00 2014 +0100

    Refactor Parameters Schema based on common Schema

    This patch is last in a series of patches to unify the code for
    property and parameter validation based on a common Schema class.

    The current patch refactors the implementation of the Parameters
    Schema to be a sub-class of the common Schema class in constraints.py
    so that most of the schema validation code can be shared for property
    and parameter validation and no two different code paths for mostly
    indentical functionality exist.

    Change-Id: I4a1dc2e65e7b118347933bdf18aba49c058aa28b
    Closes-Bug: #1230229
    Implements: blueprint schema-code-consolidation

Changed in heat:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in heat:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in heat:
milestone: icehouse-3 → 2014.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.