@transactional_session
def add_account_identity(identity, type, account, email, default=False, password=None, session=None):
    '\n    Adds a membership association between identity and account.\n\n    :param identity: The identity key name. For example x509 DN, or a username.\n    :param type: The type of the authentication (x509, gss, userpass, ssh, saml).\n    :param account: The account name.\n    :param email: The Email address associated with the identity.\n    :param default: If True, the account should be used by default with the provided identity.\n    :param password: Password if type is userpass.\n    :param session: The database session in use.\n    '
    if (not account_exists(account, session=session)):
        raise exception.AccountNotFound(("Account '%s' does not exist." % account))
    id = session.query(models.Identity).filter_by(identity=identity, identity_type=type).first()
    if (id is None):
        add_identity(identity=identity, type=type, email=email, password=password, session=session)
        id = session.query(models.Identity).filter_by(identity=identity, identity_type=type).first()
    iaa = models.IdentityAccountAssociation(identity=id.identity, identity_type=id.identity_type, account=account)
    try:
        iaa.save(session=session)
    except IntegrityError:
        raise exception.Duplicate(("Identity pair '%s','%s' already exists!" % (identity, type)))
Adds a membership association between identity and account.

:param identity: The identity key name. For example x509 DN, or a username.
:param type: The type of the authentication (x509, gss, userpass, ssh, saml).
:param account: The account name.
:param email: The Email address associated with the identity.
:param default: If True, the account should be used by default with the provided identity.
:param password: Password if type is userpass.
:param session: The database session in use.
@transactional_session
def add_account_identity(identity, type, account, email, default=False, password=None, session=None):
    '\n    Adds a membership association between identity and account.\n\n    :param identity: The identity key name. For example x509 DN, or a username.\n    :param type: The type of the authentication (x509, gss, userpass, ssh, saml).\n    :param account: The account name.\n    :param email: The Email address associated with the identity.\n    :param default: If True, the account should be used by default with the provided identity.\n    :param password: Password if type is userpass.\n    :param session: The database session in use.\n    '
    if (not account_exists(account, session=session)):
        raise exception.AccountNotFound(("Account '%s' does not exist." % account))
    id = session.query(models.Identity).filter_by(identity=identity, identity_type=type).first()
    if (id is None):
        add_identity(identity=identity, type=type, email=email, password=password, session=session)
        id = session.query(models.Identity).filter_by(identity=identity, identity_type=type).first()
    iaa = models.IdentityAccountAssociation(identity=id.identity, identity_type=id.identity_type, account=account)
    try:
        iaa.save(session=session)
    except IntegrityError:
        raise exception.Duplicate(("Identity pair '%s','%s' already exists!" % (identity, type)))