Allow to_primitive to ignore datetimes

In preparation for having nova.db.api not return any sqlalchemy objects.
nova.db.api will return only primitives, except for datetime.datetime
objects.

Uses functools.partial to make code DRYING

Partially implements bp db-api-cleanup

Change-Id: I9980d8c4e20b05bbe734cf90ac209e4e7e89befb
Merge "Allow to_primitive to ignore datetimes"