def _generate_hot_from_tosca(self, vnfd_dict, dev_attrs): parsed_params = {} if 'param_values' in dev_attrs and dev_attrs['param_values'] != "": try: parsed_params = yaml.load(dev_attrs['param_values']) except Exception as e: LOG.debug("Params not Well Formed: %s", str(e)) raise vnfm.ParamYAMLNotWellFormed(error_msg_details=str(e)) toscautils.updateimports(vnfd_dict) if 'substitution_mappings' in str(vnfd_dict): toscautils.check_for_substitution_mappings(vnfd_dict, parsed_params) try: tosca = tosca_template.ToscaTemplate(parsed_params=parsed_params, a_file=False, yaml_dict_tpl=vnfd_dict) except Exception as e: LOG.debug("tosca-parser error: %s", str(e)) raise vnfm.ToscaParserFailed(error_msg_details=str(e)) metadata = toscautils.get_vdu_metadata(tosca) monitoring_dict = toscautils.get_vdu_monitoring(tosca) mgmt_ports = toscautils.get_mgmt_ports(tosca) res_tpl = toscautils.get_resources_dict(tosca, self.STACK_FLAVOR_EXTRA) toscautils.post_process_template(tosca) try: translator = tosca_translator.TOSCATranslator(tosca, parsed_params) heat_template_yaml = translator.translate() except Exception as e: LOG.debug("heat-translator error: %s", str(e)) raise vnfm.HeatTranslatorFailed(error_msg_details=str(e)) heat_template_yaml = toscautils.post_process_heat_template( heat_template_yaml, mgmt_ports, metadata, res_tpl, self.unsupported_props) self.heat_template_yaml = heat_template_yaml self.monitoring_dict = monitoring_dict self.metadata = metadata
def generate_hot_from_tosca(vnfd_dict): parsed_params = {} if ('param_values' in dev_attrs and dev_attrs['param_values'] != ""): try: parsed_params = yaml.load(dev_attrs['param_values']) except Exception as e: LOG.debug("Params not Well Formed: %s", str(e)) raise vnfm.ParamYAMLNotWellFormed( error_msg_details=str(e)) toscautils.updateimports(vnfd_dict) try: tosca = tosca_template.ToscaTemplate( parsed_params=parsed_params, a_file=False, yaml_dict_tpl=vnfd_dict) except Exception as e: LOG.debug("tosca-parser error: %s", str(e)) raise vnfm.ToscaParserFailed(error_msg_details=str(e)) monitoring_dict = toscautils.get_vdu_monitoring(tosca) mgmt_ports = toscautils.get_mgmt_ports(tosca) res_tpl = toscautils.get_resources_dict(tosca, self.STACK_FLAVOR_EXTRA) toscautils.post_process_template(tosca) try: translator = tosca_translator.TOSCATranslator(tosca, parsed_params) heat_template_yaml = translator.translate() except Exception as e: LOG.debug("heat-translator error: %s", str(e)) raise vnfm.HeatTranslatorFailed(error_msg_details=str(e)) heat_template_yaml = toscautils.post_process_heat_template( heat_template_yaml, mgmt_ports, res_tpl, unsupported_res_prop) return heat_template_yaml, monitoring_dict
def generate_hot_from_tosca(vnfd_dict): parsed_params = {} if ('param_values' in dev_attrs and dev_attrs['param_values'] != ""): try: parsed_params = yaml.load(dev_attrs['param_values']) except Exception as e: LOG.debug("Params not Well Formed: %s", str(e)) raise vnfm.ParamYAMLNotWellFormed( error_msg_details=str(e)) toscautils.updateimports(vnfd_dict) try: tosca = ToscaTemplate(parsed_params=parsed_params, a_file=False, yaml_dict_tpl=vnfd_dict) except Exception as e: LOG.debug("tosca-parser error: %s", str(e)) raise vnfm.ToscaParserFailed(error_msg_details=str(e)) monitoring_dict = toscautils.get_vdu_monitoring(tosca) mgmt_ports = toscautils.get_mgmt_ports(tosca) res_tpl = toscautils.get_resources_dict(tosca, STACK_FLAVOR_EXTRA) toscautils.post_process_template(tosca) try: translator = TOSCATranslator(tosca, parsed_params) heat_template_yaml = translator.translate() except Exception as e: LOG.debug("heat-translator error: %s", str(e)) raise vnfm.HeatTranslatorFailed(error_msg_details=str(e)) heat_template_yaml = toscautils.post_process_heat_template( heat_template_yaml, mgmt_ports, res_tpl, unsupported_res_prop) return heat_template_yaml, monitoring_dict