diff --git a/translator/hot/translate_node_templates.py b/translator/hot/translate_node_templates.py index ac9837f6..1275deef 100644 --- a/translator/hot/translate_node_templates.py +++ b/translator/hot/translate_node_templates.py @@ -276,9 +276,7 @@ class TranslateNodeTemplates(object): if policy.is_derived_from('tosca.policies.Placement'): TOSCA_TO_HOT_TYPE[policy_type.type] = \ TOSCA_TO_HOT_TYPE['tosca.policies.Placement'] - if not policy.is_derived_from('tosca.policies.Monitoring') and \ - not policy.is_derived_from('tosca.policies.Scaling') and \ - policy_type.type not in TOSCA_TO_HOT_TYPE: + if policy_type.type not in TOSCA_TO_HOT_TYPE: raise UnsupportedTypeError(type=_('%s') % policy_type.type) elif policy_type.type == 'tosca.policies.Scaling.Cluster': self.hot_template_version = '2016-04-08' diff --git a/translator/tests/data/nfv/tacker_defs.yaml b/translator/tests/data/nfv/tacker_defs.yaml index f5fac057..60c04302 100644 --- a/translator/tests/data/nfv/tacker_defs.yaml +++ b/translator/tests/data/nfv/tacker_defs.yaml @@ -92,6 +92,9 @@ policy_types: If the policy is not strict, it is allowed to continue even if the nova-scheduler fails to assign hosts under the policy. + tosca.policies.tacker.ABC: + derived_from: tosca.policies.Root + tosca.policies.tacker.Failure: derived_from: tosca.policies.Root action: diff --git a/translator/tests/data/nfv/test_tosca_unsupported_policy_type.yaml b/translator/tests/data/nfv/test_tosca_unsupported_policy_type.yaml new file mode 100644 index 00000000..41b27ce0 --- /dev/null +++ b/translator/tests/data/nfv/test_tosca_unsupported_policy_type.yaml @@ -0,0 +1,32 @@ +tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0 + +description: > + Template for deploying the nodes based on given policies. + +imports: + - tacker_defs.yaml + - tacker_nfv_defs.yaml +topology_template: + node_templates: + my_server: + type: tosca.nodes.Compute + capabilities: + # Host container properties + host: + properties: + num_cpus: 2 + disk_size: 10 GB + mem_size: 512 MB + # Guest Operating System properties + os: + properties: + # host Operating System image properties + architecture: x86_64 + type: Linux + distribution: RHEL + version: 6.5 + policies: + - my_compute_abc_policy: + type: tosca.policies.tacker.ABC + description: Apply my ABC policy to my application's servers + targets: [ my_server ] diff --git a/translator/tests/test_tosca_hot_translation.py b/translator/tests/test_tosca_hot_translation.py index 1357a10d..b03d73f4 100644 --- a/translator/tests/test_tosca_hot_translation.py +++ b/translator/tests/test_tosca_hot_translation.py @@ -563,6 +563,20 @@ class ToscaHotTranslationTest(TestCase): .translate) self.assertEqual(expected_msg, err.__str__()) + def test_translate_unsupported_tosca_policy_type(self): + tosca_file = ('../tests/data/nfv/' + 'test_tosca_unsupported_policy_type.yaml') + tosca_tpl = os.path.normpath(os.path.join( + os.path.dirname(os.path.abspath(__file__)), tosca_file)) + params = {} + expected_msg = _('Type "tosca.policies.tacker.ABC" is valid TOSCA ' + 'type but translation support is not yet available.') + tosca = ToscaTemplate(tosca_tpl, params, True) + err = self.assertRaises(UnsupportedTypeError, + TOSCATranslator(tosca, params) + .translate) + self.assertEqual(expected_msg, err.__str__()) + def test_hot_translate_cluster_scaling_policy(self): tosca_file = '../tests/data/autoscaling/tosca_cluster_autoscaling.yaml' hot_file = '../tests/data/hot_output/autoscaling/' \