Problem:
If a nested stack has no resources, then we do not get
a "nested" link in the resource information returned by
our API.
Why?
In engine/api.py we have:
if (hasattr(resource, 'nested') and callable(resource.nested) and
resource.nested()):
res[rpc_api.RES_NESTED_STACK_ID] = dict(resource.nested().identifier())
The problem with this is the python definition of False, from the docs:
"instances of user-defined classes, if the class defines a __nonzero__()
or __len__() method, when that method returns the integer zero or bool
value False. [1]"
So if you have a stack with zero resources (len() returns 0), the
stack will be False :-O
Solution:
Use "if stack is not None:" instead of "if stack".
Change-Id: Ibdd1cb5dee6ce8e58f7d8f2586a495caded79134
Closes-bug: 1416917