'Find an image by name or id (user provided input).'

def find_image(self, name_or_id):

    with self.alternate_service_type('image', allowed_types=('image',)):
        if uuidutils.is_uuid_like(name_or_id):
            return self._get(('/v2/images/%s' % name_or_id), None)
        else:
            matches = self._list(('/v2/images?name=%s' % name_or_id), 'images')
            num_matches = len(matches)
            if (num_matches == 0):
                msg = ('No    %s    matching    %s.' % (self.resource_class.__name__, name_or_id))
                raise exceptions.NotFound(404, msg)
            elif (num_matches > 1):
                msg = (_("Multiple    %(class)s    matches    found    for    '%(name)s',    use    an    ID    to    be    more    specific.") % {'class': self.resource_class.__name__.lower(), 'name': name_or_id})
                raise exceptions.NoUniqueMatch(msg)
            else:
                matches[0].append_request_ids(matches.request_ids)
                return matches[0]
