mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-11 05:17:55 +03:00
* Fixed Properties to be unique for every user service, not globally
* Minor adjunst to StuckCleaner
This commit is contained in:
parent
531c6d983d
commit
44e6a3b50c
@ -144,16 +144,13 @@ class Config(object):
|
||||
'''
|
||||
logger.debug('Saving config {0}.{1} as {2}'.format(self._section.name(), self._key, value))
|
||||
try:
|
||||
if dbConfig.objects.filter(section=self._section.name(), key=self._key).update(value=value, crypt=self._crypt, long=self._longText, field_type=self._type) == 0: # @UndefinedVariable
|
||||
raise Exception() # Do not exists, create a new one
|
||||
obj, _ = dbConfig.objects.get_or_create(section=self._section.name(), key=self._key) # @UndefinedVariable
|
||||
obj.value, obj.crypt, obj.long, obj.field_type = value, self._crypt, self._longText, self._type
|
||||
obj.save()
|
||||
except Exception:
|
||||
logger.exception('Exception 2')
|
||||
try:
|
||||
dbConfig.objects.create(section=self._section.name(), key=self._key, value=value, crypt=self._crypt, long=self._longText, field_type=self._type) # @UndefinedVariable
|
||||
except Exception:
|
||||
logger.exception('Exception')
|
||||
# Probably a migration issue, just ignore it
|
||||
logger.info("Could not save configuration key {0}.{1}".format(self._section.name(), self._key))
|
||||
logger.exception('Exception')
|
||||
# Probably a migration issue, just ignore it
|
||||
logger.info("Could not save configuration key {0}.{1}".format(self._section.name(), self._key))
|
||||
|
||||
class _Section(object):
|
||||
def __init__(self, sectionName):
|
||||
|
@ -41,7 +41,7 @@ import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
MAX_STUCK_TIME = 3600 * 24 * 7 # At most 7 days "Stuck", not configurable (there is no need to)
|
||||
MAX_STUCK_TIME = 3600 * 24 * 2 # At most 2 days "Stuck", not configurable (there is no need to)
|
||||
|
||||
|
||||
class StuckCleaner(Job):
|
||||
@ -49,8 +49,8 @@ class StuckCleaner(Job):
|
||||
Kaputen Cleaner is very similar to Hanged Cleaner, at start, almost a copy
|
||||
We keep it in a new place to "control" more specific thins
|
||||
'''
|
||||
frecuency = MAX_STUCK_TIME / 2
|
||||
friendly_name = 'Stuck States checker'
|
||||
frecuency = 3600 * 24 # Executes Once a day
|
||||
friendly_name = 'Stuck States cleaner'
|
||||
|
||||
def __init__(self, environment):
|
||||
super(StuckCleaner, self).__init__(environment)
|
||||
|
@ -15,7 +15,7 @@ class Migration(migrations.Migration):
|
||||
name='UserServiceProperty',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('name', models.CharField(unique=True, max_length=128, db_index=True)),
|
||||
('name', models.CharField(max_length=128, db_index=True)),
|
||||
('value', models.TextField(default='')),
|
||||
('user_service', models.ForeignKey(related_name='properties', to='uds.UserService')),
|
||||
],
|
||||
@ -24,4 +24,8 @@ class Migration(migrations.Migration):
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='userserviceproperty',
|
||||
unique_together=set([('name', 'user_service')]),
|
||||
),
|
||||
]
|
||||
|
@ -35,7 +35,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
__updated__ = '2014-11-24'
|
||||
__updated__ = '2014-11-25'
|
||||
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
@ -54,7 +54,7 @@ class UserServiceProperty(models.Model):
|
||||
Properties for User Service.
|
||||
The value field is a Text field, so we can put whatever we want in it
|
||||
'''
|
||||
name = models.CharField(max_length=128, db_index=True, unique=True)
|
||||
name = models.CharField(max_length=128, db_index=True)
|
||||
value = models.TextField(default='')
|
||||
user_service = models.ForeignKey(UserService, on_delete=models.CASCADE, related_name='properties')
|
||||
|
||||
@ -63,6 +63,7 @@ class UserServiceProperty(models.Model):
|
||||
Meta class to declare default order and unique multiple field index
|
||||
'''
|
||||
db_table = 'uds__user_service_property'
|
||||
unique_together = (('name', 'user_service'),)
|
||||
app_label = 'uds'
|
||||
|
||||
def __str__(self):
|
||||
|
Loading…
Reference in New Issue
Block a user