
Previously running cfn-json2yaml would generate valid YAML, but the HOT file would not work. The key mappings it generates had 64 instead of '64'. Since 64 in YAML is a number and not a string, the template cannot find the key '64' as it is not a string value. Turns out this issue was caused by simply forgetting to explicitly re-add quotation marks after converting from a python object to YAML. In the conversion code (heat/common/template_format.py), the json string is first converted into a python object via yaml.load. Next the python object gets converted to yaml via yaml.dump. For example: u'__00015__order__32': u'F17-i386-cfntools' in the python object gets converted to __00015__order__32: F17-i386-cfntools in yaml. Crucially in YAML, all strings are not explicity quoted except for strings that contain only digits. For instance, numerical strings like '32' will automatically get quoted when using yaml.dump Normally this would be fine, but a subtle problem arises in the next line of code: yml = re.sub('__\d*__order__', '', yml) By removing all instances of the order substring in the yaml, previous alphanumeric strings become numeric-only strings. However, since this step comes after the call to yaml.dump, quotes are not explicity set anymore! so for example: __00015__order__32: F17-i386-cfntool becomes 32: F17-i386-cfntool Then in YAML, the key 32 is now interpreted as number 32 and not what we wanted, which is a string '32' So to help fix this issue, replace all numeric-only keys with quoted keys. For example: 32: F17-i386-cfntool becomes '32': F17-i386-cfntool This helps to fix the issue of not finding the numerical keys in the HOT yaml file. Change-Id: I37208679f0699d088a7ca632a409d8675cad72c4 Closes-Bug: #1286380 Closes-Bug: #1467029 Closes-Bug: #1467026
These templates are required by test_template_format and test_provider_template in situations where we don't want to use a minimal template snippet. Ideally we want to test the maximum possible syntax to prove the format conversion works. In general, tests should not depend on these templates, inline minimal template snippets are preferred.