Allow deletion_policy to be lowercase in HOT
This is more consistent with the rest of the HOT language. Change-Id: I445e986b067a1311efc23a5d350bd81976253a3f
This commit is contained in:
parent
0e30ace73f
commit
1a224a3f5a
@ -645,8 +645,11 @@ update_policy
|
|||||||
|
|
||||||
deletion_policy
|
deletion_policy
|
||||||
Deletion policy for the resource. The allowed deletion policies are
|
Deletion policy for the resource. The allowed deletion policies are
|
||||||
``Delete``, ``Retain``, and ``Snapshot``.
|
``Delete``, ``Retain``, and ``Snapshot``. Beginning with
|
||||||
This attribute is optional; the default policy is ``Delete``.
|
``heat_template_version`` ``2016-10-14``, the lowercase equivalents
|
||||||
|
``delete``, ``retain``, and ``snapshot`` are also allowed.
|
||||||
|
This attribute is optional; the default policy is to delete the physical
|
||||||
|
resource when deleting a resource from the stack.
|
||||||
|
|
||||||
Depending on the type of resource, the resource block might include more
|
Depending on the type of resource, the resource block might include more
|
||||||
resource specific data.
|
resource specific data.
|
||||||
|
@ -404,6 +404,17 @@ class HOTemplate20160408(HOTemplate20151015):
|
|||||||
|
|
||||||
|
|
||||||
class HOTemplate20161014(HOTemplate20160408):
|
class HOTemplate20161014(HOTemplate20160408):
|
||||||
|
deletion_policies = {
|
||||||
|
'Delete': rsrc_defn.ResourceDefinition.DELETE,
|
||||||
|
'Retain': rsrc_defn.ResourceDefinition.RETAIN,
|
||||||
|
'Snapshot': rsrc_defn.ResourceDefinition.SNAPSHOT,
|
||||||
|
|
||||||
|
# aliases added in 2016-10-14
|
||||||
|
'delete': rsrc_defn.ResourceDefinition.DELETE,
|
||||||
|
'retain': rsrc_defn.ResourceDefinition.RETAIN,
|
||||||
|
'snapshot': rsrc_defn.ResourceDefinition.SNAPSHOT,
|
||||||
|
}
|
||||||
|
|
||||||
functions = {
|
functions = {
|
||||||
'get_attr': hot_funcs.GetAttAllAttributes,
|
'get_attr': hot_funcs.GetAttAllAttributes,
|
||||||
'get_file': hot_funcs.GetFile,
|
'get_file': hot_funcs.GetFile,
|
||||||
|
@ -513,6 +513,54 @@ class HOTemplateTest(common.HeatTestCase):
|
|||||||
{'get_attr': ['rg', 'name']}]}
|
{'get_attr': ['rg', 'name']}]}
|
||||||
self.assertEqual('', self.resolve(snippet, tmpl, stack))
|
self.assertEqual('', self.resolve(snippet, tmpl, stack))
|
||||||
|
|
||||||
|
def test_deletion_policy_titlecase(self):
|
||||||
|
hot_tpl = template_format.parse('''
|
||||||
|
heat_template_version: 2016-10-14
|
||||||
|
resources:
|
||||||
|
del:
|
||||||
|
type: OS::Heat::None
|
||||||
|
deletion_policy: Delete
|
||||||
|
ret:
|
||||||
|
type: OS::Heat::None
|
||||||
|
deletion_policy: Retain
|
||||||
|
snap:
|
||||||
|
type: OS::Heat::None
|
||||||
|
deletion_policy: Snapshot
|
||||||
|
''')
|
||||||
|
|
||||||
|
rsrc_defns = template.Template(hot_tpl).resource_definitions(None)
|
||||||
|
|
||||||
|
self.assertEqual(rsrc_defn.ResourceDefinition.DELETE,
|
||||||
|
rsrc_defns['del'].deletion_policy())
|
||||||
|
self.assertEqual(rsrc_defn.ResourceDefinition.RETAIN,
|
||||||
|
rsrc_defns['ret'].deletion_policy())
|
||||||
|
self.assertEqual(rsrc_defn.ResourceDefinition.SNAPSHOT,
|
||||||
|
rsrc_defns['snap'].deletion_policy())
|
||||||
|
|
||||||
|
def test_deletion_policy(self):
|
||||||
|
hot_tpl = template_format.parse('''
|
||||||
|
heat_template_version: 2016-10-14
|
||||||
|
resources:
|
||||||
|
del:
|
||||||
|
type: OS::Heat::None
|
||||||
|
deletion_policy: delete
|
||||||
|
ret:
|
||||||
|
type: OS::Heat::None
|
||||||
|
deletion_policy: retain
|
||||||
|
snap:
|
||||||
|
type: OS::Heat::None
|
||||||
|
deletion_policy: snapshot
|
||||||
|
''')
|
||||||
|
|
||||||
|
rsrc_defns = template.Template(hot_tpl).resource_definitions(None)
|
||||||
|
|
||||||
|
self.assertEqual(rsrc_defn.ResourceDefinition.DELETE,
|
||||||
|
rsrc_defns['del'].deletion_policy())
|
||||||
|
self.assertEqual(rsrc_defn.ResourceDefinition.RETAIN,
|
||||||
|
rsrc_defns['ret'].deletion_policy())
|
||||||
|
self.assertEqual(rsrc_defn.ResourceDefinition.SNAPSHOT,
|
||||||
|
rsrc_defns['snap'].deletion_policy())
|
||||||
|
|
||||||
def test_str_replace(self):
|
def test_str_replace(self):
|
||||||
"""Test str_replace function."""
|
"""Test str_replace function."""
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user