Fix broken policy translation
The current policy translation implementation is not working and missing a test that tests actual translation. Change-Id: I31f792000810678e6342e95ac9e9a26fa6ac1c61 Closes-Bug: 1552299
This commit is contained in:
parent
99c3bda42e
commit
0d284ea77a
|
@ -319,6 +319,9 @@ class HotResource(object):
|
|||
operations[operation.name] = operation
|
||||
|
||||
node_type = node.type_definition
|
||||
if isinstance(node_type, str) or \
|
||||
node_type.type == "tosca.policies.Placement":
|
||||
return operations
|
||||
|
||||
while True:
|
||||
type_operations = HotResource._get_interface_operations_from_type(
|
||||
|
@ -334,6 +337,9 @@ class HotResource(object):
|
|||
@staticmethod
|
||||
def _get_interface_operations_from_type(node_type, node, lifecycle_name):
|
||||
operations = {}
|
||||
if isinstance(node_type, str) or \
|
||||
node_type.type == "tosca.policies.Placement":
|
||||
return operations
|
||||
if node_type.interfaces and lifecycle_name in node_type.interfaces:
|
||||
for name, elems in node_type.interfaces[lifecycle_name].items():
|
||||
# ignore empty operations (only type)
|
||||
|
|
|
@ -1,20 +1,16 @@
|
|||
heat_template_version: 2013-05-23
|
||||
|
||||
description: >
|
||||
Template for deploying a single server with predefined properties.
|
||||
Template for deploying the nodes based on given policies.
|
||||
|
||||
parameters: {}
|
||||
|
||||
parameters:
|
||||
receiver_port:
|
||||
type: string
|
||||
description: Port to be used for receiving messages.
|
||||
default: 1
|
||||
resources:
|
||||
my_server:
|
||||
type: OS::Nova::Server
|
||||
properties:
|
||||
flavor: m1.medium
|
||||
image: rhel-6.5-test-image
|
||||
key_name: userkey
|
||||
scheduler_hints:
|
||||
group:
|
||||
get_resource: my_compute_placement_policy
|
||||
|
@ -25,4 +21,5 @@ resources:
|
|||
name: my_compute_placement_policy
|
||||
policies:
|
||||
- affinity
|
||||
outputs: {}
|
||||
|
||||
outputs: {}
|
|
@ -621,3 +621,13 @@ class ToscaHotTranslationTest(TestCase):
|
|||
params)
|
||||
self.assertEqual({}, diff, '<difference> : ' +
|
||||
json.dumps(diff, indent=4, separators=(', ', ': ')))
|
||||
|
||||
def test_hot_translate_policy(self):
|
||||
tosca_file = '../tests/data/tosca_policies.yaml'
|
||||
hot_file = '../tests/data/hot_output/hot_policies.yaml'
|
||||
params = {}
|
||||
diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
|
||||
hot_file,
|
||||
params)
|
||||
self.assertEqual({}, diff, '<difference> : ' +
|
||||
json.dumps(diff, indent=4, separators=(', ', ': ')))
|
||||
|
|
Loading…
Reference in New Issue