Fix ToscaPolicies overwrites scheduler_hints
ToscaPlicies.handle_properties overwrites if scheduler_hints exists. This patch changes it to use 'update' method to add new key and value. Change-Id: I6062980eaa3c392a48c878518d2d61425eceb86f Story: #2004963 Task: #29403
This commit is contained in:
parent
b36f9515e9
commit
d21c0ffffa
|
@ -35,6 +35,11 @@ class ToscaPoicyTest(TestCase):
|
||||||
toscacompute = ToscaCompute(nodetemplate)
|
toscacompute = ToscaCompute(nodetemplate)
|
||||||
toscacompute.handle_properties()
|
toscacompute.handle_properties()
|
||||||
|
|
||||||
|
# adding a property to test that
|
||||||
|
# ToscaPolicies.handle_properties does not overwrite this.
|
||||||
|
toscacompute.properties['scheduler_hints'] = {
|
||||||
|
'target_cell': 'cell0'}
|
||||||
|
|
||||||
policy = Policy(policy_name, tpl, targets,
|
policy = Policy(policy_name, tpl, targets,
|
||||||
"node_templates")
|
"node_templates")
|
||||||
toscapolicy = ToscaPolicies(policy)
|
toscapolicy = ToscaPolicies(policy)
|
||||||
|
@ -73,7 +78,8 @@ class ToscaPoicyTest(TestCase):
|
||||||
'scheduler_hints': {
|
'scheduler_hints': {
|
||||||
'group': {
|
'group': {
|
||||||
'get_resource':
|
'get_resource':
|
||||||
'my_compute_placement_policy'}},
|
'my_compute_placement_policy'},
|
||||||
|
'target_cell': 'cell0'},
|
||||||
'user_data_format': 'SOFTWARE_CONFIG'}
|
'user_data_format': 'SOFTWARE_CONFIG'}
|
||||||
self._tosca_policy_test(
|
self._tosca_policy_test(
|
||||||
tpl_snippet,
|
tpl_snippet,
|
||||||
|
|
|
@ -38,5 +38,7 @@ class ToscaPolicies(HotResource):
|
||||||
self.properties["policies"] = [group_policy]
|
self.properties["policies"] = [group_policy]
|
||||||
for resource in resources:
|
for resource in resources:
|
||||||
if resource.name in self.policy.targets:
|
if resource.name in self.policy.targets:
|
||||||
resource.properties["scheduler_hints"] = {
|
if not resource.properties.get("scheduler_hints"):
|
||||||
"group": {"get_resource": self.name}}
|
resource.properties["scheduler_hints"] = {}
|
||||||
|
resource.properties["scheduler_hints"].update(
|
||||||
|
{"group": {"get_resource": self.name}})
|
||||||
|
|
Loading…
Reference in New Issue