Fix error getting a boolean capability property with value false
Change-Id: I559868a01bc2739d70a8ee56823da539d7f51431 Related-Bug: #1697856
This commit is contained in:
parent
f03e48d59b
commit
2b62122338
|
@ -443,7 +443,7 @@ class GetProperty(Function):
|
|||
props = cap.get_properties()
|
||||
if props and property_name in props.keys():
|
||||
property = props[property_name].value
|
||||
if not property and throw_errors:
|
||||
if property is None and throw_errors:
|
||||
ExceptionCollector.appendException(
|
||||
KeyError(_('Property "%(prop)s" was not found in '
|
||||
'capability "%(cap)s" of node template '
|
||||
|
@ -586,7 +586,8 @@ class GetProperty(Function):
|
|||
self._get_capability_property(target_node,
|
||||
self.args[1],
|
||||
self.args[2],
|
||||
False)):
|
||||
False)
|
||||
is not None):
|
||||
return target_node
|
||||
return self._find_host_containing_property(
|
||||
target_name)
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
tosca_definitions_version: tosca_simple_yaml_1_0
|
||||
|
||||
description: TOSCA test for boolean properties
|
||||
|
||||
node_types:
|
||||
|
||||
tosca.nodes.SoftwareComponentTest:
|
||||
derived_from: tosca.nodes.SoftwareComponent
|
||||
properties:
|
||||
some_prop:
|
||||
type: boolean
|
||||
|
||||
tosca.nodes.ComputeTest:
|
||||
derived_from: tosca.nodes.Compute
|
||||
capabilities:
|
||||
endpoint:
|
||||
type: tosca.capabilities.Endpoint
|
||||
|
||||
topology_template:
|
||||
|
||||
node_templates:
|
||||
|
||||
software:
|
||||
type: tosca.nodes.SoftwareComponentTest
|
||||
properties:
|
||||
some_prop: { get_property: [ HOST, endpoint, secure ] }
|
||||
requirements:
|
||||
- host: server
|
||||
|
||||
server:
|
||||
type: tosca.nodes.ComputeTest
|
||||
capabilities:
|
||||
endpoint:
|
||||
properties:
|
||||
network_name: PUBLIC
|
||||
secure: false
|
||||
|
|
@ -198,6 +198,16 @@ class IntrinsicFunctionsTest(TestCase):
|
|||
self.assertIsInstance(some_prop.value, functions.GetProperty)
|
||||
self.assertEqual('someval', some_prop.value.result())
|
||||
|
||||
def test_get_prop_cap_bool(self):
|
||||
tosca_tpl = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
"data/functions/test_get_prop_cap_bool.yaml")
|
||||
some_node = self._get_node('software',
|
||||
ToscaTemplate(tosca_tpl))
|
||||
some_prop = some_node.get_properties()['some_prop']
|
||||
self.assertIsInstance(some_prop.value, functions.GetProperty)
|
||||
self.assertEqual(False, some_prop.value.result())
|
||||
|
||||
|
||||
class GetAttributeTest(TestCase):
|
||||
|
||||
|
|
Loading…
Reference in New Issue