diff options
author | Steve Baker <sbaker@redhat.com> | 2016-05-27 17:07:03 +1200 |
---|---|---|
committer | Steve Baker <sbaker@redhat.com> | 2016-08-15 22:17:30 +0000 |
commit | 3ab0ede98c6dc0c0327977be994c139113fc0489 (patch) | |
tree | 63ffe0cda29fdc7e53887290615a3cc81f03e37c /heat/objects | |
parent | d072f6e7f195d6488d70b5246e67fdba1a5f5286 (diff) | |
download | heat-3ab0ede98c6dc0c0327977be994c139113fc0489.tar.gz |
Always eager load the raw_template for a stack
The vast majority of stack fetches are immediately followed by a
raw_template fetch, so this change always eagerly fetches the
raw_template for every stack fetch.
During stack versioned object creation the stack's raw_template object
is used to construct the versioned raw template object.
Change-Id: I1a6fb8fb7d069b50dd5d623c989acd5582818ae1
Related-Bug: #1479723
Related-Bug: #1523748
Diffstat (limited to 'heat/objects')
-rw-r--r-- | heat/objects/raw_template.py | 10 | ||||
-rw-r--r-- | heat/objects/stack.py | 6 |
2 files changed, 9 insertions, 7 deletions
diff --git a/heat/objects/raw_template.py b/heat/objects/raw_template.py index fee181378..de1fb4821 100644 --- a/heat/objects/raw_template.py +++ b/heat/objects/raw_template.py @@ -52,7 +52,7 @@ class RawTemplate( } @staticmethod - def _from_db_object(context, tpl, db_tpl): + def from_db_object(context, tpl, db_tpl): for field in tpl.fields: tpl[field] = db_tpl[field] @@ -85,7 +85,7 @@ class RawTemplate( @classmethod def get_by_id(cls, context, template_id): raw_template_db = db_api.raw_template_get(context, template_id) - return cls._from_db_object(context, cls(), raw_template_db) + return cls.from_db_object(context, cls(), raw_template_db) @classmethod def encrypt_hidden_parameters(cls, tmpl): @@ -100,8 +100,8 @@ class RawTemplate( @classmethod def create(cls, context, values): - return cls._from_db_object(context, cls(), - db_api.raw_template_create(context, values)) + return cls.from_db_object(context, cls(), + db_api.raw_template_create(context, values)) @classmethod def update_by_id(cls, context, template_id, values): @@ -109,7 +109,7 @@ class RawTemplate( # table, not in the old location of raw_template.files if 'files_id' in values and values['files_id']: values['files'] = None - return cls._from_db_object( + return cls.from_db_object( context, cls(), db_api.raw_template_update(context, template_id, values)) diff --git a/heat/objects/stack.py b/heat/objects/stack.py index 769dccdcf..1eeffd583 100644 --- a/heat/objects/stack.py +++ b/heat/objects/stack.py @@ -68,8 +68,10 @@ class Stack( for field in stack.fields: if field == 'raw_template': stack['raw_template'] = ( - raw_template.RawTemplate.get_by_id( - context, db_stack['raw_template_id'])) + raw_template.RawTemplate.from_db_object( + context, + raw_template.RawTemplate(), + db_stack['raw_template'])) else: stack[field] = db_stack.__dict__.get(field) stack._context = context |