'Given a string representation of a resource class -- e.g. "DISK_GB"
or "IRON_SILVER" -- return the integer code for the resource class. For
standard resource classes, this integer code will match the list of
resource classes on the fields.ResourceClass field type. Other custom
resource classes will cause a DB lookup into the resource_classes
table, however the results of these DB lookups are cached since the
lookups are so frequent.
:param rc_str: The string representation of the resource class to look
up a numeric identifier for.
:returns integer identifier for the resource class, or None, if no such
resource class was found in the list of standard resource
classes or the resource_classes database table.
:raises `exception.ResourceClassNotFound` if rc_str cannot be found in
either the standard classes or the DB.'

def id_from_string(self, rc_str):

    if (rc_str in fields.ResourceClass.STANDARD):
        return fields.ResourceClass.STANDARD.index(rc_str)
    with lockutils.lock(_LOCKNAME):
        if (rc_str in self.id_cache):
            return self.id_cache[rc_str]
        _refresh_from_db(self.ctx, self)
        if (rc_str in self.id_cache):
            return self.id_cache[rc_str]
        raise exception.ResourceClassNotFound(resource_class=rc_str)
