The count is performed in 2 parts
- A function which builds a list of all nested stacks
by recursively calling stack_get_all_by_owner_id
- A query which counts resources which belong to the list
of stacks
Considering this will be the basis for fixing bug #1455589 then this
approach is appropriate for backporting to stable/kilo, but master would
ideally replace this soon with a new Stack attribute that stores the
calculated resource count.
Partial-Bug: #1455589
Change-Id: Ifa2e5609fd9a6853e20037e94a5e16696bb378ee