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
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)
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
"""
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)
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
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'
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__)
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):
# 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
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']
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
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
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)
import unittest
import json
-from heat.engine import format
+from heat.common import template_format
@attr(speed='slow')
# 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
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
# 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)
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
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
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
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
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
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
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
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,
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
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)
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)
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
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
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')
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
self.assertEqual(join(raw), 'foo bar\nbaz')
-mapping_template = format.parse_to_template('''{
+mapping_template = template_format.parse('''{
"Mappings" : {
"ValidMapping" : {
"TestKey" : { "TestValue" : "wibble" }
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
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
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
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
import yaml
from heat.common import context
-from heat.engine import format
+from heat.common import template_format
from heat.engine import parser
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'])
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)
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)
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
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)
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
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
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
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')
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')
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)
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)
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)
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)
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
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
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
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))
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)
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,
import yaml
import json
import re
-from heat.engine import format
+from heat.common import template_format
def main():
path = sys.argv[1]
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):
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()