Merge "Show deprecated warnings when import parser"

This commit is contained in:
Jenkins 2015-04-15 11:04:51 +00:00 committed by Gerrit Code Review
commit c820cc26dc
43 changed files with 277 additions and 254 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,11 +11,15 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import warnings
from heat.engine import stack from heat.engine import stack
from heat.engine import template from heat.engine import template
# Note: these classes are here for backwards compatibility. # Note: these classes are here for backwards compatibility.
# New uses of the Stack class should use stack.Stack(). # 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 Template = template.Template
Stack = stack.Stack Stack = stack.Stack

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,7 +12,7 @@
# under the License. # under the License.
from heat.common import template_format 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.engine import template
from heat.tests import common from heat.tests import common
from heat.tests import utils from heat.tests import utils

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -27,10 +27,11 @@ from heat.engine.clients.os import glance
from heat.engine.clients.os import neutron from heat.engine.clients.os import neutron
from heat.engine.clients.os import nova from heat.engine.clients.os import nova
from heat.engine import environment from heat.engine import environment
from heat.engine import parser
from heat.engine import resource from heat.engine import resource
from heat.engine.resources.aws.ec2 import instance as instances from heat.engine.resources.aws.ec2 import instance as instances
from heat.engine import scheduler 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 common
from heat.tests.nova import fakes as fakes_nova from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils from heat.tests import utils
@ -79,11 +80,11 @@ class InstancesTest(common.HeatTestCase):
def _setup_test_stack(self, stack_name): def _setup_test_stack(self, stack_name):
t = template_format.parse(wp_template) t = template_format.parse(wp_template)
template = parser.Template( tmpl = template.Template(
t, env=environment.Environment({'KeyName': 'test'})) t, env=environment.Environment({'KeyName': 'test'}))
stack = parser.Stack(utils.dummy_context(), stack_name, template, stack = parser.Stack(utils.dummy_context(), stack_name, tmpl,
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))
return (template, stack) return (tmpl, stack)
def _mock_get_image_id_success(self, imageId_input, imageId): def _mock_get_image_id_success(self, imageId_input, imageId):
self.m.StubOutWithMock(glance.GlanceClientPlugin, 'get_image_id') self.m.StubOutWithMock(glance.GlanceClientPlugin, 'get_image_id')

View File

@ -19,10 +19,11 @@ from heat.engine.clients.os import glance
from heat.engine.clients.os import neutron from heat.engine.clients.os import neutron
from heat.engine.clients.os import nova from heat.engine.clients.os import nova
from heat.engine import environment from heat.engine import environment
from heat.engine import parser
from heat.engine.resources.aws.ec2 import instance as instances from heat.engine.resources.aws.ec2 import instance as instances
from heat.engine.resources.aws.ec2 import network_interface as net_interfaces from heat.engine.resources.aws.ec2 import network_interface as net_interfaces
from heat.engine import scheduler 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 common
from heat.tests.nova import fakes as fakes_nova from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils from heat.tests import utils
@ -201,9 +202,9 @@ class instancesTest(common.HeatTestCase):
kwargs = {'KeyName': 'test', kwargs = {'KeyName': 'test',
'InstanceType': 'm1.large', 'InstanceType': 'm1.large',
'SubnetId': '4156c7a5-e8c4-4aff-a6e1-8f3c7bc83861'} 'SubnetId': '4156c7a5-e8c4-4aff-a6e1-8f3c7bc83861'}
template = parser.Template(t, tmpl = template.Template(t,
env=environment.Environment(kwargs)) env=environment.Environment(kwargs))
stack = parser.Stack(utils.dummy_context(), stack_name, template, stack = parser.Stack(utils.dummy_context(), stack_name, tmpl,
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))
image_id = 'CentOS 5.2' image_id = 'CentOS 5.2'
t['Resources']['WebServer']['Properties']['ImageId'] = image_id t['Resources']['WebServer']['Properties']['ImageId'] = image_id
@ -256,9 +257,9 @@ class instancesTest(common.HeatTestCase):
kwargs = {'KeyName': 'test', kwargs = {'KeyName': 'test',
'InstanceType': 'm1.large', 'InstanceType': 'm1.large',
'SubnetId': '4156c7a5-e8c4-4aff-a6e1-8f3c7bc83861'} 'SubnetId': '4156c7a5-e8c4-4aff-a6e1-8f3c7bc83861'}
template = parser.Template(t, tmpl = template.Template(t,
env=environment.Environment(kwargs)) env=environment.Environment(kwargs))
stack = parser.Stack(utils.dummy_context(), stack_name, template, stack = parser.Stack(utils.dummy_context(), stack_name, tmpl,
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))
image_id = 'CentOS 5.2' image_id = 'CentOS 5.2'
t['Resources']['WebServer']['Properties']['ImageId'] = image_id t['Resources']['WebServer']['Properties']['ImageId'] = image_id

View File

@ -18,12 +18,13 @@ from oslo_config import cfg
from heat.common import identifier from heat.common import identifier
from heat.common import template_format from heat.common import template_format
from heat.engine import environment 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.resources.aws.cfn import wait_condition_handle as aws_wch
from heat.engine.resources.aws.ec2 import instance from heat.engine.resources.aws.ec2 import instance
from heat.engine.resources.openstack.nova import server from heat.engine.resources.openstack.nova import server
from heat.engine import scheduler from heat.engine import scheduler
from heat.engine import service from heat.engine import service
from heat.engine import stack as parser
from heat.engine import template as tmpl
from heat.tests import common from heat.tests import common
from heat.tests import utils from heat.tests import utils
@ -153,7 +154,7 @@ class MetadataRefreshTest(common.HeatTestCase):
def create_stack(self, stack_name='test_stack', params=None): def create_stack(self, stack_name='test_stack', params=None):
params = params or {} params = params or {}
temp = template_format.parse(test_template_metadata) temp = template_format.parse(test_template_metadata)
template = parser.Template(temp, template = tmpl.Template(temp,
env=environment.Environment(params)) env=environment.Environment(params))
ctx = utils.dummy_context() ctx = utils.dummy_context()
stack = parser.Stack(ctx, stack_name, template, stack = parser.Stack(ctx, stack_name, template,
@ -219,7 +220,7 @@ class WaitCondMetadataUpdateTest(common.HeatTestCase):
def create_stack(self, stack_name='test_stack'): def create_stack(self, stack_name='test_stack'):
temp = template_format.parse(test_template_waitcondition) temp = template_format.parse(test_template_waitcondition)
template = parser.Template(temp) template = tmpl.Template(temp)
ctx = utils.dummy_context() ctx = utils.dummy_context()
stack = parser.Stack(ctx, stack_name, template, disable_rollback=True) stack = parser.Stack(ctx, stack_name, template, disable_rollback=True)
@ -311,7 +312,7 @@ class MetadataRefreshTestServer(common.HeatTestCase):
def create_stack(self, stack_name='test_stack_native', params=None): def create_stack(self, stack_name='test_stack_native', params=None):
params = params or {} params = params or {}
temp = template_format.parse(test_template_server) temp = template_format.parse(test_template_server)
template = parser.Template(temp, template = tmpl.Template(temp,
env=environment.Environment(params)) env=environment.Environment(params))
ctx = utils.dummy_context() ctx = utils.dummy_context()
stack = parser.Stack(ctx, stack_name, template, stack = parser.Stack(ctx, stack_name, template,

View File

@ -17,8 +17,8 @@ import uuid
import mock import mock
from heat.common import exception as exc from heat.common import exception as exc
from heat.engine import parser
from heat.engine.resources.openstack.heat import multi_part as mp from heat.engine.resources.openstack.heat import multi_part as mp
from heat.engine import stack as parser
from heat.engine import template from heat.engine import template
from heat.tests import common from heat.tests import common
from heat.tests import utils from heat.tests import utils

View File

@ -22,10 +22,11 @@ from heat.common import exception
from heat.common import identifier from heat.common import identifier
from heat.common import template_format from heat.common import template_format
from heat.common import urlfetch from heat.common import urlfetch
from heat.engine import parser
from heat.engine import resource from heat.engine import resource
from heat.engine.resources.aws.cfn import stack as stack_res from heat.engine.resources.aws.cfn import stack as stack_res
from heat.engine import rsrc_defn from heat.engine import rsrc_defn
from heat.engine import stack as parser
from heat.engine import template
from heat.objects import resource_data as resource_data_object from heat.objects import resource_data as resource_data_object
from heat.tests import common from heat.tests import common
from heat.tests import generic_resource as generic_rsrc from heat.tests import generic_resource as generic_rsrc
@ -78,7 +79,7 @@ Outputs:
def parse_stack(self, t, data=None): def parse_stack(self, t, data=None):
ctx = utils.dummy_context('test_username', 'aaaa', 'password') ctx = utils.dummy_context('test_username', 'aaaa', 'password')
stack_name = 'test_stack' stack_name = 'test_stack'
tmpl = parser.Template(t) tmpl = template.Template(t)
stack = parser.Stack(ctx, stack_name, tmpl, adopt_stack_data=data) stack = parser.Stack(ctx, stack_name, tmpl, adopt_stack_data=data)
stack.store() stack.store()
return stack return stack
@ -122,7 +123,7 @@ Resources:
urlfetch.get.assert_has_calls(calls) urlfetch.get.assert_has_calls(calls)
def test_nested_stack_six_deep(self): def test_nested_stack_six_deep(self):
template = ''' tmpl = '''
HeatTemplateFormatVersion: 2012-12-12 HeatTemplateFormatVersion: 2012-12-12
Resources: Resources:
Nested: Nested:
@ -130,12 +131,12 @@ Resources:
Properties: Properties:
TemplateURL: 'https://server.test/depth%i.template' TemplateURL: 'https://server.test/depth%i.template'
''' '''
root_template = template % 1 root_template = tmpl % 1
depth1_template = template % 2 depth1_template = tmpl % 2
depth2_template = template % 3 depth2_template = tmpl % 3
depth3_template = template % 4 depth3_template = tmpl % 4
depth4_template = template % 5 depth4_template = tmpl % 5
depth5_template = template % 6 depth5_template = tmpl % 6
depth5_template += ''' depth5_template += '''
Parameters: Parameters:
KeyName: foo KeyName: foo
@ -202,7 +203,7 @@ Resources:
urlfetch.get.assert_has_calls(calls, any_order=True) urlfetch.get.assert_has_calls(calls, any_order=True)
def test_nested_stack_infinite_recursion(self): def test_nested_stack_infinite_recursion(self):
template = ''' tmpl = '''
HeatTemplateFormatVersion: 2012-12-12 HeatTemplateFormatVersion: 2012-12-12
Resources: Resources:
Nested: Nested:
@ -210,8 +211,8 @@ Resources:
Properties: Properties:
TemplateURL: 'https://server.test/the.template' TemplateURL: 'https://server.test/the.template'
''' '''
urlfetch.get.return_value = template urlfetch.get.return_value = tmpl
t = template_format.parse(template) t = template_format.parse(tmpl)
stack = self.parse_stack(t) stack = self.parse_stack(t)
res = self.assertRaises(exception.StackValidationFailed, res = self.assertRaises(exception.StackValidationFailed,
stack.validate) stack.validate)
@ -260,7 +261,7 @@ class ResDataResource(generic_rsrc.GenericResource):
class ResDataStackTest(common.HeatTestCase): class ResDataStackTest(common.HeatTestCase):
template = ''' tmpl = '''
HeatTemplateFormatVersion: "2012-12-12" HeatTemplateFormatVersion: "2012-12-12"
Parameters: Parameters:
KeyName: KeyName:
@ -285,7 +286,7 @@ Outputs:
return stack return stack
def test_res_data_delete(self): def test_res_data_delete(self):
stack = self.create_stack(self.template) stack = self.create_stack(self.tmpl)
res = stack['res'] res = stack['res']
stack.delete() stack.delete()
self.assertEqual((stack.DELETE, stack.COMPLETE), stack.state) self.assertEqual((stack.DELETE, stack.COMPLETE), stack.state)
@ -310,7 +311,8 @@ Outputs:
self.ctx = utils.dummy_context('test_username', 'aaaa', 'password') self.ctx = utils.dummy_context('test_username', 'aaaa', 'password')
empty_template = {"HeatTemplateFormatVersion": "2012-12-12"} empty_template = {"HeatTemplateFormatVersion": "2012-12-12"}
stack = parser.Stack(self.ctx, 'test', parser.Template(empty_template)) stack = parser.Stack(self.ctx, 'test',
template.Template(empty_template))
stack.store() stack.store()
self.patchobject(urlfetch, 'get', return_value=self.nested_template) self.patchobject(urlfetch, 'get', return_value=self.nested_template)

View File

@ -22,11 +22,12 @@ from heat.common import template_format
from heat.engine.clients.os import neutron from heat.engine.clients.os import neutron
from heat.engine.clients.os import nova from heat.engine.clients.os import nova
from heat.engine.clients.os import trove from heat.engine.clients.os import trove
from heat.engine import parser
from heat.engine import resource from heat.engine import resource
from heat.engine.resources.openstack.trove import os_database from heat.engine.resources.openstack.trove import os_database
from heat.engine import rsrc_defn from heat.engine import rsrc_defn
from heat.engine import scheduler 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 common
from heat.tests import utils from heat.tests import utils
@ -105,7 +106,7 @@ class OSDBInstanceTest(common.HeatTestCase):
def _setup_test_clouddbinstance(self, name, t): def _setup_test_clouddbinstance(self, name, t):
stack_name = '%s_stack' % name stack_name = '%s_stack' % name
template = parser.Template(t) template = tmpl.Template(t)
stack = parser.Stack(utils.dummy_context(), stack = parser.Stack(utils.dummy_context(),
stack_name, stack_name,
template, template,

View File

@ -25,13 +25,14 @@ from heat.common import template_format
from heat.common import urlfetch from heat.common import urlfetch
from heat.engine import attributes from heat.engine import attributes
from heat.engine import environment from heat.engine import environment
from heat.engine import parser
from heat.engine import properties from heat.engine import properties
from heat.engine import resource from heat.engine import resource
from heat.engine import resources from heat.engine import resources
from heat.engine.resources import template_resource from heat.engine.resources import template_resource
from heat.engine import rsrc_defn from heat.engine import rsrc_defn
from heat.engine import stack as parser
from heat.engine import support from heat.engine import support
from heat.engine import template
from heat.tests import common from heat.tests import common
from heat.tests import generic_resource as generic_rsrc from heat.tests import generic_resource as generic_rsrc
from heat.tests import utils from heat.tests import utils
@ -128,7 +129,7 @@ class ProviderTemplateTest(common.HeatTestCase):
env.load({'resource_registry': env.load({'resource_registry':
{'DummyResource': 'test_resource.template'}}) {'DummyResource': 'test_resource.template'}})
stack = parser.Stack(utils.dummy_context(), 'test_stack', stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template(empty_template, files=files, template.Template(empty_template, files=files,
env=env), env=env),
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))
@ -209,7 +210,7 @@ class ProviderTemplateTest(common.HeatTestCase):
env.load({'resource_registry': env.load({'resource_registry':
{'DummyResource': 'test_resource.template'}}) {'DummyResource': 'test_resource.template'}})
stack = parser.Stack(utils.dummy_context(), 'test_stack', stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template(empty_template, files=files, template.Template(empty_template, files=files,
env=env), env=env),
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))
@ -238,7 +239,7 @@ class ProviderTemplateTest(common.HeatTestCase):
env.load({'resource_registry': env.load({'resource_registry':
{'DummyResource': 'test_resource.template'}}) {'DummyResource': 'test_resource.template'}})
stack = parser.Stack(utils.dummy_context(), 'test_stack', stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template(empty_template, files=files, template.Template(empty_template, files=files,
env=env), env=env),
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))
@ -271,7 +272,7 @@ class ProviderTemplateTest(common.HeatTestCase):
env.load({'resource_registry': env.load({'resource_registry':
{'DummyResource': 'test_resource.template'}}) {'DummyResource': 'test_resource.template'}})
stack = parser.Stack(utils.dummy_context(), 'test_stack', stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template(empty_template, files=files, template.Template(empty_template, files=files,
env=env), env=env),
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))
@ -303,7 +304,7 @@ class ProviderTemplateTest(common.HeatTestCase):
env.load({'resource_registry': env.load({'resource_registry':
{'DummyResource': 'test_resource.template'}}) {'DummyResource': 'test_resource.template'}})
stack = parser.Stack(utils.dummy_context(), 'test_stack', stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template(empty_template, files=files, template.Template(empty_template, files=files,
env=env), env=env),
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))
@ -333,7 +334,7 @@ class ProviderTemplateTest(common.HeatTestCase):
env.load({'resource_registry': env.load({'resource_registry':
{'DummyResource': 'test_resource.template'}}) {'DummyResource': 'test_resource.template'}})
stack = parser.Stack(utils.dummy_context(), 'test_stack', stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template(empty_template, files=files, template.Template(empty_template, files=files,
env=env), env=env),
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))
@ -365,7 +366,7 @@ class ProviderTemplateTest(common.HeatTestCase):
env.load({'resource_registry': env.load({'resource_registry':
{'DummyResource': 'test_resource.template'}}) {'DummyResource': 'test_resource.template'}})
stack = parser.Stack(utils.dummy_context(), 'test_stack', stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template( template.Template(
{'HeatTemplateFormatVersion': '2012-12-12'}, {'HeatTemplateFormatVersion': '2012-12-12'},
files=files, env=env), files=files, env=env),
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))
@ -401,7 +402,7 @@ class ProviderTemplateTest(common.HeatTestCase):
env.load({'resource_registry': env.load({'resource_registry':
{'DummyResource': 'test_resource.template'}}) {'DummyResource': 'test_resource.template'}})
stack = parser.Stack(utils.dummy_context(), 'test_stack', stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template( template.Template(
{'HeatTemplateFormatVersion': '2012-12-12'}, {'HeatTemplateFormatVersion': '2012-12-12'},
files=files, env=env), files=files, env=env),
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))
@ -433,7 +434,7 @@ class ProviderTemplateTest(common.HeatTestCase):
env.load({'resource_registry': env.load({'resource_registry':
{'DummyResource': 'test_resource.template'}}) {'DummyResource': 'test_resource.template'}})
stack = parser.Stack(utils.dummy_context(), 'test_stack', stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template( template.Template(
{'HeatTemplateFormatVersion': '2012-12-12'}, {'HeatTemplateFormatVersion': '2012-12-12'},
files=files, env=env), files=files, env=env),
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))
@ -467,7 +468,7 @@ class ProviderTemplateTest(common.HeatTestCase):
{'DummyResource': 'test_resource.template', {'DummyResource': 'test_resource.template',
'resources': {'foo': 'foo.template'}}}) 'resources': {'foo': 'foo.template'}}})
stack = parser.Stack(utils.dummy_context(), 'test_stack', stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template( template.Template(
{'HeatTemplateFormatVersion': '2012-12-12'}, {'HeatTemplateFormatVersion': '2012-12-12'},
files=files, env=env), files=files, env=env),
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))
@ -502,7 +503,7 @@ class ProviderTemplateTest(common.HeatTestCase):
{'DummyResource': 'test_resource.template', {'DummyResource': 'test_resource.template',
'resources': {'foo': {'DummyResource': 'foo.template'}}}}) 'resources': {'foo': {'DummyResource': 'foo.template'}}}})
stack = parser.Stack(utils.dummy_context(), 'test_stack', stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template( template.Template(
{'HeatTemplateFormatVersion': '2012-12-12'}, {'HeatTemplateFormatVersion': '2012-12-12'},
files=files, env=env), files=files, env=env),
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))
@ -546,7 +547,7 @@ class ProviderTemplateTest(common.HeatTestCase):
env.load({'resource_registry': env.load({'resource_registry':
{'DummyResource': 'test_resource.template'}}) {'DummyResource': 'test_resource.template'}})
stack = parser.Stack(utils.dummy_context(), 'test_stack', stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template( template.Template(
{'HeatTemplateFormatVersion': '2012-12-12'}, {'HeatTemplateFormatVersion': '2012-12-12'},
files=files, env=env), files=files, env=env),
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))
@ -608,7 +609,7 @@ class ProviderTemplateTest(common.HeatTestCase):
self.m.ReplayAll() self.m.ReplayAll()
stack = parser.Stack(utils.dummy_context(), 'test_stack', stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template(empty_template), template.Template(empty_template),
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))
properties = { properties = {
@ -659,7 +660,7 @@ class ProviderTemplateTest(common.HeatTestCase):
g_env.load({'resource_registry': g_env.load({'resource_registry':
{'Test::Frodo': test_templ_name}}) {'Test::Frodo': test_templ_name}})
stack = parser.Stack(utils.dummy_context(), 'test_stack', stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template(empty_template), template.Template(empty_template),
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))
minimal_temp = json.dumps({'HeatTemplateFormatVersion': '2012-12-12', minimal_temp = json.dumps({'HeatTemplateFormatVersion': '2012-12-12',
@ -687,7 +688,7 @@ class ProviderTemplateTest(common.HeatTestCase):
env.load({'resource_registry': env.load({'resource_registry':
{'Test::Flippy': test_templ_name}}) {'Test::Flippy': test_templ_name}})
stack = parser.Stack(utils.dummy_context(), 'test_stack', stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template(empty_template, env=env), template.Template(empty_template, env=env),
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))
definition = rsrc_defn.ResourceDefinition('test_t_res', definition = rsrc_defn.ResourceDefinition('test_t_res',
@ -709,7 +710,7 @@ class ProviderTemplateTest(common.HeatTestCase):
g_env.load({'resource_registry': g_env.load({'resource_registry':
{'Test::Frodo': test_templ_name}}) {'Test::Frodo': test_templ_name}})
stack = parser.Stack(utils.dummy_context(), 'test_stack', stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template(empty_template), template.Template(empty_template),
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))
self.m.StubOutWithMock(urlfetch, "get") self.m.StubOutWithMock(urlfetch, "get")
@ -739,7 +740,7 @@ class ProviderTemplateTest(common.HeatTestCase):
env.load({'resource_registry': env.load({'resource_registry':
{'Test::Flippy': test_templ_name}}) {'Test::Flippy': test_templ_name}})
stack = parser.Stack(utils.dummy_context(), 'test_stack', stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template(empty_template, env=env), template.Template(empty_template, env=env),
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))
self.m.StubOutWithMock(urlfetch, "get") self.m.StubOutWithMock(urlfetch, "get")
@ -768,7 +769,7 @@ class ProviderTemplateTest(common.HeatTestCase):
env.load({'resource_registry': env.load({'resource_registry':
{'Test::Flippy': test_templ_name}}) {'Test::Flippy': test_templ_name}})
stack = parser.Stack(utils.dummy_context(), 'test_stack', stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template(empty_template, env=env), template.Template(empty_template, env=env),
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))
self.m.ReplayAll() self.m.ReplayAll()
@ -791,7 +792,7 @@ class ProviderTemplateTest(common.HeatTestCase):
env.load({'resource_registry': env.load({'resource_registry':
{'Test::Tmpl': test_templ_name}}) {'Test::Tmpl': test_templ_name}})
stack = parser.Stack(utils.dummy_context(), 'test_stack', stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template(empty_template, env=env), template.Template(empty_template, env=env),
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))
self.m.StubOutWithMock(urlfetch, "get") self.m.StubOutWithMock(urlfetch, "get")
@ -838,7 +839,7 @@ class TemplateResourceCrudTest(common.HeatTestCase):
env.load({'resource_registry': env.load({'resource_registry':
{'DummyResource': 'test_resource.template'}}) {'DummyResource': 'test_resource.template'}})
stack = parser.Stack(self.ctx, 'test_stack', stack = parser.Stack(self.ctx, 'test_stack',
parser.Template(empty_template, files=files, template.Template(empty_template, files=files,
env=env), env=env),
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))

View File

@ -18,8 +18,8 @@ from testtools import matchers
from heat.common import exception from heat.common import exception
from heat.common import template_format from heat.common import template_format
from heat.engine import parser
from heat.engine.resources.openstack.heat import random_string as rs from heat.engine.resources.openstack.heat import random_string as rs
from heat.engine import stack as parser
from heat.engine import template from heat.engine import template
from heat.tests import common from heat.tests import common
from heat.tests import utils from heat.tests import utils

View File

@ -23,11 +23,12 @@ from heat.common import exception
from heat.common.i18n import _ from heat.common.i18n import _
from heat.common import template_format from heat.common import template_format
from heat.engine import environment from heat.engine import environment
from heat.engine import parser
from heat.engine import resource from heat.engine import resource
from heat.engine.resources.openstack.heat import remote_stack from heat.engine.resources.openstack.heat import remote_stack
from heat.engine import rsrc_defn from heat.engine import rsrc_defn
from heat.engine import scheduler from heat.engine import scheduler
from heat.engine import stack
from heat.engine import template
from heat.tests import common as tests_common from heat.tests import common as tests_common
from heat.tests import utils from heat.tests import utils
@ -168,8 +169,8 @@ class RemoteStackTest(tests_common.HeatTestCase):
self.this_context = utils.dummy_context( self.this_context = utils.dummy_context(
region_name=self.this_region) region_name=self.this_region)
tmpl = parser.Template(snippet, files=self.files) tmpl = template.Template(snippet, files=self.files)
parent = parser.Stack(self.this_context, 'parent_stack', tmpl) parent = stack.Stack(self.this_context, 'parent_stack', tmpl)
# parent context checking # parent context checking
ctx = parent.context.to_dict() ctx = parent.context.to_dict()

View File

@ -30,12 +30,12 @@ from heat.engine.cfn import functions as cfn_funcs
from heat.engine import constraints from heat.engine import constraints
from heat.engine import dependencies from heat.engine import dependencies
from heat.engine import environment from heat.engine import environment
from heat.engine import parser
from heat.engine import properties from heat.engine import properties
from heat.engine import resource from heat.engine import resource
from heat.engine import resources from heat.engine import resources
from heat.engine import rsrc_defn from heat.engine import rsrc_defn
from heat.engine import scheduler from heat.engine import scheduler
from heat.engine import stack as parser
from heat.engine import template from heat.engine import template
from heat.objects import resource as resource_objects from heat.objects import resource as resource_objects
from heat.objects import resource_data as resource_data_object from heat.objects import resource_data as resource_data_object
@ -65,7 +65,7 @@ class ResourceTest(common.HeatTestCase):
u'ResourceWithCustomConstraint'}}) u'ResourceWithCustomConstraint'}})
self.stack = parser.Stack(utils.dummy_context(), 'test_stack', self.stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template(empty_template, template.Template(empty_template,
env=self.env), env=self.env),
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))
self.patch('heat.engine.resource.warnings') self.patch('heat.engine.resource.warnings')
@ -400,7 +400,7 @@ class ResourceTest(common.HeatTestCase):
tmpl2 = rsrc_defn.ResourceDefinition('test_resource', 'Foo') tmpl2 = rsrc_defn.ResourceDefinition('test_resource', 'Foo')
tmpl3 = rsrc_defn.ResourceDefinition('test_resource2', 'Bar') tmpl3 = rsrc_defn.ResourceDefinition('test_resource2', 'Bar')
stack2 = parser.Stack(utils.dummy_context(), 'test_stack', stack2 = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template(empty_template), stack_id=-1) template.Template(empty_template), stack_id=-1)
res1 = generic_rsrc.GenericResource('test_resource', tmpl1, self.stack) res1 = generic_rsrc.GenericResource('test_resource', tmpl1, self.stack)
res2 = generic_rsrc.GenericResource('test_resource', tmpl2, stack2) res2 = generic_rsrc.GenericResource('test_resource', tmpl2, stack2)
res3 = generic_rsrc.GenericResource('test_resource2', tmpl3, stack2) res3 = generic_rsrc.GenericResource('test_resource2', tmpl3, stack2)
@ -1797,7 +1797,7 @@ class MetadataTest(common.HeatTestCase):
super(MetadataTest, self).setUp() super(MetadataTest, self).setUp()
self.stack = parser.Stack(utils.dummy_context(), self.stack = parser.Stack(utils.dummy_context(),
'test_stack', 'test_stack',
parser.Template(empty_template)) template.Template(empty_template))
self.stack.store() self.stack.store()
metadata = {'Test': 'Initial metadata'} metadata = {'Test': 'Initial metadata'}
@ -1910,7 +1910,7 @@ class ResourceHookTest(common.HeatTestCase):
u'ResourceWithCustomConstraint'}}) u'ResourceWithCustomConstraint'}})
self.stack = parser.Stack(utils.dummy_context(), 'test_stack', self.stack = parser.Stack(utils.dummy_context(), 'test_stack',
parser.Template(empty_template, template.Template(empty_template,
env=self.env), env=self.env),
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))

View File

@ -23,9 +23,9 @@ from novaclient.v2 import security_groups as nova_sg
from heat.common import exception from heat.common import exception
from heat.common import template_format from heat.common import template_format
from heat.engine.clients.os import nova from heat.engine.clients.os import nova
from heat.engine import parser
from heat.engine import rsrc_defn from heat.engine import rsrc_defn
from heat.engine import scheduler from heat.engine import scheduler
from heat.engine import stack as parser
from heat.engine import template from heat.engine import template
from heat.tests import common from heat.tests import common
from heat.tests.nova import fakes as fakes_nova from heat.tests.nova import fakes as fakes_nova

View File

@ -28,10 +28,10 @@ from heat.engine.clients.os import neutron
from heat.engine.clients.os import nova from heat.engine.clients.os import nova
from heat.engine.clients.os import swift from heat.engine.clients.os import swift
from heat.engine import environment from heat.engine import environment
from heat.engine import parser
from heat.engine import resource from heat.engine import resource
from heat.engine.resources.openstack.nova import server as servers from heat.engine.resources.openstack.nova import server as servers
from heat.engine import scheduler from heat.engine import scheduler
from heat.engine import stack as parser
from heat.engine import template from heat.engine import template
from heat.objects import resource_data as resource_data_object from heat.objects import resource_data as resource_data_object
from heat.tests import common from heat.tests import common
@ -3066,8 +3066,8 @@ class ServersTest(common.HeatTestCase):
def test_server_restore(self): def test_server_restore(self):
t = template_format.parse(wp_template) t = template_format.parse(wp_template)
template = parser.Template(t) tmpl = template.Template(t)
stack = parser.Stack(utils.dummy_context(), "server_restore", template) stack = parser.Stack(utils.dummy_context(), "server_restore", tmpl)
stack.store() stack.store()
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create') self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')

View File

@ -18,9 +18,10 @@ from heat.common import template_format
from heat.engine.clients.os import glance from heat.engine.clients.os import glance
from heat.engine.clients.os import nova from heat.engine.clients.os import nova
from heat.engine import environment from heat.engine import environment
from heat.engine import parser
from heat.engine.resources.aws.ec2 import instance as instances from heat.engine.resources.aws.ec2 import instance as instances
from heat.engine import scheduler 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 common
from heat.tests.nova import fakes as fakes_nova from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils from heat.tests import utils
@ -65,7 +66,7 @@ class ServerTagsTest(common.HeatTestCase):
def _setup_test_instance(self, intags=None, nova_tags=None): def _setup_test_instance(self, intags=None, nova_tags=None):
stack_name = 'tag_test' stack_name = 'tag_test'
t = template_format.parse(instance_template) t = template_format.parse(instance_template)
template = parser.Template(t, template = tmpl.Template(t,
env=environment.Environment( env=environment.Environment(
{'KeyName': 'test'})) {'KeyName': 'test'}))
stack = parser.Stack(utils.dummy_context(), stack_name, template, stack = parser.Stack(utils.dummy_context(), stack_name, template,

View File

@ -18,10 +18,10 @@ from oslo_config import cfg
from heat.common import exception from heat.common import exception
from heat.common import template_format from heat.common import template_format
from heat.engine import parser
from heat.engine import resource from heat.engine import resource
from heat.engine.resources import stack_user from heat.engine.resources import stack_user
from heat.engine import scheduler from heat.engine import scheduler
from heat.engine import stack as parser
from heat.engine import template from heat.engine import template
from heat.objects import resource_data as resource_data_object from heat.objects import resource_data as resource_data_object
from heat.tests import common from heat.tests import common

View File

@ -14,8 +14,8 @@
import mock import mock
from heat.common import exception as exc from heat.common import exception as exc
from heat.engine import parser
from heat.engine.resources.openstack.heat import software_config as sc from heat.engine.resources.openstack.heat import software_config as sc
from heat.engine import stack
from heat.engine import template from heat.engine import template
from heat.tests import common from heat.tests import common
from heat.tests import utils from heat.tests import utils
@ -33,7 +33,7 @@ class SoftwareConfigTest(common.HeatTestCase):
'options': {}, 'options': {},
'config': '#!/bin/bash' 'config': '#!/bin/bash'
} }
self.stack = parser.Stack( self.stack = stack.Stack(
self.ctx, 'software_config_test_stack', self.ctx, 'software_config_test_stack',
template.Template({ template.Template({
'HeatTemplateFormatVersion': '2012-12-12', 'HeatTemplateFormatVersion': '2012-12-12',

View File

@ -22,9 +22,9 @@ from heat.common import exception as exc
from heat.common.i18n import _ from heat.common.i18n import _
from heat.engine.clients.os import nova from heat.engine.clients.os import nova
from heat.engine.clients.os import swift from heat.engine.clients.os import swift
from heat.engine import parser
from heat.engine.resources.openstack.heat import software_deployment as sd from heat.engine.resources.openstack.heat import software_deployment as sd
from heat.engine import rsrc_defn from heat.engine import rsrc_defn
from heat.engine import stack as parser
from heat.engine import template from heat.engine import template
from heat.tests import common from heat.tests import common
from heat.tests import utils from heat.tests import utils

View File

@ -12,8 +12,8 @@
# under the License. # under the License.
from heat.common import template_format from heat.common import template_format
from heat.engine import parser
from heat.engine import resource from heat.engine import resource
from heat.engine import stack
from heat.engine import template from heat.engine import template
from heat.tests import common from heat.tests import common
from heat.tests import generic_resource as generic_rsrc from heat.tests import generic_resource as generic_rsrc
@ -171,7 +171,7 @@ class DepAttrsTest(common.HeatTestCase):
def test_dep_attrs(self): def test_dep_attrs(self):
parsed_tmpl = template_format.parse(self.tmpl) parsed_tmpl = template_format.parse(self.tmpl)
self.stack = parser.Stack(self.ctx, 'test_stack', self.stack = stack.Stack(self.ctx, 'test_stack',
template.Template(parsed_tmpl)) template.Template(parsed_tmpl))
resources = self.stack.resources.values() resources = self.stack.resources.values()
outputs = self.stack.outputs outputs = self.stack.outputs

View File

@ -14,8 +14,8 @@
import mock import mock
from heat.common import exception from heat.common import exception
from heat.engine import parser
from heat.engine.resources.openstack.heat import structured_config as sc from heat.engine.resources.openstack.heat import structured_config as sc
from heat.engine import stack as parser
from heat.engine import template from heat.engine import template
from heat.tests import common from heat.tests import common
from heat.tests import utils from heat.tests import utils

View File

@ -20,10 +20,11 @@ from heat.common import template_format
from heat.engine.clients.os import glance from heat.engine.clients.os import glance
from heat.engine.clients.os import nova from heat.engine.clients.os import nova
from heat.engine import environment from heat.engine import environment
from heat.engine.hot import template as tmpl from heat.engine.hot import template as hot_tmpl
from heat.engine import parser
from heat.engine import resources from heat.engine import resources
from heat.engine import service from heat.engine import service
from heat.engine import stack as parser
from heat.engine import template as tmpl
from heat.tests import common from heat.tests import common
from heat.tests.nova import fakes as fakes_nova from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils from heat.tests import utils
@ -832,14 +833,14 @@ class validateTest(common.HeatTestCase):
def test_validate_volumeattach_valid(self): def test_validate_volumeattach_valid(self):
t = template_format.parse(test_template_volumeattach % 'vdq') t = template_format.parse(test_template_volumeattach % 'vdq')
stack = parser.Stack(self.ctx, 'test_stack', parser.Template(t)) stack = parser.Stack(self.ctx, 'test_stack', tmpl.Template(t))
volumeattach = stack['MountPoint'] volumeattach = stack['MountPoint']
self.assertIsNone(volumeattach.validate()) self.assertIsNone(volumeattach.validate())
def test_validate_volumeattach_invalid(self): def test_validate_volumeattach_invalid(self):
t = template_format.parse(test_template_volumeattach % 'sda') t = template_format.parse(test_template_volumeattach % 'sda')
stack = parser.Stack(self.ctx, 'test_stack', parser.Template(t)) stack = parser.Stack(self.ctx, 'test_stack', tmpl.Template(t))
volumeattach = stack['MountPoint'] volumeattach = stack['MountPoint']
self.assertRaises(exception.StackValidationFailed, self.assertRaises(exception.StackValidationFailed,
@ -1246,7 +1247,7 @@ class validateTest(common.HeatTestCase):
def test_unregistered_key(self): def test_unregistered_key(self):
t = template_format.parse(test_unregistered_key) t = template_format.parse(test_unregistered_key)
params = {'KeyName': 'not_registered'} params = {'KeyName': 'not_registered'}
template = parser.Template(t, env=environment.Environment(params)) template = tmpl.Template(t, env=environment.Environment(params))
stack = parser.Stack(self.ctx, 'test_stack', template) stack = parser.Stack(self.ctx, 'test_stack', template)
self._mock_get_image_id_success('image_name', 'image_id') self._mock_get_image_id_success('image_name', 'image_id')
@ -1258,7 +1259,7 @@ class validateTest(common.HeatTestCase):
def test_unregistered_image(self): def test_unregistered_image(self):
t = template_format.parse(test_template_image) t = template_format.parse(test_template_image)
template = parser.Template(t, template = tmpl.Template(t,
env=environment.Environment( env=environment.Environment(
{'KeyName': 'test'})) {'KeyName': 'test'}))
@ -1276,7 +1277,7 @@ class validateTest(common.HeatTestCase):
def test_duplicated_image(self): def test_duplicated_image(self):
t = template_format.parse(test_template_image) t = template_format.parse(test_template_image)
template = parser.Template(t, template = tmpl.Template(t,
env=environment.Environment( env=environment.Environment(
{'KeyName': 'test'})) {'KeyName': 'test'}))
@ -1296,7 +1297,7 @@ class validateTest(common.HeatTestCase):
def test_invalid_security_groups_with_nics(self): def test_invalid_security_groups_with_nics(self):
t = template_format.parse(test_template_invalid_secgroups) t = template_format.parse(test_template_invalid_secgroups)
template = parser.Template(t, template = tmpl.Template(t,
env=environment.Environment( env=environment.Environment(
{'KeyName': 'test'})) {'KeyName': 'test'}))
stack = parser.Stack(self.ctx, 'test_stack', template) stack = parser.Stack(self.ctx, 'test_stack', template)
@ -1314,7 +1315,7 @@ class validateTest(common.HeatTestCase):
def test_invalid_security_group_ids_with_nics(self): def test_invalid_security_group_ids_with_nics(self):
t = template_format.parse(test_template_invalid_secgroupids) t = template_format.parse(test_template_invalid_secgroupids)
template = parser.Template( template = tmpl.Template(
t, env=environment.Environment({'KeyName': 'test'})) t, env=environment.Environment({'KeyName': 'test'}))
stack = parser.Stack(self.ctx, 'test_stack', template) stack = parser.Stack(self.ctx, 'test_stack', template)
@ -1331,7 +1332,7 @@ class validateTest(common.HeatTestCase):
def test_client_exception_from_glance_client(self): def test_client_exception_from_glance_client(self):
t = template_format.parse(test_template_glance_client_exception) t = template_format.parse(test_template_glance_client_exception)
template = parser.Template(t) template = tmpl.Template(t)
stack = parser.Stack(self.ctx, 'test_stack', template) stack = parser.Stack(self.ctx, 'test_stack', template)
self.m.StubOutWithMock(self.gc.images, 'list') self.m.StubOutWithMock(self.gc.images, 'list')
@ -1346,7 +1347,7 @@ class validateTest(common.HeatTestCase):
def test_validate_unique_logical_name(self): def test_validate_unique_logical_name(self):
t = template_format.parse(test_template_unique_logical_name) t = template_format.parse(test_template_unique_logical_name)
template = parser.Template( template = tmpl.Template(
t, env=environment.Environment( t, env=environment.Environment(
{'AName': 'test', 'KeyName': 'test'})) {'AName': 'test', 'KeyName': 'test'}))
stack = parser.Stack(self.ctx, 'test_stack', template) stack = parser.Stack(self.ctx, 'test_stack', template)
@ -1355,7 +1356,7 @@ class validateTest(common.HeatTestCase):
def test_validate_duplicate_parameters_in_group(self): def test_validate_duplicate_parameters_in_group(self):
t = template_format.parse(test_template_duplicate_parameters) t = template_format.parse(test_template_duplicate_parameters)
template = tmpl.HOTemplate20130523( template = hot_tmpl.HOTemplate20130523(
t, env=environment.Environment({ t, env=environment.Environment({
'KeyName': 'test', 'KeyName': 'test',
'ImageId': 'sometestid', 'ImageId': 'sometestid',
@ -1370,7 +1371,7 @@ class validateTest(common.HeatTestCase):
def test_validate_invalid_parameter_in_group(self): def test_validate_invalid_parameter_in_group(self):
t = template_format.parse(test_template_invalid_parameter_name) t = template_format.parse(test_template_invalid_parameter_name)
template = tmpl.HOTemplate20130523(t, template = hot_tmpl.HOTemplate20130523(t,
env=environment.Environment({ env=environment.Environment({
'KeyName': 'test', 'KeyName': 'test',
'ImageId': 'sometestid', 'ImageId': 'sometestid',
@ -1386,7 +1387,7 @@ class validateTest(common.HeatTestCase):
def test_validate_no_parameters_in_group(self): def test_validate_no_parameters_in_group(self):
t = template_format.parse(test_template_no_parameters) t = template_format.parse(test_template_no_parameters)
template = tmpl.HOTemplate20130523(t) template = hot_tmpl.HOTemplate20130523(t)
stack = parser.Stack(self.ctx, 'test_stack', template) stack = parser.Stack(self.ctx, 'test_stack', template)
exc = self.assertRaises(exception.StackValidationFailed, exc = self.assertRaises(exception.StackValidationFailed,
stack.validate) stack.validate)
@ -1396,7 +1397,7 @@ class validateTest(common.HeatTestCase):
def test_validate_allowed_values_integer(self): def test_validate_allowed_values_integer(self):
t = template_format.parse(test_template_allowed_integers) t = template_format.parse(test_template_allowed_integers)
template = parser.Template(t, template = tmpl.Template(t,
env=environment.Environment({'size': '4'})) env=environment.Environment({'size': '4'}))
# test with size parameter provided as string # test with size parameter provided as string
@ -1410,7 +1411,7 @@ class validateTest(common.HeatTestCase):
def test_validate_allowed_values_integer_str(self): def test_validate_allowed_values_integer_str(self):
t = template_format.parse(test_template_allowed_integers_str) t = template_format.parse(test_template_allowed_integers_str)
template = parser.Template(t, template = tmpl.Template(t,
env=environment.Environment({'size': '4'})) env=environment.Environment({'size': '4'}))
# test with size parameter provided as string # test with size parameter provided as string
@ -1423,7 +1424,7 @@ class validateTest(common.HeatTestCase):
def test_validate_not_allowed_values_integer(self): def test_validate_not_allowed_values_integer(self):
t = template_format.parse(test_template_allowed_integers) t = template_format.parse(test_template_allowed_integers)
template = parser.Template(t, template = tmpl.Template(t,
env=environment.Environment({'size': '3'})) env=environment.Environment({'size': '3'}))
# test with size parameter provided as string # test with size parameter provided as string
@ -1443,7 +1444,7 @@ class validateTest(common.HeatTestCase):
def test_validate_not_allowed_values_integer_str(self): def test_validate_not_allowed_values_integer_str(self):
t = template_format.parse(test_template_allowed_integers_str) t = template_format.parse(test_template_allowed_integers_str)
template = parser.Template(t, template = tmpl.Template(t,
env=environment.Environment({'size': '3'})) env=environment.Environment({'size': '3'}))
# test with size parameter provided as string # test with size parameter provided as string
@ -1463,7 +1464,7 @@ class validateTest(common.HeatTestCase):
def test_validate_invalid_outputs(self): def test_validate_invalid_outputs(self):
t = template_format.parse(test_template_invalid_outputs) t = template_format.parse(test_template_invalid_outputs)
template = parser.Template(t) template = tmpl.Template(t)
err = self.assertRaises(exception.StackValidationFailed, err = self.assertRaises(exception.StackValidationFailed,
parser.Stack, self.ctx, 'test_stack', template) parser.Stack, self.ctx, 'test_stack', template)
error_message = ('Arguments to "get_attr" must be of the form ' error_message = ('Arguments to "get_attr" must be of the form '
@ -1477,7 +1478,7 @@ class validateTest(common.HeatTestCase):
resource: resource:
type: 123 type: 123
""") """)
template = parser.Template(t) template = tmpl.Template(t)
stack = parser.Stack(self.ctx, 'test_stack', template) stack = parser.Stack(self.ctx, 'test_stack', template)
ex = self.assertRaises(exception.StackValidationFailed, stack.validate) ex = self.assertRaises(exception.StackValidationFailed, stack.validate)
self.assertEqual('Resource resource type type must be string', self.assertEqual('Resource resource type type must be string',
@ -1490,7 +1491,7 @@ class validateTest(common.HeatTestCase):
Resource: Resource:
Type: [Wrong, Type] Type: [Wrong, Type]
""") """)
stack = parser.Stack(self.ctx, 'test_stack', parser.Template(t)) stack = parser.Stack(self.ctx, 'test_stack', tmpl.Template(t))
ex = self.assertRaises(exception.StackValidationFailed, stack.validate) ex = self.assertRaises(exception.StackValidationFailed, stack.validate)
self.assertEqual('Resource Resource Type type must be string', self.assertEqual('Resource Resource Type type must be string',
six.text_type(ex)) six.text_type(ex))

View File

@ -15,9 +15,9 @@ import uuid
from heat.common import exception from heat.common import exception
from heat.common import template_format from heat.common import template_format
from heat.engine import parser
from heat.engine.resources.aws.ec2 import subnet as sn from heat.engine.resources.aws.ec2 import subnet as sn
from heat.engine import scheduler from heat.engine import scheduler
from heat.engine import stack as parser
from heat.engine import template from heat.engine import template
from heat.tests import common from heat.tests import common
from heat.tests import utils from heat.tests import utils
@ -454,7 +454,7 @@ Resources:
self.m.ReplayAll() self.m.ReplayAll()
t = template_format.parse(self.test_template) t = template_format.parse(self.test_template)
tmpl = parser.Template(t) tmpl = template.Template(t)
stack = parser.Stack(utils.dummy_context(), 'test_subnet_', tmpl, stack = parser.Stack(utils.dummy_context(), 'test_subnet_', tmpl,
stack_id=str(uuid.uuid4())) stack_id=str(uuid.uuid4()))
tmpl.t['Resources']['the_subnet']['Properties']['VpcId'] = 'aaaa' tmpl.t['Resources']['the_subnet']['Properties']['VpcId'] = 'aaaa'

View File

@ -18,7 +18,7 @@ import mox
from oslo_utils import timeutils from oslo_utils import timeutils
from heat.common import exception from heat.common import exception
from heat.engine import parser from heat.engine import stack
from heat.engine import template from heat.engine import template
from heat.engine import watchrule from heat.engine import watchrule
from heat.objects import watch_rule from heat.objects import watch_rule
@ -50,7 +50,7 @@ class WatchRuleTest(common.HeatTestCase):
empty_tmpl = {'HeatTemplateFormatVersion': '2012-12-12'} empty_tmpl = {'HeatTemplateFormatVersion': '2012-12-12'}
tmpl = template.Template(empty_tmpl) tmpl = template.Template(empty_tmpl)
stack_name = 'dummystack' stack_name = 'dummystack'
dummy_stack = parser.Stack(ctx, stack_name, tmpl) dummy_stack = stack.Stack(ctx, stack_name, tmpl)
dummy_stack.state_set(dummy_stack.CREATE, dummy_stack.COMPLETE, dummy_stack.state_set(dummy_stack.CREATE, dummy_stack.COMPLETE,
'Testing') 'Testing')
dummy_stack.store() dummy_stack.store()
@ -74,8 +74,8 @@ class WatchRuleTest(common.HeatTestCase):
if action_expected: if action_expected:
dummy_action = DummyAction() dummy_action = DummyAction()
self.m.StubOutWithMock(parser.Stack, 'resource_by_refid') self.m.StubOutWithMock(stack.Stack, 'resource_by_refid')
parser.Stack.resource_by_refid( stack.Stack.resource_by_refid(
mox.IgnoreArg()).MultipleTimes().AndReturn(dummy_action) mox.IgnoreArg()).MultipleTimes().AndReturn(dummy_action)
self.m.ReplayAll() self.m.ReplayAll()