def user_id(openid):
    """generate user_id from openid"""
    import re
    ESGF_OPENID_REXP = 'https://(.*)/esgf-idp/openid/(.*)'
    user_id = None
    mo = re.match(ESGF_OPENID_REXP, openid)
    try:
        hostname = mo.group(1)
        username = mo.group(2)
        user_id = '%s_%s' % (username, hostname)
    except:
        raise Exception('unsupported openid')
    return user_id
