Use the template module to access the Template class
i.e. stop using parser.Template this imports the template module as "templatem" to avoid namespace clashes with the many local variables called "template". Change-Id: I97cc893f630e46589ee71fc73c6bbbcaa86b3a62
This commit is contained in:
parent
4872f44944
commit
ff45aba3c4
@ -80,7 +80,7 @@ class MarconiMessageQueueTest(HeatTestCase):
|
||||
|
||||
def parse_stack(self, t):
|
||||
stack_name = 'test_stack'
|
||||
tmpl = parser.Template(t)
|
||||
tmpl = template.Template(t)
|
||||
self.stack = parser.Stack(self.ctx, stack_name, tmpl)
|
||||
self.stack.validate()
|
||||
self.stack.store()
|
||||
|
@ -22,6 +22,7 @@ from heat.engine import environment
|
||||
from heat.engine import parser
|
||||
from heat.engine import resource
|
||||
from heat.engine import scheduler
|
||||
from heat.engine import template
|
||||
from heat.openstack.common import uuidutils
|
||||
from heat.tests import common
|
||||
from heat.tests import utils
|
||||
@ -89,11 +90,11 @@ class CloudServersTest(common.HeatTestCase):
|
||||
|
||||
def _setup_test_stack(self, stack_name):
|
||||
t = template_format.parse(wp_template)
|
||||
template = parser.Template(t)
|
||||
stack = parser.Stack(self.ctx, stack_name, template,
|
||||
templ = template.Template(t)
|
||||
stack = parser.Stack(self.ctx, stack_name, templ,
|
||||
environment.Environment({'key_name': 'test'}),
|
||||
stack_id=uuidutils.generate_uuid())
|
||||
return (template, stack)
|
||||
return (templ, stack)
|
||||
|
||||
def _setup_test_server(self, return_server, name, image_id=None,
|
||||
override_name=False, stub_create=True, exit_code=0):
|
||||
|
@ -19,6 +19,7 @@ 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 template
|
||||
from heat.tests import common
|
||||
from heat.tests import utils
|
||||
|
||||
@ -97,16 +98,16 @@ class RackspaceDnsTest(common.HeatTestCase):
|
||||
def _setup_test_cloud_dns_instance(self, name, parsed_t):
|
||||
stack_name = '%s_stack' % name
|
||||
t = parsed_t
|
||||
template = parser.Template(t)
|
||||
templ = template.Template(t)
|
||||
stack = parser.Stack(utils.dummy_context(),
|
||||
stack_name,
|
||||
template,
|
||||
templ,
|
||||
environment.Environment({'name': 'test'}),
|
||||
stack_id=str(uuid.uuid4()))
|
||||
|
||||
instance = cloud_dns.CloudDns(
|
||||
'%s_name' % name,
|
||||
template.resource_definitions(stack)['domain'],
|
||||
templ.resource_definitions(stack)['domain'],
|
||||
stack)
|
||||
return instance
|
||||
|
||||
|
@ -17,9 +17,9 @@ import copy
|
||||
from heat.common import exception
|
||||
from heat.engine import attributes
|
||||
from heat.engine import constraints
|
||||
from heat.engine import parser
|
||||
from heat.engine import properties
|
||||
from heat.engine import stack_resource
|
||||
from heat.engine import template
|
||||
from heat.openstack.common.gettextutils import _
|
||||
|
||||
template_template = {
|
||||
@ -136,7 +136,7 @@ class ResourceGroup(stack_resource.StackResource):
|
||||
super(ResourceGroup, self).validate()
|
||||
# make sure the nested resource is valid
|
||||
test_tmpl = self._assemble_nested(1, include_all=True)
|
||||
val_templ = parser.Template(test_tmpl)
|
||||
val_templ = template.Template(test_tmpl)
|
||||
res_def = val_templ.resource_definitions(self.stack)["0"]
|
||||
res_class = self.stack.env.get_class(res_def.resource_type)
|
||||
res_inst = res_class("%s:resource_def" % self.name, res_def,
|
||||
|
@ -38,6 +38,7 @@ from heat.engine import properties
|
||||
from heat.engine import resource
|
||||
from heat.engine import resources
|
||||
from heat.engine import stack_lock
|
||||
from heat.engine import template as templatem
|
||||
from heat.engine import watchrule
|
||||
from heat.openstack.common.gettextutils import _
|
||||
from heat.openstack.common import log as logging
|
||||
@ -501,7 +502,7 @@ class EngineService(service.Service):
|
||||
|
||||
def _parse_template_and_validate_stack(self, cnxt, stack_name, template,
|
||||
params, files, args, owner_id=None):
|
||||
tmpl = parser.Template(template, files=files)
|
||||
tmpl = templatem.Template(template, files=files)
|
||||
self._validate_new_stack(cnxt, stack_name, tmpl)
|
||||
|
||||
common_params = api.extract_args(args)
|
||||
@ -618,7 +619,7 @@ class EngineService(service.Service):
|
||||
|
||||
# Now parse the template and any parameters for the updated
|
||||
# stack definition.
|
||||
tmpl = parser.Template(template, files=files)
|
||||
tmpl = templatem.Template(template, files=files)
|
||||
if len(tmpl[tmpl.RESOURCES]) > cfg.CONF.max_resources_per_stack:
|
||||
raise exception.RequestLimitExceeded(
|
||||
message=exception.StackResourceLimitExceeded.msg_fmt)
|
||||
@ -656,7 +657,7 @@ class EngineService(service.Service):
|
||||
msg = _("No Template provided.")
|
||||
return webob.exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
tmpl = parser.Template(template)
|
||||
tmpl = templatem.Template(template)
|
||||
|
||||
# validate overall template
|
||||
try:
|
||||
|
@ -19,6 +19,7 @@ from heat.engine import environment
|
||||
from heat.engine import parser
|
||||
from heat.engine import resource
|
||||
from heat.engine import scheduler
|
||||
from heat.engine import template
|
||||
from heat.openstack.common.gettextutils import _
|
||||
from heat.openstack.common import log as logging
|
||||
|
||||
@ -99,21 +100,21 @@ class StackResource(resource.Resource):
|
||||
StackResource will be returned as if it were a regular Resource.
|
||||
'''
|
||||
try:
|
||||
if isinstance(self.child_template(), parser.Template):
|
||||
template = parser.Template(self.child_template().t)
|
||||
if isinstance(self.child_template(), template.Template):
|
||||
templ = template.Template(self.child_template().t)
|
||||
else:
|
||||
template = parser.Template(self.child_template())
|
||||
templ = template.Template(self.child_template())
|
||||
params = self.child_params()
|
||||
except NotImplementedError:
|
||||
not_implemented_msg = _("Preview of '%s' not yet implemented")
|
||||
LOG.warning(not_implemented_msg % self.__class__.__name__)
|
||||
return self
|
||||
|
||||
self._validate_nested_resources(template)
|
||||
self._validate_nested_resources(templ)
|
||||
name = "%s-%s" % (self.stack.name, self.name)
|
||||
nested = parser.Stack(self.context,
|
||||
name,
|
||||
template,
|
||||
templ,
|
||||
self._nested_environment(params),
|
||||
disable_rollback=True,
|
||||
parent_resource=self,
|
||||
@ -122,8 +123,8 @@ class StackResource(resource.Resource):
|
||||
|
||||
return nested.preview_resources()
|
||||
|
||||
def _validate_nested_resources(self, template):
|
||||
total_resources = (len(template[template.RESOURCES]) +
|
||||
def _validate_nested_resources(self, templ):
|
||||
total_resources = (len(templ[templ.RESOURCES]) +
|
||||
self.stack.root_stack.total_resources())
|
||||
if (total_resources > cfg.CONF.max_resources_per_stack):
|
||||
message = exception.StackResourceLimitExceeded.msg_fmt
|
||||
@ -155,14 +156,14 @@ class StackResource(resource.Resource):
|
||||
msg = _("Recursion depth exceeds %d.") % \
|
||||
cfg.CONF.max_nested_stack_depth
|
||||
raise exception.RequestLimitExceeded(message=msg)
|
||||
if isinstance(child_template, parser.Template):
|
||||
template = child_template
|
||||
template.files = self.stack.t.files
|
||||
if isinstance(child_template, template.Template):
|
||||
templ = child_template
|
||||
templ.files = self.stack.t.files
|
||||
else:
|
||||
template = parser.Template(child_template,
|
||||
templ = template.Template(child_template,
|
||||
files=self.stack.t.files)
|
||||
self._validate_nested_resources(template)
|
||||
self._outputs_to_attribs(template)
|
||||
self._validate_nested_resources(templ)
|
||||
self._outputs_to_attribs(templ)
|
||||
|
||||
if timeout_mins is None:
|
||||
timeout_mins = self.stack.timeout_mins
|
||||
@ -171,7 +172,7 @@ class StackResource(resource.Resource):
|
||||
# should be rolled back by the parent stack on failure
|
||||
nested = parser.Stack(self.context,
|
||||
self.physical_resource_name(),
|
||||
template,
|
||||
templ,
|
||||
self._nested_environment(user_params),
|
||||
timeout_mins=timeout_mins,
|
||||
disable_rollback=True,
|
||||
@ -205,18 +206,18 @@ class StackResource(resource.Resource):
|
||||
def update_with_template(self, child_template, user_params,
|
||||
timeout_mins=None):
|
||||
"""Update the nested stack with the new template."""
|
||||
if isinstance(child_template, parser.Template):
|
||||
template = child_template
|
||||
template.files = self.stack.t.files
|
||||
if isinstance(child_template, template.Template):
|
||||
templ = child_template
|
||||
templ.files = self.stack.t.files
|
||||
else:
|
||||
template = parser.Template(child_template,
|
||||
templ = template.Template(child_template,
|
||||
files=self.stack.t.files)
|
||||
nested_stack = self.nested()
|
||||
if nested_stack is None:
|
||||
raise exception.Error(_('Cannot update %s, stack not created')
|
||||
% self.name)
|
||||
res_diff = (
|
||||
len(template[template.RESOURCES]) - len(nested_stack.resources))
|
||||
len(templ[templ.RESOURCES]) - len(nested_stack.resources))
|
||||
new_size = nested_stack.root_stack.total_resources() + res_diff
|
||||
if new_size > cfg.CONF.max_resources_per_stack:
|
||||
raise exception.RequestLimitExceeded(
|
||||
@ -229,7 +230,7 @@ class StackResource(resource.Resource):
|
||||
# should be rolled back by the parent stack on failure
|
||||
stack = parser.Stack(self.context,
|
||||
self.physical_resource_name(),
|
||||
template,
|
||||
templ,
|
||||
self._nested_environment(user_params),
|
||||
timeout_mins=timeout_mins,
|
||||
disable_rollback=True,
|
||||
@ -243,7 +244,7 @@ class StackResource(resource.Resource):
|
||||
# define their own attributes_schema.
|
||||
if not hasattr(type(self), 'attributes_schema'):
|
||||
self.attributes = None
|
||||
self._outputs_to_attribs(template)
|
||||
self._outputs_to_attribs(templ)
|
||||
|
||||
updater = scheduler.TaskRunner(nested_stack.update_task, stack)
|
||||
updater.start()
|
||||
|
@ -17,6 +17,7 @@ from heat.engine import constraints
|
||||
from heat.engine import parser
|
||||
from heat.engine import properties
|
||||
from heat.engine import resource
|
||||
from heat.engine import template
|
||||
from heat.tests.common import HeatTestCase
|
||||
from heat.tests import utils
|
||||
|
||||
@ -154,7 +155,7 @@ class DBInstanceTest(HeatTestCase):
|
||||
"""test that the Template is parsable and
|
||||
publishes the correct properties.
|
||||
"""
|
||||
templ = parser.Template(template_format.parse(rds_template))
|
||||
templ = template.Template(template_format.parse(rds_template))
|
||||
stack = parser.Stack(utils.dummy_context(), 'test_stack',
|
||||
templ)
|
||||
|
||||
|
@ -42,6 +42,7 @@ from heat.engine import resource as res
|
||||
from heat.engine.resources import instance as instances
|
||||
from heat.engine import service
|
||||
from heat.engine import stack_lock
|
||||
from heat.engine import template as templatem
|
||||
from heat.engine import watchrule
|
||||
from heat.openstack.common import threadgroup
|
||||
from heat.rpc import api as engine_api
|
||||
@ -175,7 +176,7 @@ resources:
|
||||
|
||||
def get_wordpress_stack(stack_name, ctx):
|
||||
t = template_format.parse(wp_template)
|
||||
template = parser.Template(t)
|
||||
template = templatem.Template(t)
|
||||
stack = parser.Stack(ctx, stack_name, template,
|
||||
environment.Environment({'KeyName': 'test'}))
|
||||
return stack
|
||||
@ -183,7 +184,7 @@ def get_wordpress_stack(stack_name, ctx):
|
||||
|
||||
def get_stack(stack_name, ctx, template):
|
||||
t = template_format.parse(template)
|
||||
template = parser.Template(t)
|
||||
template = templatem.Template(t)
|
||||
stack = parser.Stack(ctx, stack_name, template)
|
||||
return stack
|
||||
|
||||
@ -344,7 +345,7 @@ class StackCreateTest(HeatTestCase):
|
||||
|
||||
def test_wordpress_single_instance_stack_adopt(self):
|
||||
t = template_format.parse(wp_template)
|
||||
template = parser.Template(t)
|
||||
template = templatem.Template(t)
|
||||
ctx = utils.dummy_context()
|
||||
adopt_data = {
|
||||
'resources': {
|
||||
@ -369,7 +370,7 @@ class StackCreateTest(HeatTestCase):
|
||||
|
||||
def test_wordpress_single_instance_stack_adopt_fail(self):
|
||||
t = template_format.parse(wp_template)
|
||||
template = parser.Template(t)
|
||||
template = templatem.Template(t)
|
||||
ctx = utils.dummy_context()
|
||||
adopt_data = {
|
||||
'resources': {
|
||||
@ -436,11 +437,11 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase):
|
||||
|
||||
stack = get_wordpress_stack(stack_name, self.ctx)
|
||||
|
||||
self.m.StubOutWithMock(parser, 'Template')
|
||||
self.m.StubOutWithMock(templatem, 'Template')
|
||||
self.m.StubOutWithMock(environment, 'Environment')
|
||||
self.m.StubOutWithMock(parser, 'Stack')
|
||||
|
||||
parser.Template(template, files=None).AndReturn(stack.t)
|
||||
templatem.Template(template, files=None).AndReturn(stack.t)
|
||||
environment.Environment(params).AndReturn(stack.env)
|
||||
parser.Stack(self.ctx, stack.name,
|
||||
stack.t, stack.env, owner_id=None).AndReturn(stack)
|
||||
@ -485,11 +486,11 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase):
|
||||
|
||||
stack = get_wordpress_stack(stack_name, self.ctx)
|
||||
|
||||
self.m.StubOutWithMock(parser, 'Template')
|
||||
self.m.StubOutWithMock(templatem, 'Template')
|
||||
self.m.StubOutWithMock(environment, 'Environment')
|
||||
self.m.StubOutWithMock(parser, 'Stack')
|
||||
|
||||
parser.Template(template, files=None).AndReturn(stack.t)
|
||||
templatem.Template(template, files=None).AndReturn(stack.t)
|
||||
environment.Environment(params).AndReturn(stack.env)
|
||||
parser.Stack(self.ctx, stack.name,
|
||||
stack.t,
|
||||
@ -539,19 +540,19 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase):
|
||||
# force check for credentials on create
|
||||
stack['WebServer'].requires_deferred_auth = True
|
||||
|
||||
self.m.StubOutWithMock(parser, 'Template')
|
||||
self.m.StubOutWithMock(templatem, 'Template')
|
||||
self.m.StubOutWithMock(environment, 'Environment')
|
||||
self.m.StubOutWithMock(parser, 'Stack')
|
||||
|
||||
ctx_no_pwd = utils.dummy_context(password=None)
|
||||
ctx_no_user = utils.dummy_context(user=None)
|
||||
|
||||
parser.Template(template, files=None).AndReturn(stack.t)
|
||||
templatem.Template(template, files=None).AndReturn(stack.t)
|
||||
environment.Environment(params).AndReturn(stack.env)
|
||||
parser.Stack(ctx_no_pwd, stack.name,
|
||||
stack.t, stack.env, owner_id=None).AndReturn(stack)
|
||||
|
||||
parser.Template(template, files=None).AndReturn(stack.t)
|
||||
templatem.Template(template, files=None).AndReturn(stack.t)
|
||||
environment.Environment(params).AndReturn(stack.env)
|
||||
parser.Stack(ctx_no_user, stack.name,
|
||||
stack.t, stack.env, owner_id=None).AndReturn(stack)
|
||||
@ -587,15 +588,15 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase):
|
||||
'B': {'Type': 'GenericResourceType'},
|
||||
'C': {'Type': 'GenericResourceType'}}}
|
||||
|
||||
template = parser.Template(tpl)
|
||||
template = templatem.Template(tpl)
|
||||
stack = parser.Stack(self.ctx, stack_name, template,
|
||||
environment.Environment({}))
|
||||
|
||||
self.m.StubOutWithMock(parser, 'Template')
|
||||
self.m.StubOutWithMock(templatem, 'Template')
|
||||
self.m.StubOutWithMock(environment, 'Environment')
|
||||
self.m.StubOutWithMock(parser, 'Stack')
|
||||
|
||||
parser.Template(template, files=None).AndReturn(stack.t)
|
||||
templatem.Template(template, files=None).AndReturn(stack.t)
|
||||
environment.Environment(params).AndReturn(stack.env)
|
||||
parser.Stack(self.ctx, stack.name,
|
||||
stack.t,
|
||||
@ -861,10 +862,10 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase):
|
||||
self.m.StubOutWithMock(parser.Stack, 'load')
|
||||
parser.Stack.load(self.ctx, stack=s).AndReturn(old_stack)
|
||||
|
||||
self.m.StubOutWithMock(parser, 'Template')
|
||||
self.m.StubOutWithMock(templatem, 'Template')
|
||||
self.m.StubOutWithMock(environment, 'Environment')
|
||||
|
||||
parser.Template(template, files=None).AndReturn(stack.t)
|
||||
templatem.Template(template, files=None).AndReturn(stack.t)
|
||||
environment.Environment(params).AndReturn(stack.env)
|
||||
parser.Stack(self.ctx, stack.name,
|
||||
stack.t, stack.env, timeout_mins=60).AndReturn(stack)
|
||||
@ -896,7 +897,7 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase):
|
||||
'B': {'Type': 'GenericResourceType'},
|
||||
'C': {'Type': 'GenericResourceType'}}}
|
||||
|
||||
template = parser.Template(tpl)
|
||||
template = templatem.Template(tpl)
|
||||
|
||||
old_stack = parser.Stack(self.ctx, stack_name, template)
|
||||
sid = old_stack.store()
|
||||
@ -908,10 +909,10 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase):
|
||||
self.m.StubOutWithMock(parser.Stack, 'load')
|
||||
parser.Stack.load(self.ctx, stack=s).AndReturn(old_stack)
|
||||
|
||||
self.m.StubOutWithMock(parser, 'Template')
|
||||
self.m.StubOutWithMock(templatem, 'Template')
|
||||
self.m.StubOutWithMock(environment, 'Environment')
|
||||
|
||||
parser.Template(template, files=None).AndReturn(stack.t)
|
||||
templatem.Template(template, files=None).AndReturn(stack.t)
|
||||
environment.Environment(params).AndReturn(stack.env)
|
||||
parser.Stack(self.ctx, stack.name,
|
||||
stack.t, stack.env, timeout_mins=60).AndReturn(stack)
|
||||
@ -951,7 +952,7 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase):
|
||||
}
|
||||
}
|
||||
|
||||
template = parser.Template(tpl)
|
||||
template = templatem.Template(tpl)
|
||||
|
||||
create_stack = parser.Stack(self.ctx, stack_name, template)
|
||||
sid = create_stack.store()
|
||||
@ -1029,7 +1030,7 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase):
|
||||
AndReturn(json.dumps(nested_tpl))
|
||||
mox.Replay(urlfetch.get)
|
||||
|
||||
template = parser.Template(tpl)
|
||||
template = templatem.Template(tpl)
|
||||
|
||||
create_env = environment.Environment({'some_param': 'foo'})
|
||||
create_stack = parser.Stack(self.ctx, stack_name, template, create_env)
|
||||
@ -1081,7 +1082,7 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase):
|
||||
'B': {'Type': 'GenericResourceType'},
|
||||
'C': {'Type': 'GenericResourceType'}}}
|
||||
|
||||
template = parser.Template(tpl)
|
||||
template = templatem.Template(tpl)
|
||||
old_stack = parser.Stack(self.ctx, stack_name, template)
|
||||
sid = old_stack.store()
|
||||
self.assertIsNotNone(sid)
|
||||
@ -1112,10 +1113,10 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase):
|
||||
self.m.StubOutWithMock(parser.Stack, 'load')
|
||||
parser.Stack.load(self.ctx, stack=s).AndReturn(old_stack)
|
||||
|
||||
self.m.StubOutWithMock(parser, 'Template')
|
||||
self.m.StubOutWithMock(templatem, 'Template')
|
||||
self.m.StubOutWithMock(environment, 'Environment')
|
||||
|
||||
parser.Template(template, files=None).AndReturn(stack.t)
|
||||
templatem.Template(template, files=None).AndReturn(stack.t)
|
||||
environment.Environment(params).AndReturn(stack.env)
|
||||
parser.Stack(self.ctx, stack.name,
|
||||
stack.t, stack.env, timeout_mins=60).AndReturn(stack)
|
||||
@ -1166,7 +1167,7 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase):
|
||||
|
||||
self.m.StubOutWithMock(parser, 'Stack')
|
||||
self.m.StubOutWithMock(parser.Stack, 'load')
|
||||
self.m.StubOutWithMock(parser, 'Template')
|
||||
self.m.StubOutWithMock(templatem, 'Template')
|
||||
self.m.StubOutWithMock(environment, 'Environment')
|
||||
self.m.StubOutWithMock(self.man, '_get_stack')
|
||||
|
||||
@ -1174,7 +1175,7 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase):
|
||||
|
||||
parser.Stack.load(self.ctx, stack=s).AndReturn(old_stack)
|
||||
|
||||
parser.Template(template, files=None).AndReturn(old_stack.t)
|
||||
templatem.Template(template, files=None).AndReturn(old_stack.t)
|
||||
environment.Environment(params).AndReturn(old_stack.env)
|
||||
parser.Stack(self.ctx, old_stack.name,
|
||||
old_stack.t, old_stack.env,
|
||||
@ -2662,7 +2663,7 @@ class StackServiceTest(HeatTestCase):
|
||||
}
|
||||
}
|
||||
}
|
||||
templ = parser.Template(lazy_load_template)
|
||||
templ = templatem.Template(lazy_load_template)
|
||||
stack = parser.Stack(self.ctx, stack_name, templ,
|
||||
environment.Environment({}))
|
||||
|
||||
@ -2749,7 +2750,7 @@ class StackServiceTest(HeatTestCase):
|
||||
def test_validate_new_stack_checks_stack_limit(self, mock_db_count):
|
||||
cfg.CONF.set_override('max_stacks_per_tenant', 99)
|
||||
mock_db_count.return_value = 99
|
||||
template = service.parser.Template(
|
||||
template = service.templatem.Template(
|
||||
{'HeatTemplateFormatVersion': '2012-12-12'})
|
||||
self.assertRaises(exception.RequestLimitExceeded,
|
||||
self.eng._validate_new_stack,
|
||||
@ -2759,7 +2760,7 @@ class StackServiceTest(HeatTestCase):
|
||||
cfg.CONF.set_override('max_resources_per_stack', 5)
|
||||
template = {'HeatTemplateFormatVersion': '2012-12-12',
|
||||
'Resources': [1, 2, 3, 4, 5, 6]}
|
||||
parsed_template = service.parser.Template(template)
|
||||
parsed_template = service.templatem.Template(template)
|
||||
self.assertRaises(exception.RequestLimitExceeded,
|
||||
self.eng._validate_new_stack,
|
||||
self.ctx, 'test_existing_stack', parsed_template)
|
||||
|
@ -20,6 +20,7 @@ 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 template
|
||||
from heat.tests.common import HeatTestCase
|
||||
from heat.tests import utils
|
||||
from heat.tests.v1_1 import fakes
|
||||
@ -101,15 +102,15 @@ Resources:
|
||||
self.m.StubOutWithMock(neutronclient.Client, 'delete_security_group')
|
||||
self.m.StubOutWithMock(neutronclient.Client, 'update_security_group')
|
||||
|
||||
def create_stack(self, template):
|
||||
t = template_format.parse(template)
|
||||
def create_stack(self, templ):
|
||||
t = template_format.parse(templ)
|
||||
self.stack = self.parse_stack(t)
|
||||
self.assertIsNone(self.stack.create())
|
||||
return self.stack
|
||||
|
||||
def parse_stack(self, t):
|
||||
stack_name = 'test_stack'
|
||||
tmpl = parser.Template(t)
|
||||
tmpl = template.Template(t)
|
||||
stack = parser.Stack(utils.dummy_context(), stack_name, tmpl)
|
||||
stack.store()
|
||||
return stack
|
||||
|
@ -50,7 +50,7 @@ from heat.tests.v1_1 import fakes
|
||||
|
||||
|
||||
def join(raw):
|
||||
tmpl = parser.Template(mapping_template)
|
||||
tmpl = template.Template(mapping_template)
|
||||
return function.resolve(tmpl.parse(None, raw))
|
||||
|
||||
|
||||
|
@ -21,6 +21,7 @@ from heat.common import exception
|
||||
from heat.common import template_format
|
||||
from heat.engine import parser
|
||||
from heat.engine.resources.random_string import RandomString
|
||||
from heat.engine import template
|
||||
from heat.tests.common import HeatTestCase
|
||||
from heat.tests import utils
|
||||
|
||||
@ -87,15 +88,14 @@ Resources:
|
||||
super(TestRandomString, self).setUp()
|
||||
self.ctx = utils.dummy_context()
|
||||
|
||||
def create_stack(self, template):
|
||||
t = template_format.parse(template)
|
||||
self.stack = self.parse_stack(t)
|
||||
def create_stack(self, templ):
|
||||
self.stack = self.parse_stack(template_format.parse(templ))
|
||||
self.assertIsNone(self.stack.create())
|
||||
return self.stack
|
||||
|
||||
def parse_stack(self, t):
|
||||
stack_name = 'test_stack'
|
||||
tmpl = parser.Template(t)
|
||||
tmpl = template.Template(t)
|
||||
stack = parser.Stack(utils.dummy_context(), stack_name, tmpl)
|
||||
stack.validate()
|
||||
stack.store()
|
||||
|
@ -23,6 +23,7 @@ from heat.common import template_format
|
||||
from heat.engine.clients.os import nova
|
||||
from heat.engine import parser
|
||||
from heat.engine import scheduler
|
||||
from heat.engine import template
|
||||
from heat.tests.common import HeatTestCase
|
||||
from heat.tests import utils
|
||||
from heat.tests.v1_1 import fakes
|
||||
@ -143,15 +144,14 @@ Resources:
|
||||
neutronclient.Client, 'delete_security_group_rule')
|
||||
self.m.StubOutWithMock(neutronclient.Client, 'delete_security_group')
|
||||
|
||||
def create_stack(self, template):
|
||||
t = template_format.parse(template)
|
||||
self.stack = self.parse_stack(t)
|
||||
def create_stack(self, templ):
|
||||
self.stack = self.parse_stack(template_format.parse(templ))
|
||||
self.assertIsNone(self.stack.create())
|
||||
return self.stack
|
||||
|
||||
def parse_stack(self, t):
|
||||
stack_name = 'test_stack'
|
||||
tmpl = parser.Template(t)
|
||||
tmpl = template.Template(t)
|
||||
stack = parser.Stack(utils.dummy_context(), stack_name, tmpl)
|
||||
stack.store()
|
||||
return stack
|
||||
|
@ -31,6 +31,7 @@ from heat.engine import parser
|
||||
from heat.engine import resource
|
||||
from heat.engine.resources import server as servers
|
||||
from heat.engine import scheduler
|
||||
from heat.engine import template
|
||||
from heat.openstack.common.gettextutils import _
|
||||
from heat.tests.common import HeatTestCase
|
||||
from heat.tests import fakes
|
||||
@ -88,12 +89,12 @@ class ServersTest(HeatTestCase):
|
||||
|
||||
def _setup_test_stack(self, stack_name):
|
||||
t = template_format.parse(wp_template)
|
||||
template = parser.Template(t)
|
||||
stack = parser.Stack(utils.dummy_context(), stack_name, template,
|
||||
templ = template.Template(t)
|
||||
stack = parser.Stack(utils.dummy_context(), stack_name, templ,
|
||||
environment.Environment({'key_name': 'test'}),
|
||||
stack_id=str(uuid.uuid4()),
|
||||
stack_user_project_id='8888')
|
||||
return (template, stack)
|
||||
return (templ, stack)
|
||||
|
||||
def _get_test_template(self, stack_name, server_name=None,
|
||||
image_id=None):
|
||||
@ -812,11 +813,11 @@ class ServersTest(HeatTestCase):
|
||||
}
|
||||
'''
|
||||
t = template_format.parse(nova_keypair_template)
|
||||
template = parser.Template(t)
|
||||
stack = parser.Stack(utils.dummy_context(), stack_name, template,
|
||||
templ = template.Template(t)
|
||||
stack = parser.Stack(utils.dummy_context(), stack_name, templ,
|
||||
stack_id=str(uuid.uuid4()))
|
||||
|
||||
resource_defns = template.resource_definitions(stack)
|
||||
resource_defns = templ.resource_definitions(stack)
|
||||
server = servers.Server('server_validate_test',
|
||||
resource_defns['WebServer'], stack)
|
||||
|
||||
|
@ -23,6 +23,7 @@ from heat.engine import parser
|
||||
from heat.engine import resource
|
||||
from heat.engine import scheduler
|
||||
from heat.engine import stack_user
|
||||
from heat.engine import template
|
||||
from heat.tests.common import HeatTestCase
|
||||
from heat.tests import fakes
|
||||
from heat.tests import generic_resource
|
||||
@ -61,11 +62,10 @@ class SignalTest(HeatTestCase):
|
||||
super(SignalTest, self).tearDown()
|
||||
|
||||
def create_stack(self, stack_name='test_stack', stub=True):
|
||||
temp = template_format.parse(test_template_signal)
|
||||
template = parser.Template(temp)
|
||||
templ = template.Template(template_format.parse(test_template_signal))
|
||||
ctx = utils.dummy_context()
|
||||
ctx.tenant_id = 'test_tenant'
|
||||
stack = parser.Stack(ctx, stack_name, template,
|
||||
stack = parser.Stack(ctx, stack_name, templ,
|
||||
disable_rollback=True)
|
||||
|
||||
# Stub out the stack ID so we have a known value
|
||||
|
@ -24,6 +24,7 @@ from heat.engine import parser
|
||||
from heat.engine import resource
|
||||
from heat.engine import scheduler
|
||||
from heat.engine import stack_resource
|
||||
from heat.engine import template as templatem
|
||||
from heat.tests.common import HeatTestCase
|
||||
from heat.tests import generic_resource as generic_rsrc
|
||||
from heat.tests import utils
|
||||
@ -147,7 +148,7 @@ class StackResourceTest(HeatTestCase):
|
||||
mock_stack_class.return_value = nested_stack
|
||||
nested_stack.preview_resources.return_value = 'preview_nested_stack'
|
||||
mock_env_class.return_value = 'environment'
|
||||
template = parser.Template(template_format.parse(param_template))
|
||||
template = templatem.Template(template_format.parse(param_template))
|
||||
parent_t = self.parent_stack.t
|
||||
resource_defns = parent_t.resource_definitions(self.parent_stack)
|
||||
parent_resource = MyImplementedStackResource(
|
||||
@ -183,7 +184,7 @@ class StackResourceTest(HeatTestCase):
|
||||
nested_stack.preview_resources.return_value = 'preview_nested_stack'
|
||||
mock_env_class.return_value = 'environment'
|
||||
template_dict = template_format.parse(param_template)
|
||||
template = parser.Template(template_dict)
|
||||
template = templatem.Template(template_dict)
|
||||
parent_t = self.parent_stack.t
|
||||
resource_defns = parent_t.resource_definitions(self.parent_stack)
|
||||
parent_resource = MyImplementedStackResource(
|
||||
@ -217,7 +218,7 @@ class StackResourceTest(HeatTestCase):
|
||||
resource_defns[self.ws_resname],
|
||||
self.parent_stack)
|
||||
stk_resource.child_template = \
|
||||
mock.Mock(return_value=parser.Template(self.simple_template))
|
||||
mock.Mock(return_value=templatem.Template(self.simple_template))
|
||||
stk_resource.child_params = mock.Mock()
|
||||
exc = exception.RequestLimitExceeded(message='Validation Failed')
|
||||
validation_mock = mock.Mock(side_effect=exc)
|
||||
@ -247,7 +248,7 @@ class StackResourceTest(HeatTestCase):
|
||||
stack_resource.cfg.CONF.set_override('max_resources_per_stack', 2)
|
||||
tmpl = {'HeatTemplateFormatVersion': '2012-12-12',
|
||||
'Resources': [1]}
|
||||
template = stack_resource.parser.Template(tmpl)
|
||||
template = stack_resource.template.Template(tmpl)
|
||||
root_resources = mock.Mock(return_value=2)
|
||||
self.parent_resource.stack.root_stack.total_resources = root_resources
|
||||
|
||||
@ -576,7 +577,7 @@ class StackResourceTest(HeatTestCase):
|
||||
|
||||
ctx = self.parent_resource.context
|
||||
phy_id = "cb2f2b28-a663-4683-802c-4b40c916e1ff"
|
||||
templ = parser.Template(self.templ)
|
||||
templ = templatem.Template(self.templ)
|
||||
env = environment.Environment({"KeyName": "test"})
|
||||
self.stack = parser.Stack(ctx, phy_id, templ, env, timeout_mins=None,
|
||||
disable_rollback=True,
|
||||
|
@ -15,6 +15,7 @@ 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 template
|
||||
from heat.tests.common import HeatTestCase
|
||||
from heat.tests import utils
|
||||
|
||||
@ -57,8 +58,8 @@ class VPCTestBase(HeatTestCase):
|
||||
neutronclient.Client, 'delete_security_group_rule')
|
||||
self.stub_keystoneclient()
|
||||
|
||||
def create_stack(self, template):
|
||||
t = template_format.parse(template)
|
||||
def create_stack(self, templ):
|
||||
t = template_format.parse(templ)
|
||||
stack = self.parse_stack(t)
|
||||
self.assertIsNone(stack.validate())
|
||||
self.assertIsNone(stack.create())
|
||||
@ -66,7 +67,7 @@ class VPCTestBase(HeatTestCase):
|
||||
|
||||
def parse_stack(self, t):
|
||||
stack_name = 'test_stack'
|
||||
tmpl = parser.Template(t)
|
||||
tmpl = template.Template(t)
|
||||
stack = parser.Stack(utils.dummy_context(), stack_name, tmpl)
|
||||
stack.store()
|
||||
return stack
|
||||
|
@ -19,6 +19,7 @@ import mox
|
||||
from heat.common import exception
|
||||
from heat.db import api as db_api
|
||||
from heat.engine import parser
|
||||
from heat.engine import template
|
||||
from heat.engine import watchrule
|
||||
from heat.openstack.common import timeutils
|
||||
from heat.tests.common import HeatTestCase
|
||||
@ -47,7 +48,7 @@ class WatchRuleTest(HeatTestCase):
|
||||
ctx = utils.dummy_context()
|
||||
ctx.auth_token = 'abcd1234'
|
||||
empty_tmpl = {'HeatTemplateFormatVersion': '2012-12-12'}
|
||||
tmpl = parser.Template(empty_tmpl)
|
||||
tmpl = template.Template(empty_tmpl)
|
||||
stack_name = 'dummystack'
|
||||
dummy_stack = parser.Stack(ctx, stack_name, tmpl)
|
||||
dummy_stack.state_set(dummy_stack.CREATE, dummy_stack.COMPLETE,
|
||||
|
@ -24,6 +24,7 @@ from heat.db import api as db_api
|
||||
from heat.engine import environment
|
||||
from heat.engine import parser
|
||||
from heat.engine import resource
|
||||
from heat.engine import template
|
||||
|
||||
get_engine = db_api.get_engine
|
||||
|
||||
@ -85,8 +86,8 @@ def parse_stack(t, params=None, stack_name='test_stack', stack_id=None,
|
||||
timeout_mins=None):
|
||||
params = params or {}
|
||||
ctx = dummy_context()
|
||||
template = parser.Template(t)
|
||||
stack = parser.Stack(ctx, stack_name, template,
|
||||
templ = template.Template(t)
|
||||
stack = parser.Stack(ctx, stack_name, templ,
|
||||
environment.Environment(params), stack_id,
|
||||
timeout_mins=timeout_mins)
|
||||
stack.store()
|
||||
|
Loading…
Reference in New Issue
Block a user