Merge "Trivial: Fix unnecessary redundant code"

This commit is contained in:
Zuul 2018-09-14 13:38:33 +00:00 committed by Gerrit Code Review
commit 82b0d26ed0
4 changed files with 50 additions and 3 deletions

View File

@ -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'

View File

@ -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:

View File

@ -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 ]

View File

@ -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/' \