Handle ibm_db_sa DBDuplicateEntry integrity errors

This patch adds duplicate entry integrity error handling for the
ibm_db_sa driver to the common sqlalchemy db session.

Closes-Bug: #1227321
Part of nova blueprint: db2-database

Change-Id: I2f0d3d660373e4f647615f121fed0da9442f8cd2
Allow filters to only run once per request if their data is static

Currently the filter_all() method of each scheduler filter is run
once for each resource in a request, but for many filters the data
doesn't change during a request.

For example the data used by the AZ filter is pretty static, and
doesn't filter any more hosts on successive runs. However it is
fairly expensive to run on a large system.

Only filters that are based on data that may change within a
request, for example resource consumption, need to be evaluated
for each resource.

This patch adds a new attribute that allows filters to declare that
they only need to be run once per request. The default behavior is
left so that a filter is evaluated once for each resource in a
request.

Port from nova: Ia668f16414da86441323c58b1bbef5f88c81b90c

Change-Id: Ic656f1aa6830ed9b93c232a2098318e498a7d59e
Implements bp once-per-request-filters
Merge "Allow filters to only run once per request if their data is static"
Merge "Handle ibm_db_sa DBDuplicateEntry integrity errors"