'Helper method to create a resource provider with inventory'

def _create_resource_provider(self, inventory):

    ctxt = context.get_admin_context()
    rp_uuid = uuidutils.generate_uuid()
    rp = objects.ResourceProvider(context=ctxt, name=rp_uuid, uuid=rp_uuid)
    rp.create()
    inventory = objects.Inventory(context=ctxt, resource_provider=rp, **inventory)
    inventory.create()
    return rp
