In rocky cycle, 'GET /allocation_candidates' started to be aware of
nested providers from microversion 1.29, namely, it can have multiple
allocations from multiple resource providers in the same tree in the
allocation requests.
To keep the behavior of microversion before 1.29, it added a filters
to exculde nested providers being unaware of the nested architecture.
However that function "_exclude_nested_providers()" is very heavy
and is executed even if there is no nested provider in the environment
when microversion < 1.29.
This patch changes it to skip it if there is no nested provider.
Since _exclude_nested_providers() should be done before limitting
the candidates, this patch also moves it from hander file to the
deeper layer.
This is manually backported from the placement repository:
commit 727fb88dccfe8461cc40ae53ca2d4e40fd2a9c3c
Change-Id: I4efdc65395e69a6d33fba927018d003cce26fa68
Closes-Bug: #1828937