Merge "Fix heat translator bug due to nested_resource_name"
This commit is contained in:
commit
355c5b0842
@ -23,4 +23,4 @@ resources:
|
||||
network: net_mgmt
|
||||
port_security_enabled: false
|
||||
heat_template_version: 2013-05-23
|
||||
description: Tacker Scaling template
|
||||
description: Tacker Scaling template
|
||||
|
@ -22,4 +22,4 @@ resources:
|
||||
network: net_mgmt
|
||||
port_security_enabled: false
|
||||
heat_template_version: 2013-05-23
|
||||
description: Tacker Scaling template
|
||||
description: Tacker Scaling template
|
||||
|
@ -17,7 +17,6 @@ import codecs
|
||||
import json
|
||||
import mock
|
||||
import os
|
||||
import unittest
|
||||
import yaml
|
||||
|
||||
from tacker import context
|
||||
@ -393,7 +392,6 @@ class TestOpenStack(base.TestCase):
|
||||
input_params
|
||||
)
|
||||
|
||||
@unittest.skip("Skip and wait for releasing Heat Translator")
|
||||
def test_create_tosca_scale(self):
|
||||
self._test_assert_equal_for_tosca_templates(
|
||||
'tosca_scale.yaml',
|
||||
@ -435,7 +433,6 @@ class TestOpenStack(base.TestCase):
|
||||
is_monitor=False
|
||||
)
|
||||
|
||||
@unittest.skip("Skip and wait for releasing Heat Translator")
|
||||
def test_create_tosca_alarm_scale(self):
|
||||
self._test_assert_equal_for_tosca_templates(
|
||||
'tosca_alarm_scale.yaml',
|
||||
|
@ -19,6 +19,7 @@ import yaml
|
||||
|
||||
from collections import OrderedDict
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import uuidutils
|
||||
from tacker.common import log
|
||||
from tacker.common import utils
|
||||
from tacker.extensions import vnfm
|
||||
@ -668,6 +669,14 @@ def get_nested_resources_name(template):
|
||||
return nested_resource_name
|
||||
|
||||
|
||||
def get_sub_heat_tmpl_name(template):
|
||||
for policy in template.policies:
|
||||
if (policy.type_definition.is_derived_from(SCALING)):
|
||||
sub_heat_tmpl_name = policy.name + '_' + \
|
||||
uuidutils.generate_uuid() + '_res.yaml'
|
||||
return sub_heat_tmpl_name
|
||||
|
||||
|
||||
def update_nested_scaling_resources(nested_resources, mgmt_ports, metadata,
|
||||
res_tpl, unsupported_res_prop=None):
|
||||
nested_tpl = dict()
|
||||
@ -678,8 +687,9 @@ def update_nested_scaling_resources(nested_resources, mgmt_ports, metadata,
|
||||
yamlparser.simple_ordered_parse(nested_resources_yaml)
|
||||
if metadata:
|
||||
for vdu_name, metadata_dict in metadata['vdus'].items():
|
||||
nested_resources_dict['resources'][vdu_name]['properties']['metadata'] = \
|
||||
metadata_dict
|
||||
if nested_resources_dict['resources'].get(vdu_name):
|
||||
nested_resources_dict['resources'][vdu_name]['properties']['metadata'] = \
|
||||
metadata_dict
|
||||
add_resources_tpl(nested_resources_dict, res_tpl)
|
||||
for res in nested_resources_dict["resources"].values():
|
||||
if not res['type'] == HEAT_SOFTWARE_CONFIG:
|
||||
|
@ -281,20 +281,20 @@ class TOSCAToHOT(object):
|
||||
monitoring_dict = toscautils.get_vdu_monitoring(tosca)
|
||||
mgmt_ports = toscautils.get_mgmt_ports(tosca)
|
||||
nested_resource_name = toscautils.get_nested_resources_name(tosca)
|
||||
sub_heat_tmpl_name = toscautils.get_sub_heat_tmpl_name(tosca)
|
||||
res_tpl = toscautils.get_resources_dict(tosca,
|
||||
self.STACK_FLAVOR_EXTRA)
|
||||
toscautils.post_process_template(tosca)
|
||||
scaling_policy_names = toscautils.get_scaling_policy(tosca)
|
||||
try:
|
||||
translator = tosca_translator.TOSCATranslator(tosca,
|
||||
parsed_params)
|
||||
translator = tosca_translator.TOSCATranslator(tosca, parsed_params)
|
||||
heat_template_yaml = translator.translate()
|
||||
if nested_resource_name:
|
||||
sub_heat_template_yaml =\
|
||||
translator.translate_to_yaml_files_dict(
|
||||
nested_resource_name, True)
|
||||
translator.translate_to_yaml_files_dict(sub_heat_tmpl_name)
|
||||
nested_resource_yaml =\
|
||||
sub_heat_template_yaml[nested_resource_name]
|
||||
LOG.debug("nested_resource_yaml: %s", nested_resource_yaml)
|
||||
self.nested_resources[nested_resource_name] =\
|
||||
nested_resource_yaml
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user