# Path: tools/convert_heat_nic_config_to_ansible_j2.py
# MIN_VIABLE_MTU_HEADER = (
#     "{% set mtu_list = [ctlplane_mtu] %}\n"
#     "{% for network in role_networks %}\n"
#     "{{ mtu_list.append(lookup('vars', networks_lower[network] ~ '_mtu')) }}\n"
#     "{%- endfor %}\n"
#     "{% set min_viable_mtu = mtu_list | max %}\n"
# )
# DUAL_MIN_VIABLE_MTU_HEADER = (
#     "{% set mtu_ctlplane_list = [ctlplane_mtu] %}\n"
#     "{% set mtu_dataplane_list = [] %}\n"
#     "{% for network in role_networks %}\n"
#     "{# This block resolves the minimum viable MTU for interfaces connected to #}\n"  # noqa
#     "{# the dataplane network(s), which start by Tenant, and also bonds #}\n"
#     "{# and bridges that carry multiple VLANs. Each VLAN may have different MTU. #}\n"  # noqa
#     "{# The bridge, bond or interface must have an MTU to allow the VLAN with the #}\n"  # noqa
#     "{# largest MTU. #}\n"
#     "{% if network.startswith('Tenant') %}\n"
#     "{{ mtu_dataplane_list.append(lookup('vars', networks_lower[network] ~ '_mtu')) }}\n"  # noqa
#     "{# This block resolves the minimum viable MTU for interfaces connected to #}\n"  # noqa
#     "{# the control plane network(s) (don't start by Tenant), and also bonds #}\n"  # noqa
#     "{# and bridges that carry multiple VLANs. Each VLAN may have different MTU. #}\n"  # noqa
#     "{# The bridge, bond or interface must have an MTU to allow the VLAN with the #}\n"  # noqa
#     "{# largest MTU. #}\n"
#     "{% else %}\n"
#     "{{ mtu_ctlplane_list.append(lookup('vars', networks_lower[network] ~ '_mtu')) }}\n"  # noqa
#     "{%- endif %}\n"
#     "{%- endfor %}\n"
#     "{% set min_viable_mtu_ctlplane = mtu_ctlplane_list | max %}\n"
#     "{% set min_viable_mtu_dataplane = mtu_dataplane_list | max %}\n"
# )
# UNSUPPORTED_HEAT_INTRINSIC_FUNCTIONS = {
#     'get_file', 'get_resource', 'digest', 'repeat', 'resource_facade',
#     'str_replace', 'str_replace_strict', 'str_split', 'map_merge',
#     'map_replace', 'yaql', 'equals', 'if', 'not', 'and', 'or', 'filter',
#     'make_url', 'contains'
# }
# QUOTE_FIX = '%_fix_quote_%'
# DBL_QUOTE_FIX = '%_double_fix_quote_%'
# def parse_opts(argv):
#     def represent_ordered_dict(self, data):
#     def construct_mapping(self, node):
#     def __init__(self, stack_env, networks_file):
#     def unwrap_j2_var(x):
#     def strip_j2_comment(x):
#     def normalize_complex(self, old):
#     def to_j2_var(x):
#     def quote_fix(x):
#     def create_param_to_var_map(self, networks_file):
#     def convert_get_param(self, old):
#     def convert_get_attr(self, old):
#     def convert_list_join(self, list_join_attrs):
#     def convert_list_concat(self, list_concat_attrs):
#     def convert_list_concat_unique(self, list_concat_unique_attrs):
#     def convert_unsupported(old, fn):
#     def recursive_convert(self, old):
#     def convert_template(self, template):
# def write_j2_template(j2_template, j2_config, mtu_header, j2_header):
# def validate_files(opts, template, networks_file, j2_template):
# def get_stack_environment(stack_name):
# def main():
# class TemplateDumper(yaml.SafeDumper):
# class TemplateLoader(yaml.SafeLoader):
# class ConvertToAnsibleJ2(object):


import os
import tempfile
import yaml
from oslotest import base
from tools import convert_heat_nic_config_to_ansible_j2 as converter
            self.assertEqual(self.fake_param_to_var_map[key],
                             param_to_var_map[key])

    def test_convert_get_param(self):
        for k, v in self.fake_param_to_var_map.items():
            old = {'get_param': k}
            new = self.convert.convert_get_param(old)
            self.assertEqual(v, new)

        for k, v in self.fake_stack_env['parameter_defaults'].items():
            old = {'get_param': k}
            new = self.convert.convert_get_param(old)
            if isinstance(v, str):
                self.assertTrue(v in new)
                self.assertTrue(new.startswith(converter.QUOTE_FIX + v))
            elif isinstance(v, (bool, int, list, dict)):
                self.assertEqual(v, new)

    def test_convert_get_param_unable_param_not_defined(self):
        old = {'get_param': 'UNKNOWN_PARAM'}
        new = self.convert.convert_get_param(old)
        self.assertEqual(converter.QUOTE_FIX
                         + ('NEED MANUAL CONVERSION: {\'get_param\': '
                           '\'UNKNOWN_PARAM\'}') + converter.QUOTE_FIX, new)

    def test_convert_get_param_comlex_data_struct_not_supported(self):
        old = {'get_param': ['COMPLEX', 'DATA']}
        new = self.convert.convert_get_param(old)
        self.assertEqual(converter.QUOTE_FIX
                         + ('NEED MANUAL CONVERSION: {\'get_param\': '

# Path: tools/convert_heat_nic_config_to_ansible_j2.py
# MIN_VIABLE_MTU_HEADER = (
#     "{% set mtu_list = [ctlplane_mtu] %}\n"
#     "{% for network in role_networks %}\n"
#     "{{ mtu_list.append(lookup('vars', networks_lower[network] ~ '_mtu')) }}\n"
#     "{%- endfor %}\n"
#     "{% set min_viable_mtu = mtu_list | max %}\n"
# )
# DUAL_MIN_VIABLE_MTU_HEADER = (
#     "{% set mtu_ctlplane_list = [ctlplane_mtu] %}\n"
#     "{% set mtu_dataplane_list = [] %}\n"
#     "{% for network in role_networks %}\n"
#     "{# This block resolves the minimum viable MTU for interfaces connected to #}\n"  # noqa
#     "{# the dataplane network(s), which start by Tenant, and also bonds #}\n"
#     "{# and bridges that carry multiple VLANs. Each VLAN may have different MTU. #}\n"  # noqa
#     "{# The bridge, bond or interface must have an MTU to allow the VLAN with the #}\n"  # noqa
#     "{# largest MTU. #}\n"
#     "{% if network.startswith('Tenant') %}\n"
#     "{{ mtu_dataplane_list.append(lookup('vars', networks_lower[network] ~ '_mtu')) }}\n"  # noqa
#     "{# This block resolves the minimum viable MTU for interfaces connected to #}\n"  # noqa
#     "{# the control plane network(s) (don't start by Tenant), and also bonds #}\n"  # noqa
#     "{# and bridges that carry multiple VLANs. Each VLAN may have different MTU. #}\n"  # noqa
#     "{# The bridge, bond or interface must have an MTU to allow the VLAN with the #}\n"  # noqa
#     "{# largest MTU. #}\n"
#     "{% else %}\n"
#     "{{ mtu_ctlplane_list.append(lookup('vars', networks_lower[network] ~ '_mtu')) }}\n"  # noqa
#     "{%- endif %}\n"
#     "{%- endfor %}\n"
#     "{% set min_viable_mtu_ctlplane = mtu_ctlplane_list | max %}\n"
#     "{% set min_viable_mtu_dataplane = mtu_dataplane_list | max %}\n"
# )
# UNSUPPORTED_HEAT_INTRINSIC_FUNCTIONS = {
#     'get_file', 'get_resource', 'digest', 'repeat', 'resource_facade',
#     'str_replace', 'str_replace_strict', 'str_split', 'map_merge',
#     'map_replace', 'yaql', 'equals', 'if', 'not', 'and', 'or', 'filter',
#     'make_url', 'contains'
# }
# QUOTE_FIX = '%_fix_quote_%'
# DBL_QUOTE_FIX = '%_double_fix_quote_%'
# def parse_opts(argv):
#     def represent_ordered_dict(self, data):
#     def construct_mapping(self, node):
#     def __init__(self, stack_env, networks_file):
#     def unwrap_j2_var(x):
#     def strip_j2_comment(x):
#     def normalize_complex(self, old):
#     def to_j2_var(x):
#     def quote_fix(x):
#     def create_param_to_var_map(self, networks_file):
#     def convert_get_param(self, old):
#     def convert_get_attr(self, old):
#     def convert_list_join(self, list_join_attrs):
#     def convert_list_concat(self, list_concat_attrs):
#     def convert_list_concat_unique(self, list_concat_unique_attrs):
#     def convert_unsupported(old, fn):
#     def recursive_convert(self, old):
#     def convert_template(self, template):
# def write_j2_template(j2_template, j2_config, mtu_header, j2_header):
# def validate_files(opts, template, networks_file, j2_template):
# def get_stack_environment(stack_name):
# def main():
# class TemplateDumper(yaml.SafeDumper):
# class TemplateLoader(yaml.SafeLoader):
# class ConvertToAnsibleJ2(object):


# Path: tools/tests/test_convert_heat_nic_config_to_ansible_j2.py
import os
import tempfile
import yaml
from oslotest import base
from tools import convert_heat_nic_config_to_ansible_j2 as converter

            self.assertEqual(self.fake_param_to_var_map[key],
                             param_to_var_map[key])

    def test_convert_get_param(self):
        for k, v in self.fake_param_to_var_map.items():
            old = {'get_param': k}
            new = self.convert.convert_get_param(old)
            self.assertEqual(v, new)

        for k, v in self.fake_stack_env['parameter_defaults'].items():
            old = {'get_param': k}
            new = self.convert.convert_get_param(old)
            if isinstance(v, str):
                self.assertTrue(v in new)
                self.assertTrue(new.startswith(converter.QUOTE_FIX + v))
            elif isinstance(v, (bool, int, list, dict)):
                self.assertEqual(v, new)

    def test_convert_get_param_unable_param_not_defined(self):
        old = {'get_param': 'UNKNOWN_PARAM'}
        new = self.convert.convert_get_param(old)
        self.assertEqual(converter.QUOTE_FIX
                         + ('NEED MANUAL CONVERSION: {\'get_param\': '
                           '\'UNKNOWN_PARAM\'}') + converter.QUOTE_FIX, new)

    def test_convert_get_param_comlex_data_struct_not_supported(self):
        old = {'get_param': ['COMPLEX', 'DATA']}
        new = self.convert.convert_get_param(old)
        self.assertEqual(converter.QUOTE_FIX
                         + ('NEED MANUAL CONVERSION: {\'get_param\': '

                            '[\'COMPLEX\', \'DATA\']}') + converter.QUOTE_FIX,