def _put(userhost, user): """Release a system account to user credential server. :param userhost: (`server`, `port`) of the user credential server. :type userhost: :class:`tuple` :param user: The name of acquired user. :type user: :class:`str` :raises: Various :class:`Exception` if the user cannot be released. """ client = UserHostClient(userhost[0], userhost[1]) if not client.release(user): raise RuntimeError('Could not release system account.')
def _acquire(userhost, expires): """Acquire a free account from user credential server. :param userhost: (`server`, `port`) of the user credential server. :type userhost: :class:`tuple` :param expires: Seconds for this user to expire. :type expires: :class:`int` :return: The acquired user account name. :raises: Various :class:`Exception` if the user cannot be acquired. """ client = UserHostClient(userhost[0], userhost[1]) ret = client.acquire(expires) if ret is None: raise RuntimeError('System account exhausted.') return ret