'Factory function for quota Resource.
This routine returns a resource instance of the appropriate type
according to system configuration.
If QUOTAS.track_quota_usage is True, and there is a model mapping for
the current resource, this function will return an instance of
AccountedResource; otherwise an instance of CountableResource.'

def _create_resource_instance(self, resource_name, plural_name):

    if ((not cfg.CONF.QUOTAS.track_quota_usage) or (resource_name not in self._tracked_resource_mappings)):
        LOG.info(_LI('Creating    instance    of    CountableResource    for    resource:%s'), resource_name)
        return resource.CountableResource(resource_name, resource._count_resource, ('quota_%s' % resource_name))
    else:
        LOG.info(_LI('Creating    instance    of    TrackedResource    for    resource:%s'), resource_name)
        return resource.TrackedResource(resource_name, self._tracked_resource_mappings[resource_name], ('quota_%s' % resource_name))
