make record_metering_data concurrency safe

Recording metering might happen in parallel, and if two sqlalchemy
session try to create a source, a user, a project or a resource at the
same time, one of them fail with a IntegrityError.

This patch ensure the record_metering_data sqlalchemy session always
have the needed source, user, project and a resource by creating missing
obj in an other sqlalchemy session.

Fixes bug: #1237671

Change-Id: Ie8761ce1615c3142ad6ad2a400537f465f3bbf0a
(cherry picked from commit dd62f9ce0d8d5abac0fb34b0520515b6c4566c1f)
Merge "make record_metering_data concurrency safe" into stable/havana