Show deprecated warnings when import parser

Classes in parser.py are already split to stack.py and
template.py, it's not recommended to import it.

Closes-Bug: #1442011
Change-Id: Ia8cc0ca07e7926fe8b7d9f5c89b39053a799e689
changes/67/171967/4
Ethan Lynn 8 years ago
parent e53b3ff73b
commit 65a77a3105
  1. 4
      contrib/cinder_volume_type/cinder_volume_type/tests/test_cinder_volume_type.py
  2. 4
      contrib/heat_keystone/heat_keystone/tests/test_project.py
  3. 4
      contrib/heat_keystone/heat_keystone/tests/test_role.py
  4. 4
      contrib/heat_zaqar/heat_zaqar/tests/test_queue.py
  5. 4
      contrib/nova_flavor/nova_flavor/tests/test_nova_flavor.py
  6. 2
      contrib/rackspace/rackspace/tests/test_rackspace_cloud_server.py
  7. 2
      contrib/rackspace/rackspace/tests/test_rackspace_dns.py
  8. 4
      heat/engine/parser.py
  9. 19
      heat/tests/aws/test_waitcondition.py
  10. 9
      heat/tests/db/test_sqlalchemy_api.py
  11. 2
      heat/tests/neutron/test_neutron_security_group.py
  12. 7
      heat/tests/openstack/test_waitcondition.py
  13. 5
      heat/tests/test_ceilometer_alarm.py
  14. 4
      heat/tests/test_cloud_config.py
  15. 2
      heat/tests/test_dbinstance.py
  16. 5
      heat/tests/test_eip.py
  17. 2
      heat/tests/test_empty_stack.py
  18. 15
      heat/tests/test_engine_api_utils.py
  19. 6
      heat/tests/test_event.py
  20. 9
      heat/tests/test_function.py
  21. 19
      heat/tests/test_glance_image.py
  22. 139
      heat/tests/test_hot.py
  23. 9
      heat/tests/test_instance.py
  24. 15
      heat/tests/test_instance_network.py
  25. 13
      heat/tests/test_metadata_refresh.py
  26. 2
      heat/tests/test_multi_part.py
  27. 32
      heat/tests/test_nested_stack.py
  28. 5
      heat/tests/test_os_database.py
  29. 45
      heat/tests/test_provider_template.py
  30. 2
      heat/tests/test_random_string.py
  31. 7
      heat/tests/test_remote_stack.py
  32. 14
      heat/tests/test_resource.py
  33. 2
      heat/tests/test_security_group.py
  34. 6
      heat/tests/test_server.py
  35. 9
      heat/tests/test_server_tags.py
  36. 2
      heat/tests/test_signal.py
  37. 4
      heat/tests/test_software_config.py
  38. 2
      heat/tests/test_software_deployment.py
  39. 6
      heat/tests/test_stack_collect_attributes.py
  40. 2
      heat/tests/test_structured_config.py
  41. 71
      heat/tests/test_validate.py
  42. 4
      heat/tests/test_vpc.py
  43. 8
      heat/tests/test_watch.py

@ -13,8 +13,8 @@
import mock
from heat.engine import parser
from heat.engine import resource
from heat.engine import stack
from heat.engine import template
from heat.tests import common
from heat.tests import utils
@ -46,7 +46,7 @@ class CinderVolumeTypeTest(common.HeatTestCase):
# explicitly.
resource._register_class('OS::Cinder::VolumeType', CinderVolumeType)
self.stack = parser.Stack(
self.stack = stack.Stack(
self.ctx, 'cinder_volume_type_test_stack',
template.Template(volume_type_template)
)

@ -14,9 +14,9 @@
import mock
from heat.engine import constraints
from heat.engine import parser
from heat.engine import properties
from heat.engine import resource
from heat.engine import stack
from heat.engine import template
from heat.tests import common
from heat.tests import utils
@ -51,7 +51,7 @@ class KeystoneProjectTest(common.HeatTestCase):
# For unit testing purpose. Register resource provider explicitly.
resource._register_class(RESOURCE_TYPE, KeystoneProject)
self.stack = parser.Stack(
self.stack = stack.Stack(
self.ctx, 'test_stack_keystone',
template.Template(keystone_project_template)
)

@ -13,8 +13,8 @@
import mock
from heat.engine import parser
from heat.engine import resource
from heat.engine import stack
from heat.engine import template
from heat.tests import common
from heat.tests import utils
@ -46,7 +46,7 @@ class KeystoneRoleTest(common.HeatTestCase):
# For unit testing purpose. Register resource provider explicitly.
resource._register_class(RESOURCE_TYPE, KeystoneRole)
self.stack = parser.Stack(
self.stack = stack.Stack(
self.ctx, 'test_stack_keystone',
template.Template(keystone_role_template)
)

@ -16,10 +16,10 @@ import six
from heat.common import exception
from heat.common import template_format
from heat.engine import parser
from heat.engine import resource
from heat.engine import rsrc_defn
from heat.engine import scheduler
from heat.engine import stack
from heat.engine import template
from heat.tests import common
from heat.tests import utils
@ -88,7 +88,7 @@ class ZaqarMessageQueueTest(common.HeatTestCase):
def parse_stack(self, t):
stack_name = 'test_stack'
tmpl = template.Template(t)
self.stack = parser.Stack(self.ctx, stack_name, tmpl)
self.stack = stack.Stack(self.ctx, stack_name, tmpl)
self.stack.validate()
self.stack.store()

@ -13,8 +13,8 @@
import mock
from heat.engine import parser
from heat.engine import resource
from heat.engine import stack
from heat.engine import template
from heat.tests import common
from heat.tests.nova import fakes
@ -51,7 +51,7 @@ class NovaFlavorTest(common.HeatTestCase):
# explicitly.
resource._register_class("OS::Nova::Flavor", nova_flavor.NovaFlavor)
self.stack = parser.Stack(
self.stack = stack.Stack(
self.ctx, 'nova_flavor_test_stack',
template.Template(flavor_template)
)

@ -20,9 +20,9 @@ import six
from heat.common import exception
from heat.common import template_format
from heat.engine import environment
from heat.engine import parser
from heat.engine import resource
from heat.engine import scheduler
from heat.engine import stack as parser
from heat.engine import template
from heat.tests import common
from heat.tests.nova import fakes

@ -18,10 +18,10 @@ import mock
from heat.common import exception
from heat.common import template_format
from heat.engine import environment
from heat.engine import parser
from heat.engine import resource
from heat.engine import rsrc_defn
from heat.engine import scheduler
from heat.engine import stack as parser
from heat.engine import template
from heat.tests import common
from heat.tests import utils

@ -11,11 +11,15 @@
# License for the specific language governing permissions and limitations
# under the License.
import warnings
from heat.engine import stack
from heat.engine import template
# Note: these classes are here for backwards compatibility.
# New uses of the Stack class should use stack.Stack().
#
warnings.warn('Module parser.py is deprecated. Please use class Template '
'in heat.engine.template and class Stack in heat.engine.stack.')
Template = template.Template
Stack = stack.Stack

@ -24,10 +24,11 @@ from heat.common import exception
from heat.common import identifier
from heat.common import template_format
from heat.engine import environment
from heat.engine import parser
from heat.engine.resources.aws.cfn import wait_condition_handle as aws_wch
from heat.engine import rsrc_defn
from heat.engine import scheduler
from heat.engine import stack as parser
from heat.engine import template as tmpl
from heat.objects import resource as resource_objects
from heat.tests import common
from heat.tests import utils
@ -86,8 +87,8 @@ class WaitConditionTest(common.HeatTestCase):
stub=True, stub_status=True):
params = params or {}
temp = template_format.parse(template)
template = parser.Template(temp,
env=environment.Environment(params))
template = tmpl.Template(temp,
env=environment.Environment(params))
ctx = utils.dummy_context(tenant_id='test_tenant')
stack = parser.Stack(ctx, 'test_stack', template,
disable_rollback=True)
@ -355,7 +356,7 @@ class WaitConditionHandleTest(common.HeatTestCase):
def create_stack(self, stack_name=None, stack_id=None):
temp = template_format.parse(test_template_waitcondition)
template = parser.Template(temp)
template = tmpl.Template(temp)
ctx = utils.dummy_context(tenant_id='test_tenant')
if stack_name is None:
stack_name = utils.random_name()
@ -523,11 +524,11 @@ class WaitConditionUpdateTest(common.HeatTestCase):
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://server.test:8000/v1/waitcondition')
def create_stack(self, tmpl=None):
if tmpl is None:
tmpl = test_template_wc_count
temp = template_format.parse(tmpl)
template = parser.Template(temp)
def create_stack(self, temp=None):
if temp is None:
temp = test_template_wc_count
temp_fmt = template_format.parse(temp)
template = tmpl.Template(temp_fmt)
ctx = utils.dummy_context(tenant_id='test_tenant')
stack = parser.Stack(ctx, 'test_stack', template,
disable_rollback=True)

@ -28,10 +28,11 @@ from heat.db.sqlalchemy import api as db_api
from heat.engine.clients.os import glance
from heat.engine.clients.os import nova
from heat.engine import environment
from heat.engine import parser
from heat.engine import resource as rsrc
from heat.engine.resources.aws.ec2 import instance as instances
from heat.engine import scheduler
from heat.engine import stack as parser
from heat.engine import template as tmpl
from heat.tests import common
from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils
@ -101,7 +102,7 @@ class SqlAlchemyTest(common.HeatTestCase):
def _setup_test_stack(self, stack_name, stack_id=None, owner_id=None,
stack_user_project_id=None, backup=False):
t = template_format.parse(wp_template)
template = parser.Template(
template = tmpl.Template(
t, env=environment.Environment({'KeyName': 'test'}))
stack_id = stack_id or str(uuid.uuid4())
stack = parser.Stack(self.ctx, stack_name, template,
@ -283,8 +284,8 @@ class SqlAlchemyTest(common.HeatTestCase):
def test_encryption(self):
stack_name = 'test_encryption'
(tmpl, stack) = self._setup_test_stack(stack_name)
resource_defns = tmpl.resource_definitions(stack)
(template, stack) = self._setup_test_stack(stack_name)
resource_defns = template.resource_definitions(stack)
cs = MyResource('cs_encryption',
resource_defns['WebServer'],
stack)

@ -18,8 +18,8 @@ from novaclient.v2 import security_groups as nova_sg
from heat.common import exception
from heat.common import template_format
from heat.engine import parser
from heat.engine import scheduler
from heat.engine import stack as parser
from heat.engine import template
from heat.tests import common
from heat.tests.nova import fakes as fakes_nova

@ -21,9 +21,10 @@ from heat.common import identifier
from heat.common import template_format
from heat.engine.clients.os import heat_plugin
from heat.engine import environment
from heat.engine import parser
from heat.engine import resource
from heat.engine.resources.openstack.heat import wait_condition_handle as h_wch
from heat.engine import stack as parser
from heat.engine import template as tmpl
from heat.objects import resource as resource_objects
from heat.tests import common
from heat.tests import utils
@ -79,8 +80,8 @@ class HeatWaitConditionTest(common.HeatTestCase):
params={},
stub=True, stub_status=True):
temp = template_format.parse(template)
template = parser.Template(temp,
env=environment.Environment(params))
template = tmpl.Template(temp,
env=environment.Environment(params))
ctx = utils.dummy_context(tenant_id=self.tenant_id)
stack = parser.Stack(ctx, 'test_stack', template,
disable_rollback=True)

@ -23,12 +23,13 @@ import six
from heat.common import exception
from heat.common import template_format
from heat.engine.clients.os import ceilometer
from heat.engine import parser
from heat.engine import properties as props
from heat.engine import resource
from heat.engine.resources.openstack.ceilometer import alarm
from heat.engine import rsrc_defn
from heat.engine import scheduler
from heat.engine import stack as parser
from heat.engine import template as tmpl
from heat.tests import common
from heat.tests import generic_resource
from heat.tests import utils
@ -127,7 +128,7 @@ class CeilometerAlarmTest(common.HeatTestCase):
if template is None:
template = alarm_template
temp = template_format.parse(template)
template = parser.Template(temp)
template = tmpl.Template(temp)
ctx = utils.dummy_context()
ctx.tenant_id = 'test_tenant'
stack = parser.Stack(ctx, utils.random_name(), template,

@ -15,8 +15,8 @@ import uuid
import mock
from heat.engine import parser
from heat.engine.resources.openstack.heat import cloud_config
from heat.engine import stack
from heat.engine import template
from heat.tests import common
from heat.tests import utils
@ -30,7 +30,7 @@ class CloudConfigTest(common.HeatTestCase):
self.properties = {
'cloud_config': {'foo': 'bar'}
}
self.stack = parser.Stack(
self.stack = stack.Stack(
self.ctx, 'software_config_test_stack',
template.Template({
'HeatTemplateFormatVersion': '2012-12-12',

@ -14,9 +14,9 @@
from heat.common import template_format
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import parser
from heat.engine import properties
from heat.engine import resource
from heat.engine import stack as parser
from heat.engine import template
from heat.tests import common
from heat.tests import utils

@ -21,10 +21,11 @@ import six
from heat.common import exception
from heat.common import template_format
from heat.engine.clients.os import nova
from heat.engine import parser
from heat.engine.resources.aws.ec2 import eip
from heat.engine import rsrc_defn
from heat.engine import scheduler
from heat.engine import stack as parser
from heat.engine import template as tmpl
from heat.tests import common
from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils
@ -394,7 +395,7 @@ class AllocTest(common.HeatTestCase):
def _setup_test_stack(self, stack_name):
t = template_format.parse(ipassoc_template_validate)
template = parser.Template(t)
template = tmpl.Template(t)
stack = parser.Stack(utils.dummy_context(), stack_name,
template, stack_id='12233',
stack_user_project_id='8888')

@ -12,7 +12,7 @@
# under the License.
from heat.common import template_format
from heat.engine import parser
from heat.engine import stack as parser
from heat.engine import template
from heat.tests import common
from heat.tests import utils

@ -24,8 +24,9 @@ from heat.common import template_format
from heat.engine import api
from heat.engine import event
from heat.engine import parameters
from heat.engine import parser
from heat.engine import resource
from heat.engine import stack as parser
from heat.engine import template
from heat.rpc import api as rpc_api
from heat.tests import common
from heat.tests import generic_resource as generic_rsrc
@ -38,7 +39,7 @@ class FormatTest(common.HeatTestCase):
def setUp(self):
super(FormatTest, self).setUp()
template = parser.Template({
tmpl = template.Template({
'HeatTemplateFormatVersion': '2012-12-12',
'Resources': {
'generic1': {'Type': 'GenericResourceType'},
@ -52,7 +53,7 @@ class FormatTest(common.HeatTestCase):
resource._register_class('ResWithComplexPropsAndAttrs',
generic_rsrc.ResWithComplexPropsAndAttrs)
self.stack = parser.Stack(utils.dummy_context(), 'test_stack',
template, stack_id=str(uuid.uuid4()))
tmpl, stack_id=str(uuid.uuid4()))
def _dummy_event(self, event_id):
resource = self.stack['generic1']
@ -145,7 +146,7 @@ class FormatTest(common.HeatTestCase):
self.assertIn('a2', formatted_attributes)
def _get_formatted_resource_properties(self, res_name):
tmpl = parser.Template(template_format.parse('''
tmpl = template.Template(template_format.parse('''
heat_template_version: 2013-05-23
resources:
resource1:
@ -341,7 +342,7 @@ class FormatTest(common.HeatTestCase):
self.assertEqual('foobar', info[rpc_api.STACK_OUTPUTS])
def test_format_stack_outputs(self):
template = parser.Template({
tmpl = template.Template({
'HeatTemplateFormatVersion': '2012-12-12',
'Resources': {
'generic': {'Type': 'GenericResourceType'}
@ -357,7 +358,7 @@ class FormatTest(common.HeatTestCase):
}
})
stack = parser.Stack(utils.dummy_context(), 'test_stack',
template, stack_id=str(uuid.uuid4()))
tmpl, stack_id=str(uuid.uuid4()))
stack.action = 'CREATE'
stack.status = 'COMPLETE'
stack['generic'].action = 'CREATE'
@ -908,7 +909,7 @@ class FormatValidateParameterTest(common.HeatTestCase):
"""
t = template_format.parse(self.template % self.param)
tmpl = parser.Template(t)
tmpl = template.Template(t)
tmpl_params = parameters.Parameters(None, tmpl)
tmpl_params.validate(validate_value=False)

@ -14,9 +14,9 @@
from oslo_config import cfg
from heat.engine import event
from heat.engine import parser
from heat.engine import resource
from heat.engine import rsrc_defn
from heat.engine import stack
from heat.engine import template
from heat.objects import event as event_object
from heat.objects import stack as stack_object
@ -51,8 +51,8 @@ class EventTest(common.HeatTestCase):
resource._register_class('ResourceWithRequiredProps',
generic_rsrc.ResourceWithRequiredProps)
self.stack = parser.Stack(self.ctx, 'event_load_test_stack',
template.Template(tmpl))
self.stack = stack.Stack(self.ctx, 'event_load_test_stack',
template.Template(tmpl))
self.stack.store()
self.resource = self.stack['EventTestResource']

@ -21,9 +21,10 @@ from heat.common.i18n import _
from heat.engine.cfn import functions
from heat.engine import environment
from heat.engine import function
from heat.engine import parser
from heat.engine import resource
from heat.engine import rsrc_defn
from heat.engine import stack
from heat.engine import template
from heat.tests import common
from heat.tests import generic_resource as generic_rsrc
from heat.tests import utils
@ -175,10 +176,10 @@ class ValidateGetAttTest(common.HeatTestCase):
env.load({u'resource_registry':
{u'OS::Test::FakeResource': u'OverwrittenFnGetAttType'}})
self.stack = parser.Stack(
self.stack = stack.Stack(
utils.dummy_context(), 'test_stack',
parser.Template({"HeatTemplateFormatVersion": "2012-12-12"},
env=env),
template.Template({"HeatTemplateFormatVersion": "2012-12-12"},
env=env),
stack_id=str(uuid.uuid4()))
res_defn = rsrc_defn.ResourceDefinition('test_rsrc',
'OS::Test::GenericResource')

@ -17,9 +17,10 @@ import six
from heat.common import exception
from heat.common import template_format
from heat.engine import parser
from heat.engine import resource
from heat.engine.resources.openstack.glance import glance_image as gi
from heat.engine import stack as parser
from heat.engine import template
from heat.tests import common
from heat.tests import utils
@ -68,7 +69,7 @@ class GlanceImageTest(common.HeatTestCase):
tpl = template_format.parse(image_template)
self.stack = parser.Stack(
self.ctx, 'glance_image_test_stack',
parser.Template(tpl)
template.Template(tpl)
)
self.my_image = self.stack['my_image']
@ -94,7 +95,7 @@ class GlanceImageTest(common.HeatTestCase):
tpl = template_format.parse(image_template_validate)
stack = parser.Stack(
self.ctx, 'glance_image_stack_validate',
parser.Template(tpl)
template.Template(tpl)
)
image = stack['image']
image.t['Properties']['min_disk'] = -1
@ -106,7 +107,7 @@ class GlanceImageTest(common.HeatTestCase):
tpl = template_format.parse(image_template_validate)
stack = parser.Stack(
self.ctx, 'glance_image_stack_validate',
parser.Template(tpl)
template.Template(tpl)
)
image = stack['image']
image.t['Properties']['min_ram'] = -1
@ -118,7 +119,7 @@ class GlanceImageTest(common.HeatTestCase):
tpl = template_format.parse(image_template_validate)
stack = parser.Stack(
self.ctx, 'glance_image_stack_validate',
parser.Template(tpl)
template.Template(tpl)
)
image = stack['image']
image.t['Properties'].pop('disk_format')
@ -130,7 +131,7 @@ class GlanceImageTest(common.HeatTestCase):
tpl = template_format.parse(image_template_validate)
stack = parser.Stack(
self.ctx, 'glance_image_stack_validate',
parser.Template(tpl)
template.Template(tpl)
)
image = stack['image']
image.t['Properties']['disk_format'] = 'incorrect_format'
@ -143,7 +144,7 @@ class GlanceImageTest(common.HeatTestCase):
tpl = template_format.parse(image_template_validate)
stack = parser.Stack(
self.ctx, 'glance_image_stack_validate',
parser.Template(tpl)
template.Template(tpl)
)
image = stack['image']
image.t['Properties'].pop('container_format')
@ -155,7 +156,7 @@ class GlanceImageTest(common.HeatTestCase):
tpl = template_format.parse(image_template_validate)
stack = parser.Stack(
self.ctx, 'glance_image_stack_validate',
parser.Template(tpl)
template.Template(tpl)
)
image = stack['image']
image.t['Properties']['container_format'] = 'incorrect_format'
@ -168,7 +169,7 @@ class GlanceImageTest(common.HeatTestCase):
tpl = template_format.parse(image_template_validate)
stack = parser.Stack(
self.ctx, 'glance_image_stack_validate',
parser.Template(tpl)
template.Template(tpl)
)
image = stack['image']
image.t['Properties'].pop('location')

@ -24,10 +24,10 @@ from heat.engine.hot import functions as hot_functions
from heat.engine.hot import parameters as hot_param
from heat.engine.hot import template as hot_template
from heat.engine import parameters
from heat.engine import parser
from heat.engine import resource
from heat.engine import resources
from heat.engine import rsrc_defn
from heat.engine import stack as parser
from heat.engine import template
from heat.tests import common
from heat.tests import generic_resource as generic_rsrc
@ -104,7 +104,7 @@ class HOTemplateTest(common.HeatTestCase):
def test_defaults(self):
"""Test default content behavior of HOT template."""
tmpl = parser.Template(hot_tpl_empty)
tmpl = template.Template(hot_tpl_empty)
# check if we get the right class
self.assertIsInstance(tmpl, hot_template.HOTemplate20130523)
# test getting an invalid section
@ -118,7 +118,7 @@ class HOTemplateTest(common.HeatTestCase):
def test_defaults_for_empty_sections(self):
"""Test default secntion's content behavior of HOT template."""
tmpl = parser.Template(hot_tpl_empty_sections)
tmpl = template.Template(hot_tpl_empty_sections)
# check if we get the right class
self.assertIsInstance(tmpl, hot_template.HOTemplate20130523)
# test getting an invalid section
@ -160,7 +160,7 @@ class HOTemplateTest(common.HeatTestCase):
'DeletionPolicy': 'dummy',
'UpdatePolicy': {'foo': 'bar'}}}
tmpl = parser.Template(hot_tpl)
tmpl = template.Template(hot_tpl)
self.assertEqual(expected, tmpl[tmpl.RESOURCES])
def test_translate_resources_bad_no_data(self):
@ -172,7 +172,7 @@ class HOTemplateTest(common.HeatTestCase):
resource1:
""")
tmpl = parser.Template(hot_tpl)
tmpl = template.Template(hot_tpl)
error = self.assertRaises(exception.StackValidationFailed,
tmpl.__getitem__, tmpl.RESOURCES)
self.assertEqual('Each resource must contain a type key.',
@ -196,7 +196,7 @@ class HOTemplateTest(common.HeatTestCase):
foo: bar
''')
tmpl = parser.Template(hot_tpl)
tmpl = template.Template(hot_tpl)
err = self.assertRaises(exception.StackValidationFailed,
tmpl.__getitem__, tmpl.RESOURCES)
self.assertEqual('u\'"Type" is not a valid keyword '
@ -221,7 +221,7 @@ class HOTemplateTest(common.HeatTestCase):
foo: bar
''')
tmpl = parser.Template(hot_tpl)
tmpl = template.Template(hot_tpl)
err = self.assertRaises(exception.StackValidationFailed,
tmpl.__getitem__, tmpl.RESOURCES)
self.assertEqual('u\'"Properties" is not a valid keyword '
@ -240,7 +240,7 @@ class HOTemplateTest(common.HeatTestCase):
depends_on: dummy
deletion_policy: dummy
''')
tmpl = parser.Template(hot_tpl)
tmpl = template.Template(hot_tpl)
error = self.assertRaises(exception.StackValidationFailed,
tmpl.__getitem__, tmpl.RESOURCES)
self.assertEqual('"resources" must contain a map of resource maps. '
@ -265,7 +265,7 @@ class HOTemplateTest(common.HeatTestCase):
foo: bar
''')
tmpl = parser.Template(hot_tpl)
tmpl = template.Template(hot_tpl)
err = self.assertRaises(exception.StackValidationFailed,
tmpl.__getitem__, tmpl.RESOURCES)
self.assertEqual('u\'"Metadata" is not a valid keyword '
@ -290,7 +290,7 @@ class HOTemplateTest(common.HeatTestCase):
foo: bar
''')
tmpl = parser.Template(hot_tpl)
tmpl = template.Template(hot_tpl)
err = self.assertRaises(exception.StackValidationFailed,
tmpl.__getitem__, tmpl.RESOURCES)
self.assertEqual('u\'"DependsOn" is not a valid keyword '
@ -315,7 +315,7 @@ class HOTemplateTest(common.HeatTestCase):
foo: bar
''')
tmpl = parser.Template(hot_tpl)
tmpl = template.Template(hot_tpl)
err = self.assertRaises(exception.StackValidationFailed,
tmpl.__getitem__, tmpl.RESOURCES)
self.assertEqual('u\'"DeletionPolicy" is not a valid keyword '
@ -340,7 +340,7 @@ class HOTemplateTest(common.HeatTestCase):
foo: bar
''')
tmpl = parser.Template(hot_tpl)
tmpl = template.Template(hot_tpl)
err = self.assertRaises(exception.StackValidationFailed,
tmpl.__getitem__, tmpl.RESOURCES)
self.assertEqual('u\'"UpdatePolicy" is not a valid keyword '
@ -360,7 +360,7 @@ class HOTemplateTest(common.HeatTestCase):
expected = {'output1': {'Description': 'output1', 'Value': 'value1'}}
tmpl = parser.Template(hot_tpl)
tmpl = template.Template(hot_tpl)
self.assertEqual(expected, tmpl[tmpl.OUTPUTS])
def test_translate_outputs_bad_no_data(self):
@ -372,7 +372,7 @@ class HOTemplateTest(common.HeatTestCase):
output1:
""")
tmpl = parser.Template(hot_tpl)
tmpl = template.Template(hot_tpl)
error = self.assertRaises(exception.StackValidationFailed,
tmpl.__getitem__, tmpl.OUTPUTS)
self.assertEqual('Each output must contain a value key.',
@ -388,7 +388,7 @@ class HOTemplateTest(common.HeatTestCase):
value: value1
""")
tmpl = parser.Template(hot_tpl)
tmpl = template.Template(hot_tpl)
error = self.assertRaises(exception.StackValidationFailed,
tmpl.__getitem__, tmpl.OUTPUTS)
self.assertEqual('"outputs" must contain a map of output maps. '
@ -406,7 +406,7 @@ class HOTemplateTest(common.HeatTestCase):
value: value1
''')
tmpl = parser.Template(hot_tpl)
tmpl = template.Template(hot_tpl)
err = self.assertRaises(exception.StackValidationFailed,
tmpl.__getitem__, tmpl.OUTPUTS)
self.assertIn('Description', six.text_type(err))
@ -422,7 +422,7 @@ class HOTemplateTest(common.HeatTestCase):
Value: value1
''')
tmpl = parser.Template(hot_tpl)
tmpl = template.Template(hot_tpl)
err = self.assertRaises(exception.StackValidationFailed,
tmpl.__getitem__, tmpl.OUTPUTS)
self.assertIn('Value', six.text_type(err))
@ -443,7 +443,7 @@ class HOTemplateTest(common.HeatTestCase):
resource_def:
type: OS::Nova::Server
''')
tmpl = parser.Template(hot_tpl)
tmpl = template.Template(hot_tpl)
stack = parser.Stack(utils.dummy_context(), 'test_stack', tmpl)
snippet = {'list_join': ["\n", {'get_attr': ['rg', 'name']}]}
self.assertEqual('', self.resolve(snippet, tmpl, stack))
@ -455,7 +455,7 @@ class HOTemplateTest(common.HeatTestCase):
'params': {'var1': 'foo', 'var2': 'bar'}}}
snippet_resolved = 'Template foo string bar'
tmpl = parser.Template(hot_tpl_empty)
tmpl = template.Template(hot_tpl_empty)
self.assertEqual(snippet_resolved, self.resolve(snippet, tmpl))
@ -466,7 +466,7 @@ class HOTemplateTest(common.HeatTestCase):
'params': {'number': 1}}}
snippet_resolved = 'Template 1 string bar'
tmpl = parser.Template(hot_tpl_empty)
tmpl = template.Template(hot_tpl_empty)
self.assertEqual(snippet_resolved, self.resolve(snippet, tmpl))
@ -477,7 +477,7 @@ class HOTemplateTest(common.HeatTestCase):
'Template $var1 string $var2']}
snippet_resolved = 'Template foo string bar'
tmpl = parser.Template(hot_tpl_empty)
tmpl = template.Template(hot_tpl_empty)
self.assertEqual(snippet_resolved, self.resolve(snippet, tmpl))
@ -492,7 +492,7 @@ class HOTemplateTest(common.HeatTestCase):
snippet = {'str_replace': [{'template': 'Template var1 string var2'},
{'params': {'var1': 'foo', 'var2': 'bar'}}]}
tmpl = parser.Template(hot_tpl_empty)
tmpl = template.Template(hot_tpl_empty)
self.assertRaises(TypeError, self.resolve, snippet, tmpl)
@ -507,7 +507,7 @@ class HOTemplateTest(common.HeatTestCase):
snippet = {'str_replace': {'tmpl': 'Template var1 string var2',
'params': {'var1': 'foo', 'var2': 'bar'}}}
tmpl = parser.Template(hot_tpl_empty)
tmpl = template.Template(hot_tpl_empty)
self.assertRaises(KeyError, self.resolve, snippet, tmpl)
@ -527,7 +527,7 @@ class HOTemplateTest(common.HeatTestCase):
snippet = {'str_replace': {'template': 12345,
'params': {'var1': 'foo', 'var2': 'bar'}}}
tmpl = parser.Template(hot_tpl_empty)
tmpl = template.Template(hot_tpl_empty)
self.assertRaises(TypeError, self.resolve, snippet, tmpl)
@ -542,7 +542,7 @@ class HOTemplateTest(common.HeatTestCase):
snippet = {'get_file': 'file:///tmp/foo.yaml'}
snippet_resolved = 'foo contents'
tmpl = parser.Template(hot_tpl_empty, files={
tmpl = template.Template(hot_tpl_empty, files={
'file:///tmp/foo.yaml': 'foo contents'
})
stack = parser.Stack(utils.dummy_context(), 'param_id_test', tmpl)
@ -553,7 +553,7 @@ class HOTemplateTest(common.HeatTestCase):
"""Test get_file function with non-string argument."""
snippet = {'get_file': ['file:///tmp/foo.yaml']}
tmpl = parser.Template(hot_tpl_empty)
tmpl = template.Template(hot_tpl_empty)
stack = parser.Stack(utils.dummy_context(), 'param_id_test', tmpl)
notStrErr = self.assertRaises(TypeError, self.resolve,
snippet, tmpl, stack)
@ -566,7 +566,7 @@ class HOTemplateTest(common.HeatTestCase):
snippet = {'get_file': 'file:///tmp/foo.yaml'}
tmpl = parser.Template(hot_tpl_empty, files={
tmpl = template.Template(hot_tpl_empty, files={
'file:///tmp/bar.yaml': 'bar contents'
})
stack = parser.Stack(utils.dummy_context(), 'param_id_test', tmpl)
@ -583,7 +583,7 @@ class HOTemplateTest(common.HeatTestCase):
snippet = {'get_file': 'file:///tmp/foo.yaml'}
snippet_resolved = '{get_file: file:///tmp/bar.yaml}'
tmpl = parser.Template(hot_tpl_empty, files={
tmpl = template.Template(hot_tpl_empty, files={
'file:///tmp/foo.yaml': snippet_resolved,
'file:///tmp/bar.yaml': 'bar content',
})
@ -597,7 +597,7 @@ class HOTemplateTest(common.HeatTestCase):
'for_each': {'%var%': ['a', 'b', 'c']}}}
snippet_resolved = ['this is a', 'this is b', 'this is c']
tmpl = parser.Template(hot_kilo_tpl_empty)
tmpl = template.Template(hot_kilo_tpl_empty)
self.assertEqual(snippet_resolved, self.resolve(snippet, tmpl))
@ -609,7 +609,7 @@ class HOTemplateTest(common.HeatTestCase):
{'key-b': 'this is b'},
{'key-c': 'this is c'}]
tmpl = parser.Template(hot_kilo_tpl_empty)
tmpl = template.Template(hot_kilo_tpl_empty)
self.assertEqual(snippet_resolved, self.resolve(snippet, tmpl))
@ -621,7 +621,7 @@ class HOTemplateTest(common.HeatTestCase):
['this is b', 'static'],
['this is c', 'static']]
tmpl = parser.Template(hot_kilo_tpl_empty)
tmpl = template.Template(hot_kilo_tpl_empty)
self.assertEqual(snippet_resolved, self.resolve(snippet, tmpl))
@ -633,7 +633,7 @@ class HOTemplateTest(common.HeatTestCase):
snippet_resolved = ['this is a-1', 'this is b-1', 'this is c-1',
'this is a-2', 'this is b-2', 'this is c-2']
tmpl = parser.Template(hot_kilo_tpl_empty)
tmpl = template.Template(hot_kilo_tpl_empty)
result = self.resolve(snippet, tmpl)
self.assertEqual(len(result), len(snippet_resolved))
@ -645,7 +645,7 @@ class HOTemplateTest(common.HeatTestCase):
Test that the repeat function reports a proper error when missing
or invalid arguments.
"""
tmpl = parser.Template(hot_kilo_tpl_empty)
tmpl = template.Template(hot_kilo_tpl_empty)
# missing for_each
snippet = {'repeat': {'template': 'this is %var%'}}
@ -675,11 +675,11 @@ class HOTemplateTest(common.HeatTestCase):
snippet = {'digest': ['md5', 'foobar']}
snippet_resolved = '3858f62230ac3c915f300c664312c63f'
tmpl = parser.Template(hot_kilo_tpl_empty)
tmpl = template.Template(hot_kilo_tpl_empty)
self.assertEqual(snippet_resolved, self.resolve(snippet, tmpl))
def test_digest_invalid_types(self):
tmpl = parser.Template(hot_kilo_tpl_empty)
tmpl = template.Template(hot_kilo_tpl_empty)
invalid_snippets = [
{'digest': 'invalid'},
@ -691,7 +691,7 @@ class HOTemplateTest(common.HeatTestCase):
self.assertIn('must be a list of strings', six.text_type(exc))
def test_digest_incorrect_number_arguments(self):
tmpl = parser.Template(hot_kilo_tpl_empty)
tmpl = template.Template(hot_kilo_tpl_empty)
invalid_snippets = [
{'digest': []},
@ -705,7 +705,7 @@ class HOTemplateTest(common.HeatTestCase):
six.text_type(exc))
def test_digest_invalid_algorithm(self):
tmpl = parser.Template(hot_kilo_tpl_empty)
tmpl = template.Template(hot_kilo_tpl_empty)
snippet = {'digest': ['invalid_algorithm', 'foobar']}
exc = self.assertRaises(ValueError, self.resolve, snippet, tmpl)
@ -725,7 +725,7 @@ class HOTemplateTest(common.HeatTestCase):
type: string
'''.format(expected_description))
tmpl = parser.Template(hot_tpl)
tmpl = template.Template(hot_tpl)
self.assertEqual(expected_description, tmpl['description'])
err_str = "can not be accessed directly"
@ -744,10 +744,11 @@ class HOTemplateTest(common.HeatTestCase):
used as an iterable.
"""
expected_description = "This can be accessed"
tmpl = parser.Template({'heat_template_version': '2013-05-23',
'description': expected_description,
'parameters':
{'foo': {'Type': 'String', 'Required': True}}})
tmpl = template.Template({'heat_template_version': '2013-05-23',
'description': expected_description,
'parameters':
{'foo': {'Type': 'String',
'Required': True}}})
self.assertEqual(expected_description, tmpl['description'])
self.assertNotIn('parameters', tmpl.keys())
@ -792,9 +793,9 @@ class HOTemplateTest(common.HeatTestCase):
update_policy={"blarg": "wibble"})
parent_resource.stack = parser.Stack(utils.dummy_context(),
'toplevel_stack',
parser.Template(hot_tpl_empty))
template.Template(hot_tpl_empty))
stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template(hot_tpl_empty),
template.Template(hot_tpl_empty),
parent_resource='parent')
stack._parent_resource = parent_resource
self.assertEqual({"foo": "bar"},
@ -809,7 +810,7 @@ class HOTemplateTest(common.HeatTestCase):
parent_resource = DummyClass()
parent_resource.metadata_set({"foo": "bar"})
tmpl = parser.Template(hot_juno_tpl_empty)
tmpl = template.Template(hot_juno_tpl_empty)
parent_resource.stack = parser.Stack(utils.dummy_context(),
'toplevel_stack',
tmpl)
@ -820,7 +821,7 @@ class HOTemplateTest(common.HeatTestCase):
deletion_policy=del_policy)
stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template(hot_tpl_empty),
template.Template(hot_tpl_empty),
parent_resource='parent')
stack._parent_resource = parent_resource
self.assertEqual('Retain',
@ -829,7 +830,7 @@ class HOTemplateTest(common.HeatTestCase):
def test_resource_facade_invalid_arg(self):
snippet = {'resource_facade': 'wibble'}
stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template(hot_tpl_empty))
template.Template(hot_tpl_empty))
error = self.assertRaises(ValueError,
self.resolve,
snippet,
@ -844,9 +845,9 @@ class HOTemplateTest(common.HeatTestCase):
parent_resource.t = rsrc_defn.ResourceDefinition('parent', 'SomeType')
parent_resource.stack = parser.Stack(utils.dummy_context(),
'toplevel_stack',
parser.Template(hot_tpl_empty))
template.Template(hot_tpl_empty))
stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template(hot_tpl_empty),
template.Template(hot_tpl_empty),
parent_resource='parent')
stack._parent_resource = parent_resource
self.assertEqual('Delete', self.resolve(snippet, stack.t, stack))
@ -854,7 +855,7 @@ class HOTemplateTest(common.HeatTestCase):
def test_removed_function(self):
snippet = {'Fn::GetAZs': ''}
stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template(hot_juno_tpl_empty))
template.Template(hot_juno_tpl_empty))
error = self.assertRaises(exception.InvalidTemplateVersion,
function.validate,
stack.t.parse(stack, snippet))
@ -876,8 +877,8 @@ class HOTemplateTest(common.HeatTestCase):
update_policy:
foo: bar
''')
source = parser.Template(hot_tpl)
empty = parser.Template(copy.deepcopy(hot_tpl_empty))
source = template.Template(hot_tpl)
empty = template.Template(copy.deepcopy(hot_tpl_empty))
stack = parser.Stack(utils.dummy_context(), 'test_stack', source)
for defn in source.resource_definitions(stack).values():
@ -977,7 +978,7 @@ class HotStackTest(common.HeatTestCase):
self.assertEqual({'value': 'resource1'}, self.resolve(snippet))
def test_set_param_id(self):
tmpl = parser.Template(hot_tpl_empty)
tmpl = template.Template(hot_tpl_empty)
self.stack = parser.Stack(self.ctx, 'param_id_test', tmpl)
self.assertEqual('None', self.stack.parameters['OS::stack_id'])
self.stack.store()
@ -988,7 +989,7 @@ class HotStackTest(common.HeatTestCase):
self.m.VerifyAll()
def test_set_wrong_param(self):
tmpl = parser.Template(hot_tpl_empty)
tmpl = template.Template(hot_tpl_empty)
stack_id = identifier.HeatIdentifier('', "stack_testit", None)
params = tmpl.parameters(None, {})
self.assertFalse(params.set_stack_id(None))
@ -1024,7 +1025,7 @@ class HotStackTest(common.HeatTestCase):
self.stack['AResource'].metadata_get()['Bar'])
def test_load_param_id(self):
tmpl = parser.Template(hot_tpl_empty)
tmpl = template.Template(hot_tpl_empty)
self.stack = parser.Stack(self.ctx, 'param_load_id_test', tmpl)
self.stack.store()
stack_identifier = self.stack.identifier()
@ -1310,7 +1311,7 @@ class StackParametersTest(common.HeatTestCase):
def test_param_refs(self):
"""Test if parameter references work."""
env = environment.Environment(self.params)
tmpl = parser.Template(self.props_template, env=env)
tmpl = template.Template(self.props_template, env=env)
stack = parser.Stack(utils.dummy_context(), 'test', tmpl,
stack_id='1ba8c334-2297-4312-8c7c-43763a988ced',
tenant_id='9913ef0a-b8be-4b33-b574-9061441bd373')
@ -1388,7 +1389,7 @@ class HOTParamValidatorTest(common.HeatTestCase):
- allowed_pattern: "[a-z]+[a-zA-Z]*"
description: %s
''' % (len_desc, pattern_desc1, pattern_desc2))
tmpl = parser.Template(hot_tpl)
tmpl = template.Template(hot_tpl)
def run_parameters(value):
tmpl.parameters(
@ -1535,7 +1536,7 @@ class HOTParamValidatorTest(common.HeatTestCase):
''')
error = self.assertRaises(
exception.InvalidSchemaError, parameters.Parameters,
"stack_testit", parser.Template(hot_tpl))
"stack_testit", template.Template(hot_tpl))
self.assertEqual("Invalid key 'foo' for parameter (param1)",
six.text_type(error))
@ -1548,7 +1549,7 @@ class HOTParamValidatorTest(common.HeatTestCase):
''')
error = self.assertRaises(
exception.InvalidSchemaError, parameters.Parameters,
"stack_testit", parser.Template(hot_tpl))
"stack_testit", template.Template(hot_tpl))
self.assertEqual("Missing parameter type for parameter: param1",
six.text_type(error))
@ -1561,7 +1562,7 @@ class HOTParamValidatorTest(common.HeatTestCase):
''')
error = self.assertRaises(
exception.InvalidSchemaError, parameters.Parameters,