make record_metering_data concurrency safe
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

openstack/aodh,chungg/aodh,r-mibu/ceilometer,mathslinux/ceilometer,r-mibu/ceilometer,openstack/ceilometer,pkilambi/ceilometer,luogangyi/Ceilometer-oVirt,redhat-openstack/ceilometer,NeCTAR-RC/ceilometer,tanglei528/ceilometer,redhat-openstack/ceilometer,ityaptin/ceilometer,froyobin/ceilometer,sileht/aodh,chungg/aodh,pczerkas/aodh,fabian4/ceilometer,tanglei528/ceilometer,cernops/ceilometer,pczerkas/aodh,m1093782566/openstack_org_ceilometer,eayunstack/ceilometer,ityaptin/ceilometer,rackerlabs/instrumented-ceilometer,sileht/aodh,idegtiarov/ceilometer,MisterPup/Ceilometer-Juno-Extension,pkilambi/ceilometer,m1093782566/openstack_org_ceilometer,tanglei528/ceilometer,rackerlabs/instrumented-ceilometer,NeCTAR-RC/ceilometer,mathslinux/ceilometer,isyippee/ceilometer,openstack/ceilometer,Juniper/ceilometer,idegtiarov/ceilometer,Juniper/ceilometer,luogangyi/Ceilometer-oVirt,maestro-hybrid-cloud/ceilometer,rackerlabs/instrumented-ceilometer,MisterPup/Ceilometer-Juno-Extension,maestro-hybrid-cloud/ceilometer,openstack/aodh,isyippee/ceilometer,cernops/ceilometer,fabian4/ceilometer,froyobin/ceilometer,eayunstack/ceilometer,NeCTAR-RC/ceilometer