def add_account(account, type, email, session=None): """ Add an account with the given account name and type. :param account: the name of the new account. :param type: the type of the new account. :param email: The Email address associated with the account. :param session: the database session in use. """ vo = account.vo if not vo_exists(vo=vo, session=session): raise exception.VONotFound('VO {} not found'.format(vo)) # Reserve the name 'super_root' for multi_vo admins if account.external == 'super_root': if not (vo == 'def' and config_get_bool( 'common', 'multi_vo', raise_exception=False, default=False)): raise exception.UnsupportedAccountName( 'The name "%s" cannot be used.' % account.external) new_account = models.Account(account=account, account_type=type, email=email, status=AccountStatus.ACTIVE) try: new_account.save(session=session) except IntegrityError: raise exception.Duplicate('Account ID \'%s\' already exists!' % account) # Create the account counters for this account rucio.core.account_counter.create_counters_for_new_account(account=account, session=session)
def update_vo(vo, parameters, session=None): """ Update VO properties (email, description). :param vo: The VO to update. :param parameters: A dictionary with the new properties. :param session: The db session in use. """ if not config_get_bool('common', 'multi_vo', raise_exception=False, default=False): raise exception.UnsupportedOperation('VO operations cannot be performed in single VO mode.') try: query = session.query(models.VO).filter_by(vo=vo).one() except NoResultFound: raise exception.VONotFound('VO {} not found'.format(vo)) param = {} for key in parameters: if key in ['email', 'description']: param[key] = parameters[key] query.update(param)