Deprecate the Resource.parsed_template() method

Anything this was used for can now be done much better using the
ResourceDefinition API.

Change-Id: Ied36742221ed5e63438b3499e176bbccda4aa082
This commit is contained in:
Zane Bitter 2016-05-01 19:06:09 -05:00
parent 0496c3cad6
commit b3e59321a4
4 changed files with 21 additions and 17 deletions

View File

@ -14,6 +14,7 @@
import base64
import contextlib
import datetime as dt
import warnings
import weakref
from oslo_config import cfg
@ -346,10 +347,10 @@ class Resource(object):
def __eq__(self, other):
"""Allow == comparison of two resources."""
# For the purposes of comparison, we declare two resource objects
# equal if their names and parsed_templates are the same
# equal if their names and resolved templates are the same
if isinstance(other, Resource):
return (self.name == other.name) and (
self.parsed_template() == other.parsed_template())
return ((self.name == other.name) and
(self.t.freeze() == other.t.freeze()))
return NotImplemented
def __ne__(self, other):
@ -481,12 +482,16 @@ class Resource(object):
May be limited to only one section of the data, in which case a default
value may also be supplied.
"""
default = default or {}
warnings.warn('Resource.parsed_template() is deprecated and will be '
'removed in the Ocata release. Use the '
'ResourceDefinition API instead.',
DeprecationWarning)
frozen = self.t.freeze()
if section is None:
template = self.t
else:
template = self.t.get(section, default)
return function.resolve(template)
return frozen
return frozen.get(section, default or {})
def frozen_definition(self):
if self._stored_properties_data is not None:

View File

@ -350,7 +350,7 @@ class CeilometerAlarm(resource.Resource):
# to ceilometer.
wr = watchrule.WatchRule(context=self.context,
watch_name=self.physical_resource_name(),
rule=self.parsed_template('Properties'),
rule=dict(self.properties),
stack_id=self.stack.id)
wr.state = wr.CEILOMETER_CONTROLLED
wr.store()

View File

@ -154,7 +154,7 @@ class CloudWatchAlarm(resource.Resource):
def handle_create(self):
wr = watchrule.WatchRule(context=self.context,
watch_name=self.physical_resource_name(),
rule=self.parsed_template('Properties'),
rule=dict(self.properties),
stack_id=self.stack.id)
wr.store()
@ -168,7 +168,7 @@ class CloudWatchAlarm(resource.Resource):
wr = loader(self.context,
watch_name=self.physical_resource_name())
wr.rule = self.parsed_template('Properties')
wr.rule = dict(self.properties)
wr.store()
def handle_delete(self):

View File

@ -12,7 +12,6 @@
# under the License.
import collections
import copy
from heatclient import exc
from heatclient.v1 import stacks
@ -584,7 +583,7 @@ class RemoteStackTest(tests_common.HeatTestCase):
rsrc = self.create_remote_stack()
props = copy.deepcopy(rsrc.parsed_template()['Properties'])
props = dict(rsrc.properties)
props['parameters']['name'] = 'bar'
update_snippet = rsrc_defn.ResourceDefinition(rsrc.name,
rsrc.type(),
@ -612,7 +611,7 @@ class RemoteStackTest(tests_common.HeatTestCase):
def test_update_with_replace(self):
rsrc = self.create_remote_stack()
props = copy.deepcopy(rsrc.parsed_template()['Properties'])
props = dict(rsrc.properties)
props['context']['region_name'] = 'RegionOne'
update_snippet = rsrc_defn.ResourceDefinition(rsrc.name,
rsrc.type(),
@ -627,7 +626,7 @@ class RemoteStackTest(tests_common.HeatTestCase):
rsrc = self.create_remote_stack()
props = copy.deepcopy(rsrc.parsed_template()['Properties'])
props = dict(rsrc.properties)
props['parameters']['name'] = 'bar'
update_snippet = rsrc_defn.ResourceDefinition(rsrc.name,
rsrc.type(),
@ -650,7 +649,7 @@ class RemoteStackTest(tests_common.HeatTestCase):
rsrc = self.create_remote_stack()
props = copy.deepcopy(rsrc.parsed_template()['Properties'])
props = dict(rsrc.properties)
update_snippet = rsrc_defn.ResourceDefinition(rsrc.name,
rsrc.type(),
props)
@ -683,7 +682,7 @@ class RemoteStackTest(tests_common.HeatTestCase):
rsrc = self.create_remote_stack()
rsrc.state_set(rsrc.CHECK, rsrc.FAILED)
props = copy.deepcopy(rsrc.parsed_template()['Properties'])
props = dict(rsrc.properties)
update_snippet = rsrc_defn.ResourceDefinition(rsrc.name,
rsrc.type(),
props)