def _thread(request): partitions = [] message = None success = True result = [] # Determine different partitions for obj in request.options: partitions.append(obj['object'].split('@')[-1]) for partition in set(partitions): self._check_error(request, partition) # Remove user quota for obj in request.options: (unicode_user, partition) = obj['object'].split('@') user = unicode_user.encode('utf-8') failed = tools.setquota(partition, user, '0', '0', '0', '0') if failed: result.append({'id': obj['object'], 'success': False}) success = False else: result.append({'id': obj['object'], 'success': True}) if success: message = _('Successfully removed quota settings') return {'result': result, 'message': message, 'success': success}
def _thread(request): message = None success = True result = [] partition = request.options['partitionDevice'] unicode_user = request.options['user'] user = unicode_user.encode('utf-8') size_soft = request.options['sizeLimitSoft'] size_hard = request.options['sizeLimitHard'] file_soft = request.options['fileLimitSoft'] file_hard = request.options['fileLimitHard'] self._check_error(request, partition) failed = tools.setquota(partition, user, tools.byte2block(size_soft), tools.byte2block(size_hard), file_soft, file_hard) if failed: MODULE.error('Failed to modify quota settings for user %s ' 'on partition %s' % (user, partition)) message = _('Failed to modify quota settings for user %s on ' 'partition %s') % (user, partition) request.status = MODULE_ERR self.finished(request.id, None, message) message = _('Successfully set quota settings') return {'result': result, 'message': message, 'success': success}
def _thread(request): partition = request.options['partitionDevice'] user = request.options['user'] if isinstance(user, unicode): user = user.encode('utf-8') size_soft = request.options['sizeLimitSoft'] size_hard = request.options['sizeLimitHard'] file_soft = request.options['fileLimitSoft'] file_hard = request.options['fileLimitHard'] self._check_error(request, partition) if tools.setquota(partition, user, tools.byte2block(size_soft), tools.byte2block(size_hard), file_soft, file_hard): raise UMC_Error(_('Failed to modify quota settings for user %(user)s on partition %(partition)s.') % {'user': user, 'partition': partition}) return {'objects': [], 'success': True}
def _thread(request): partitions = [] success = True objects = [] # Determine different partitions for obj in request.options: partitions.append(obj['object'].split('@')[-1]) for partition in set(partitions): self._check_error(request, partition) # Remove user quota for obj in request.options: (unicode_user, partition) = obj['object'].split('@', 1) user = unicode_user.encode('utf-8') if tools.setquota(partition, user, 0, 0, 0, 0): objects.append({'id': obj['object'], 'success': False}) success = False else: objects.append({'id': obj['object'], 'success': True}) return {'objects': objects, 'success': success}