Properly handle snatting for external gateways

Previously, snatting for netowrks with external gateways had to be
handled by manually setting:
 * public_interface = ''
 * force_snat_range = snat_range
Whereas networks with a gateway managed by nova needed:
 * public_interface = eth0
 * force_snat_range = None or ['0.0.0.0/0']

In order to support both simultaneously, we calcualate whether the
gateway is external, and use the force_snat_range and skip interface
if it is an external gateway. Otherwise, we use the setting for public
interface and 0.0.0.0/0. This allows external and internal gateways
to co-exist.

Partially-implements blueprint better-support-for-multiple-networks

Change-Id: Id5ec66946c3a82841a6dd2d019404e822cdafe64
Fix _parse_datetime in simple tenant usage extension

_parse_datetime in os-simple-tenant-usage incorrectly attempts
to parse the datetime string even when it is None. As a result
a 400 BadRequest is returned. This has the overall effect of making
the start and end datetime parameters compulsory when they are meant
to be optional.

Note that this restores the behavior where start/end are optional which is
in contradiction to the API docs, but is the long standing API behaviour.
This was an API change which was accidentally applied in commit
I8e0e870727d687da165c809ffb7a4456bff81122 as part of some nova internal
changes but not picked up by the unitests

Change-Id: I00427379dc7aa39770f9a16ff026addb6e311735
Closes-Bug: 1300972
Improve logging when python-guestfs/libguestfs isn't working

Bumped from debug to warn level, as most often refers to
missing python-guestfs package or other libguestfs misconfiguration,
and the fallback path is usually not desired.

Closes-bug: 1240339
Change-Id: I5d90a3ea109e79fe17221c001f94d49d599048ba
Add a retry_on_deadlock to reservations_expire

Now that we have an index for the reservations_expire query, we
have uncovered a race with quota usage updates due to the foreign
key on the table, so just retry if there is a deadlock. This is
a fix to unblock the gate while we try to remove the deadlocks
completely.

Change-Id: I1993c3bd1f81facf1d98a4e29f9e8df4858a7d66
Partial-bug: #1350466
Merge "Fix _parse_datetime in simple tenant usage extension"
Merge "Properly handle snatting for external gateways"
Merge "Improve logging when python-guestfs/libguestfs isn't working"