This method is more complicated than it needs
to be, and it makes it difficult to target
fixes for it.
Furthermore, this method calls into
auto_schedule_routers, which duplicates some
of the DB calls already made in the above
mentioned method. This refactoring
is done in preparation of the performance
improvement.
Partial-bug: #1356121
Related-Bug: #1358636
Change-Id: I9a0cfa41a5f067949b964d39157def55c40bf9af