From cd2fd324a044f8762613793206216cf73617c2ad Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Fri, 30 Nov 2012 14:12:38 +0100 Subject: [PATCH] Move template-format parsing code into common This is used mostly by the API (but also the engine for composed templates), so it doesn't belong in the engine package. Change-Id: I79cf8cc619a6988013a58eb4d46c014c3dcac4a3 Signed-off-by: Zane Bitter --- heat/api/cfn/v1/stacks.py | 4 ++-- heat/api/openstack/v1/stacks.py | 4 ++-- .../format.py => common/template_format.py} | 2 +- heat/engine/parser.py | 2 +- heat/engine/resources/dbinstance.py | 4 ++-- heat/engine/resources/loadbalancer.py | 6 ++--- heat/engine/resources/stack.py | 4 ++-- heat/tests/functional/test_CFN_API_Actions.py | 4 ++-- heat/tests/functional/util.py | 4 ++-- heat/tests/test_autoscaling.py | 4 ++-- heat/tests/test_dbinstance.py | 4 ++-- heat/tests/test_eip.py | 4 ++-- heat/tests/test_engine_service.py | 4 ++-- heat/tests/test_instance.py | 6 ++--- heat/tests/test_loadbalancer.py | 6 ++--- heat/tests/test_parser.py | 4 ++-- heat/tests/test_quantum.py | 4 ++-- heat/tests/test_s3.py | 4 ++-- ...test_format.py => test_template_format.py} | 22 +++++++++---------- heat/tests/test_user.py | 4 ++-- heat/tests/test_validate.py | 14 ++++++------ heat/tests/test_volume.py | 4 ++-- heat/tests/test_waitcondition.py | 8 +++---- tools/cfn-json2yaml | 6 ++--- 24 files changed, 66 insertions(+), 66 deletions(-) rename heat/{engine/format.py => common/template_format.py} (98%) rename heat/tests/{test_format.py => test_template_format.py} (89%) diff --git a/heat/api/cfn/v1/stacks.py b/heat/api/cfn/v1/stacks.py index b7b0b5bc..99f1a722 100644 --- a/heat/api/cfn/v1/stacks.py +++ b/heat/api/cfn/v1/stacks.py @@ -26,7 +26,7 @@ from heat.api.aws import exception from heat.api.aws import utils as api_utils from heat.common import wsgi from heat.engine import rpcapi as engine_rpcapi -from heat.engine import format +from heat.common import template_format import heat.engine.api as engine_api from heat.common import identifier @@ -316,7 +316,7 @@ class StackController(object): return exception.HeatMissingParameterError(detail=msg) try: - stack = format.parse_to_template(templ) + stack = template_format.parse(templ) except ValueError: msg = _("The Template must be a JSON document.") return exception.HeatInvalidParameterValueError(detail=msg) diff --git a/heat/api/openstack/v1/stacks.py b/heat/api/openstack/v1/stacks.py index 64a78fec..e76f02e8 100644 --- a/heat/api/openstack/v1/stacks.py +++ b/heat/api/openstack/v1/stacks.py @@ -26,7 +26,7 @@ from webob import exc from heat.api.openstack.v1 import util from heat.common import wsgi -from heat.engine import format +from heat.common import template_format from heat.engine import api as engine_api from heat.engine import rpcapi as engine_rpcapi @@ -65,7 +65,7 @@ class InstantiationData(object): """ try: - return format.parse_to_template(data) + return template_format.parse(data) except ValueError: err_reason = "%s not in valid format" % data_type raise exc.HTTPBadRequest(explanation=err_reason) diff --git a/heat/engine/format.py b/heat/common/template_format.py similarity index 98% rename from heat/engine/format.py rename to heat/common/template_format.py index 8647d677..7e120ded 100644 --- a/heat/engine/format.py +++ b/heat/common/template_format.py @@ -29,7 +29,7 @@ yaml.Loader.add_constructor(u'tag:yaml.org,2002:str', _construct_yaml_str) yaml.SafeLoader.add_constructor(u'tag:yaml.org,2002:str', _construct_yaml_str) -def parse_to_template(tmpl_str): +def parse(tmpl_str): ''' Takes a string and returns a dict containing the parsed structure. This includes determination of whether the string is using the diff --git a/heat/engine/parser.py b/heat/engine/parser.py index 2244ece5..10d1dc93 100644 --- a/heat/engine/parser.py +++ b/heat/engine/parser.py @@ -430,7 +430,7 @@ def resolve_static_data(template, parameters, snippet): Example: - >>> template = Template(format.parse_to_template(template_path)) + >>> template = Template(template_format.parse(template_path)) >>> parameters = Parameters('stack', template, {'KeyName': 'my_key'}) >>> resolve_static_data(template, parameters, {'Ref': 'KeyName'}) 'my_key' diff --git a/heat/engine/resources/dbinstance.py b/heat/engine/resources/dbinstance.py index f8acebc5..bb5c2b22 100644 --- a/heat/engine/resources/dbinstance.py +++ b/heat/engine/resources/dbinstance.py @@ -15,7 +15,7 @@ from heat.common import exception from heat.engine.resources import stack -from heat.engine import format +from heat.common import template_format from heat.openstack.common import log as logging logger = logging.getLogger(__file__) @@ -219,7 +219,7 @@ class DBInstance(stack.Stack): return p def handle_create(self): - templ = format.parse_to_template(mysql_template) + templ = template_format.parse(mysql_template) self.create_with_template(templ) def FnGetAtt(self, key): diff --git a/heat/engine/resources/loadbalancer.py b/heat/engine/resources/loadbalancer.py index dd8950b2..9dd8c145 100644 --- a/heat/engine/resources/loadbalancer.py +++ b/heat/engine/resources/loadbalancer.py @@ -14,7 +14,7 @@ # under the License. from heat.common import exception -from heat.engine import format +from heat.common import template_format from heat.engine.resources import stack from novaclient.exceptions import NotFound @@ -283,7 +283,7 @@ class LoadBalancer(stack.Stack): return '%s%s%s%s\n' % (gl, frontend, backend, '\n'.join(servers)) def handle_create(self): - templ = format.parse_to_template(lb_template) + templ = template_format.parse(lb_template) if self.properties['Instances']: md = templ['Resources']['LB_instance']['Metadata'] @@ -313,7 +313,7 @@ class LoadBalancer(stack.Stack): save it to the db. rely on the cfn-hup to reconfigure HAProxy ''' - templ = format.parse_to_template(lb_template) + templ = template_format.parse(lb_template) cfg = self._haproxy_config(templ, inst_list) md = self.nested()['LB_instance'].metadata diff --git a/heat/engine/resources/stack.py b/heat/engine/resources/stack.py index 87ebf72c..cb1e4c26 100644 --- a/heat/engine/resources/stack.py +++ b/heat/engine/resources/stack.py @@ -17,7 +17,7 @@ import urllib2 import json from heat.common import exception -from heat.engine import format +from heat.common import template_format from heat.engine import resource from heat.engine import parser @@ -76,7 +76,7 @@ class Stack(resource.Resource): def handle_create(self): response = urllib2.urlopen(self.properties[PROP_TEMPLATE_URL]) - template = format.parse_to_template(response) + template = template_format.parse(response) self.create_with_template(template) diff --git a/heat/tests/functional/test_CFN_API_Actions.py b/heat/tests/functional/test_CFN_API_Actions.py index e2593348..a8441bce 100644 --- a/heat/tests/functional/test_CFN_API_Actions.py +++ b/heat/tests/functional/test_CFN_API_Actions.py @@ -21,7 +21,7 @@ from nose.plugins.attrib import attr import unittest import json -from heat.engine import format +from heat.common import template_format @attr(speed='slow') @@ -282,7 +282,7 @@ class CfnApiFunctionalTest(unittest.TestCase): # Extract the JSON TemplateBody and prove it parses template = self.stack.response_xml_item(response, prefix, "TemplateBody") - json_load = format.parse_to_template(template) + json_load = template_format.parse(template) self.assertTrue(json_load != None) # Then sanity check content - I guess we could diff diff --git a/heat/tests/functional/util.py b/heat/tests/functional/util.py index 8d16220c..3a12d051 100644 --- a/heat/tests/functional/util.py +++ b/heat/tests/functional/util.py @@ -41,7 +41,7 @@ except ImportError: from novaclient.v1_1 import client as nova_client import heat from heat import utils -from heat.engine import format +from heat.common import template_format from heat.engine import parser from heat import client as heat_client from heat import boto_client as heat_client_boto @@ -249,7 +249,7 @@ class Instance(object): # time.sleep(1) # necessary for sendall to complete f = open(basepath + '/templates/' + template_file) - t = format.parse_to_template(f.read()) + t = template_format.parse(f.read()) f.close() template = parser.Template(t) diff --git a/heat/tests/test_autoscaling.py b/heat/tests/test_autoscaling.py index fe9df09c..a8c5c9fe 100644 --- a/heat/tests/test_autoscaling.py +++ b/heat/tests/test_autoscaling.py @@ -24,7 +24,7 @@ import json from nose.plugins.attrib import attr from heat.common import context -from heat.engine import format +from heat.common import template_format from heat.engine.resources import autoscaling as asc from heat.engine.resources import loadbalancer from heat.engine import parser @@ -45,7 +45,7 @@ class AutoScalingTest(unittest.TestCase): self.path = os.path.dirname(os.path.realpath(__file__)).\ replace('heat/tests', 'templates') f = open("%s/AutoScalingMultiAZSample.template" % self.path) - t = format.parse_to_template(f.read()) + t = template_format.parse(f.read()) f.close() return t diff --git a/heat/tests/test_dbinstance.py b/heat/tests/test_dbinstance.py index f717194b..cdffbdab 100644 --- a/heat/tests/test_dbinstance.py +++ b/heat/tests/test_dbinstance.py @@ -25,7 +25,7 @@ from nose.plugins.attrib import attr from heat.common import context from heat.common import exception -from heat.engine import format +from heat.common import template_format from heat.engine import parser from heat.engine.resources import stack from heat.engine.resources import dbinstance as dbi @@ -47,7 +47,7 @@ class DBInstanceTest(unittest.TestCase): self.path = os.path.dirname(os.path.realpath(__file__)).\ replace('heat/tests', 'templates') f = open("%s/WordPress_With_RDS.template" % self.path) - t = format.parse_to_template(f.read()) + t = template_format.parse(f.read()) f.close() return t diff --git a/heat/tests/test_eip.py b/heat/tests/test_eip.py index 41c64fc6..be64db16 100644 --- a/heat/tests/test_eip.py +++ b/heat/tests/test_eip.py @@ -24,7 +24,7 @@ import json from nose.plugins.attrib import attr from heat.common import context -from heat.engine import format +from heat.common import template_format from heat.engine.resources import eip from heat.engine import parser from heat.tests.v1_1 import fakes @@ -48,7 +48,7 @@ class EIPTest(unittest.TestCase): self.path = os.path.dirname(os.path.realpath(__file__)).\ replace('heat/tests', 'templates') f = open("%s/WordPress_Single_Instance_With_EIP.template" % self.path) - t = format.parse_to_template(f.read()) + t = template_format.parse(f.read()) f.close() return t diff --git a/heat/tests/test_engine_service.py b/heat/tests/test_engine_service.py index 5dcf7069..d4dbbcfa 100644 --- a/heat/tests/test_engine_service.py +++ b/heat/tests/test_engine_service.py @@ -27,7 +27,7 @@ from heat.common import context from heat.tests.v1_1 import fakes import heat.engine.api as engine_api import heat.db as db_api -from heat.engine import format +from heat.common import template_format from heat.engine import parser from heat.engine import service from heat.engine.resources import instance as instances @@ -55,7 +55,7 @@ def get_wordpress_stack(stack_name, ctx): tmpl_path = os.path.join(templates_dir, 'WordPress_Single_Instance_gold.template') with open(tmpl_path) as f: - t = format.parse_to_template(f.read()) + t = template_format.parse(f.read()) template = parser.Template(t) parameters = parser.Parameters(stack_name, template, diff --git a/heat/tests/test_instance.py b/heat/tests/test_instance.py index fe52dfb0..f3781adf 100644 --- a/heat/tests/test_instance.py +++ b/heat/tests/test_instance.py @@ -28,7 +28,7 @@ from nose import with_setup from heat.tests.v1_1 import fakes from heat.engine.resources import instance as instances import heat.db as db_api -from heat.engine import format +from heat.common import template_format from heat.engine import parser @@ -47,7 +47,7 @@ class instancesTest(unittest.TestCase): def test_instance_create(self): f = open("%s/WordPress_Single_Instance_gold.template" % self.path) - t = format.parse_to_template(f.read()) + t = template_format.parse(f.read()) f.close() template = parser.Template(t) @@ -89,7 +89,7 @@ class instancesTest(unittest.TestCase): def test_instance_create_delete(self): f = open("%s/WordPress_Single_Instance_gold.template" % self.path) - t = format.parse_to_template(f.read()) + t = template_format.parse(f.read()) f.close() template = parser.Template(t) diff --git a/heat/tests/test_loadbalancer.py b/heat/tests/test_loadbalancer.py index ec179df5..89deb9f1 100644 --- a/heat/tests/test_loadbalancer.py +++ b/heat/tests/test_loadbalancer.py @@ -27,7 +27,7 @@ from nose.plugins.attrib import attr from heat.common import exception from heat.common import context from heat.common import config -from heat.engine import format +from heat.common import template_format from heat.engine import parser from heat.engine.resources import instance from heat.engine.resources import loadbalancer as lb @@ -66,7 +66,7 @@ class LoadBalancerTest(unittest.TestCase): self.path = os.path.dirname(os.path.realpath(__file__)).\ replace('heat/tests', 'templates') f = open("%s/WordPress_With_LB.template" % self.path) - t = format.parse_to_template(f.read()) + t = template_format.parse(f.read()) f.close() return t @@ -124,7 +124,7 @@ class LoadBalancerTest(unittest.TestCase): self.assertEqual('LoadBalancer', resource.FnGetRefId()) - templ = format.parse_to_template(lb.lb_template) + templ = template_format.parse(lb.lb_template) ha_cfg = resource._haproxy_config(templ, resource.properties['Instances']) self.assertRegexpMatches(ha_cfg, 'bind \*:80') diff --git a/heat/tests/test_parser.py b/heat/tests/test_parser.py index a0a95fbe..c4d68f75 100644 --- a/heat/tests/test_parser.py +++ b/heat/tests/test_parser.py @@ -22,7 +22,7 @@ import sys from heat.common import context from heat.common import exception -from heat.engine import format +from heat.common import template_format from heat.engine import parser from heat.engine import parameters from heat.engine import template @@ -96,7 +96,7 @@ class ParserTest(unittest.TestCase): self.assertEqual(join(raw), 'foo bar\nbaz') -mapping_template = format.parse_to_template('''{ +mapping_template = template_format.parse('''{ "Mappings" : { "ValidMapping" : { "TestKey" : { "TestValue" : "wibble" } diff --git a/heat/tests/test_quantum.py b/heat/tests/test_quantum.py index 7c20fb18..37160fc2 100644 --- a/heat/tests/test_quantum.py +++ b/heat/tests/test_quantum.py @@ -25,7 +25,7 @@ from nose.plugins.attrib import attr from heat.common import context from heat.common import exception -from heat.engine import format +from heat.common import template_format from heat.engine import properties from heat.engine.resources.quantum import net from heat.engine.resources.quantum.quantum import QuantumResource as qr @@ -82,7 +82,7 @@ class QuantumTest(unittest.TestCase): self.path = os.path.dirname(os.path.realpath(__file__)).\ replace('heat/tests', 'templates') f = open("%s/Quantum.template" % self.path) - t = format.parse_to_template(f.read()) + t = template_format.parse(f.read()) f.close() return t diff --git a/heat/tests/test_s3.py b/heat/tests/test_s3.py index c884baa6..0842ba96 100644 --- a/heat/tests/test_s3.py +++ b/heat/tests/test_s3.py @@ -25,7 +25,7 @@ import json from nose.plugins.attrib import attr from heat.common import context -from heat.engine import format +from heat.common import template_format from heat.engine.resources import s3 from heat.engine import parser from utils import skip_if @@ -59,7 +59,7 @@ class s3Test(unittest.TestCase): self.path = os.path.dirname(os.path.realpath(__file__)).\ replace('heat/tests', 'templates') f = open("%s/S3_Single_Instance.template" % self.path) - t = format.parse_to_template(f.read()) + t = template_format.parse(f.read()) f.close() return t diff --git a/heat/tests/test_format.py b/heat/tests/test_template_format.py similarity index 89% rename from heat/tests/test_format.py rename to heat/tests/test_template_format.py index 2308e98d..d89d0428 100644 --- a/heat/tests/test_format.py +++ b/heat/tests/test_template_format.py @@ -22,7 +22,7 @@ import unittest import yaml from heat.common import context -from heat.engine import format +from heat.common import template_format from heat.engine import parser @@ -53,16 +53,16 @@ class JsonToYamlTest(unittest.TestCase): self.expected_test_count) def compare_json_vs_yaml(self, json_str, yml_str, file_name): - yml = format.parse_to_template(yml_str) + yml = template_format.parse(yml_str) self.assertEqual(u'2012-12-12', yml[u'HeatTemplateFormatVersion'], file_name) self.assertFalse(u'AWSTemplateFormatVersion' in yml, file_name) del(yml[u'HeatTemplateFormatVersion']) - jsn = format.parse_to_template(json_str) - format.default_for_missing(jsn, 'AWSTemplateFormatVersion', - format.CFN_VERSIONS) + jsn = template_format.parse(json_str) + template_format.default_for_missing(jsn, 'AWSTemplateFormatVersion', + template_format.CFN_VERSIONS) if u'AWSTemplateFormatVersion' in jsn: del(jsn[u'AWSTemplateFormatVersion']) @@ -76,7 +76,7 @@ class JsonToYamlTest(unittest.TestCase): f = open(os.path.join(dirpath, path), 'r') json_str = f.read() - yml_str = format.convert_json_to_yaml(json_str) + yml_str = template_format.convert_json_to_yaml(json_str) yield (json_str, yml_str, f.name) @@ -91,8 +91,8 @@ Mappings: {} Resources: {} Outputs: {} ''' - tpl1 = format.parse_to_template(yaml1) - tpl2 = format.parse_to_template(yaml2) + tpl1 = template_format.parse(yaml1) + tpl2 = template_format.parse(yaml2) self.assertEqual(tpl1, tpl2) @@ -107,7 +107,7 @@ class JsonYamlResolvedCompareTest(unittest.TestCase): self.path = os.path.dirname(os.path.realpath(__file__)).\ replace('heat/tests', 'templates') f = open("%s/%s" % (self.path, file_name)) - t = format.parse_to_template(f.read()) + t = template_format.parse(f.read()) f.close() return t @@ -126,8 +126,8 @@ class JsonYamlResolvedCompareTest(unittest.TestCase): def compare_stacks(self, json_file, yaml_file, parameters): t1 = self.load_template(json_file) - format.default_for_missing(t1, 'AWSTemplateFormatVersion', - format.CFN_VERSIONS) + template_format.default_for_missing(t1, 'AWSTemplateFormatVersion', + template_format.CFN_VERSIONS) del(t1[u'AWSTemplateFormatVersion']) t2 = self.load_template(yaml_file) diff --git a/heat/tests/test_user.py b/heat/tests/test_user.py index e6ca0851..69ca793b 100644 --- a/heat/tests/test_user.py +++ b/heat/tests/test_user.py @@ -27,7 +27,7 @@ from nose.plugins.attrib import attr from heat.common import context from heat.common import exception from heat.common import config -from heat.engine import format +from heat.common import template_format from heat.engine import parser from heat.engine.resources import user from heat.tests import fakes @@ -51,7 +51,7 @@ class UserTest(unittest.TestCase): self.path = os.path.dirname(os.path.realpath(__file__)).\ replace('heat/tests', 'templates') f = open("%s/Rails_Single_Instance.template" % self.path) - t = format.parse_to_template(f.read()) + t = template_format.parse(f.read()) f.close() return t diff --git a/heat/tests/test_validate.py b/heat/tests/test_validate.py index 6cde6729..280d2c09 100644 --- a/heat/tests/test_validate.py +++ b/heat/tests/test_validate.py @@ -20,7 +20,7 @@ import json from nose.plugins.attrib import attr from heat.tests.v1_1 import fakes -from heat.engine import format +from heat.common import template_format from heat.engine.resources import instance as instances from heat.engine import service import heat.db as db_api @@ -220,7 +220,7 @@ class validateTest(unittest.TestCase): print "volumeTest teardown complete" def test_validate_volumeattach_valid(self): - t = format.parse_to_template(test_template_volumeattach % 'vdq') + t = template_format.parse(test_template_volumeattach % 'vdq') stack = parser.Stack(None, 'test_stack', parser.Template(t)) self.m.StubOutWithMock(db_api, 'resource_get_by_name_and_stack') @@ -232,7 +232,7 @@ class validateTest(unittest.TestCase): self.assertTrue(volumeattach.validate() is None) def test_validate_volumeattach_invalid(self): - t = format.parse_to_template(test_template_volumeattach % 'sda') + t = template_format.parse(test_template_volumeattach % 'sda') stack = parser.Stack(None, 'test_stack', parser.Template(t)) self.m.StubOutWithMock(db_api, 'resource_get_by_name_and_stack') @@ -244,7 +244,7 @@ class validateTest(unittest.TestCase): self.assertTrue(volumeattach.validate()) def test_validate_ref_valid(self): - t = format.parse_to_template(test_template_ref % 'WikiDatabase') + t = template_format.parse(test_template_ref % 'WikiDatabase') self.m.StubOutWithMock(instances.Instance, 'nova') instances.Instance.nova().AndReturn(self.fc) @@ -257,7 +257,7 @@ class validateTest(unittest.TestCase): self.assertEqual(res['Description'], 'test.') def test_validate_ref_invalid(self): - t = format.parse_to_template(test_template_ref % 'WikiDatabasez') + t = template_format.parse(test_template_ref % 'WikiDatabasez') self.m.StubOutWithMock(instances.Instance, 'nova') instances.Instance.nova().AndReturn(self.fc) @@ -269,7 +269,7 @@ class validateTest(unittest.TestCase): self.assertNotEqual(res['Description'], 'Successfully validated') def test_validate_findinmap_valid(self): - t = format.parse_to_template(test_template_findinmap_valid) + t = template_format.parse(test_template_findinmap_valid) self.m.StubOutWithMock(instances.Instance, 'nova') instances.Instance.nova().AndReturn(self.fc) @@ -281,7 +281,7 @@ class validateTest(unittest.TestCase): self.assertEqual(res['Description'], 'test.') def test_validate_findinmap_invalid(self): - t = format.parse_to_template(test_template_findinmap_invalid) + t = template_format.parse(test_template_findinmap_invalid) self.m.StubOutWithMock(instances.Instance, 'nova') instances.Instance.nova().AndReturn(self.fc) diff --git a/heat/tests/test_volume.py b/heat/tests/test_volume.py index 1f388866..75a84795 100644 --- a/heat/tests/test_volume.py +++ b/heat/tests/test_volume.py @@ -25,7 +25,7 @@ import unittest from nose.plugins.attrib import attr from heat.common import context -from heat.engine import format +from heat.common import template_format from heat.engine import parser from heat.engine.resources import volume as vol from heat.tests.v1_1 import fakes @@ -54,7 +54,7 @@ class VolumeTest(unittest.TestCase): self.path = os.path.dirname(os.path.realpath(__file__)).\ replace('heat/tests', 'templates') f = open("%s/WordPress_2_Instances_With_EBS.template" % self.path) - t = format.parse_to_template(f.read()) + t = template_format.parse(f.read()) f.close() return t diff --git a/heat/tests/test_waitcondition.py b/heat/tests/test_waitcondition.py index 59699696..df651211 100644 --- a/heat/tests/test_waitcondition.py +++ b/heat/tests/test_waitcondition.py @@ -27,7 +27,7 @@ from nose.plugins.attrib import attr from heat.tests import fakes import heat.db as db_api -from heat.engine import format +from heat.common import template_format from heat.engine import parser from heat.engine.resources import wait_condition as wc from heat.common import context @@ -88,7 +88,7 @@ class WaitConditionTest(unittest.TestCase): def test_post_success_to_handle(self): - t = format.parse_to_template(test_template_waitcondition) + t = template_format.parse(test_template_waitcondition) stack = self.create_stack('test_stack', t, {}) wc.WaitCondition._create_timeout().AndReturn(eventlet.Timeout(5)) @@ -120,7 +120,7 @@ class WaitConditionTest(unittest.TestCase): def test_timeout(self): - t = format.parse_to_template(test_template_waitcondition) + t = template_format.parse(test_template_waitcondition) stack = self.create_stack('test_stack', t, {}) tmo = eventlet.Timeout(6) @@ -166,7 +166,7 @@ class WaitConditionHandleTest(unittest.TestCase): self.m.UnsetStubs() def create_stack(self, stack_name='test_stack2', params={}): - temp = format.parse_to_template(test_template_waitcondition) + temp = template_format.parse(test_template_waitcondition) template = parser.Template(temp) parameters = parser.Parameters(stack_name, template, params) stack = parser.Stack(context.get_admin_context(), stack_name, diff --git a/tools/cfn-json2yaml b/tools/cfn-json2yaml index d816d826..fd855956 100755 --- a/tools/cfn-json2yaml +++ b/tools/cfn-json2yaml @@ -19,7 +19,7 @@ import os import yaml import json import re -from heat.engine import format +from heat.common import template_format def main(): path = sys.argv[1] @@ -32,7 +32,7 @@ def main(): def convert_file(path): f = open(path, 'r') - print format.convert_json_to_yaml(f.read()) + print template_format.convert_json_to_yaml(f.read()) def convert_directory(dirpath): for path in os.listdir(dirpath): @@ -42,7 +42,7 @@ def convert_directory(dirpath): print 'Writing to %s' % yamlpath f = open(os.path.join(dirpath, path), 'r') out = open(os.path.join(dirpath, yamlpath), 'w') - yml = format.convert_json_to_yaml(f.read()) + yml = template_format.convert_json_to_yaml(f.read()) out.write(yml) out.close() -- 2.45.2