mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-21 18:03:54 +03:00
Added support so a deployed service can "ignore unused but assigned"
state. That is, UDS now can enforce the check to be ignored.
This commit is contained in:
parent
76c822b015
commit
dc640fd400
@ -69,7 +69,10 @@ class ServicesPools(ModelHandler):
|
||||
'actions': ActionsCalendars
|
||||
}
|
||||
|
||||
save_fields = ['name', 'short_name', 'comments', 'tags', 'service_id', 'osmanager_id', 'image_id', 'servicesPoolGroup_id', 'initial_srvs', 'cache_l1_srvs', 'cache_l2_srvs', 'max_srvs', 'show_transports', 'allow_users_remove']
|
||||
save_fields = ['name', 'short_name', 'comments', 'tags', 'service_id',
|
||||
'osmanager_id', 'image_id', 'servicesPoolGroup_id', 'initial_srvs',
|
||||
'cache_l1_srvs', 'cache_l2_srvs', 'max_srvs', 'show_transports',
|
||||
'allow_users_remove', 'ignores_unused']
|
||||
remove_fields = ['osmanager_id', 'service_id']
|
||||
|
||||
table_title = _('Service Pools')
|
||||
@ -88,7 +91,6 @@ class ServicesPools(ModelHandler):
|
||||
|
||||
custom_methods = [('setFallbackAccess', True), ('actionsList', True)]
|
||||
|
||||
|
||||
def item_as_dict(self, item):
|
||||
# if item does not have an associated service, hide it (the case, for example, for a removed service)
|
||||
# Access from dict will raise an exception, and item will be skipped
|
||||
@ -132,6 +134,7 @@ class ServicesPools(ModelHandler):
|
||||
'restrained': item.isRestrained(),
|
||||
'show_transports': item.show_transports,
|
||||
'allow_users_remove': item.allow_users_remove,
|
||||
'ignores_unused': item.ignores_unused,
|
||||
'fallbackAccess': item.fallbackAccess,
|
||||
'permission': permissions.getEffectivePermission(self._user, item),
|
||||
'info': Services.serviceInfo(item.service),
|
||||
@ -167,13 +170,37 @@ class ServicesPools(ModelHandler):
|
||||
'type': gui.InputField.CHOICE_TYPE,
|
||||
'rdonly': True,
|
||||
'order': 101,
|
||||
}, {
|
||||
'name': 'show_transports',
|
||||
'value': True,
|
||||
'label': ugettext('Show transports'),
|
||||
'tooltip': ugettext('If active, alternative transports for user will be shown'),
|
||||
'type': gui.InputField.CHECKBOX_TYPE,
|
||||
'order': 110,
|
||||
'tab': ugettext('Advanced'),
|
||||
}, {
|
||||
'name': 'allow_users_remove',
|
||||
'value': False,
|
||||
'label': ugettext('Allow removal by users'),
|
||||
'tooltip': ugettext('If active, the user will be allowed to remove the service "manually". Be care with this, because the user will have the "poser" to delete it\'s own service'),
|
||||
'type': gui.InputField.CHECKBOX_TYPE,
|
||||
'order': 111,
|
||||
'tab': ugettext('Advanced'),
|
||||
}, {
|
||||
'name': 'ignores_unused',
|
||||
'value': False,
|
||||
'label': ugettext('Ignores unused'),
|
||||
'tooltip': ugettext('If active, UDS will not try to detect and remove assigned but not used user services.'),
|
||||
'type': gui.InputField.CHECKBOX_TYPE,
|
||||
'order': 112,
|
||||
'tab': ugettext('Advanced'),
|
||||
}, {
|
||||
'name': 'image_id',
|
||||
'values': [gui.choiceImage(-1, '--------', DEFAULT_THUMB_BASE64)] + gui.sortedChoices([gui.choiceImage(v.uuid, v.name, v.thumb64) for v in Image.objects.all()]),
|
||||
'label': ugettext('Associated Image'),
|
||||
'tooltip': ugettext('Image assocciated with this service'),
|
||||
'type': gui.InputField.IMAGECHOICE_TYPE,
|
||||
'order': 102,
|
||||
'order': 120,
|
||||
'tab': ugettext('Display'),
|
||||
}, {
|
||||
'name': 'servicesPoolGroup_id',
|
||||
@ -181,7 +208,7 @@ class ServicesPools(ModelHandler):
|
||||
'label': ugettext('Pool group'),
|
||||
'tooltip': ugettext('Pool group for this pool (for pool clasify on display)'),
|
||||
'type': gui.InputField.IMAGECHOICE_TYPE,
|
||||
'order': 103,
|
||||
'order': 121,
|
||||
'tab': ugettext('Display'),
|
||||
}, {
|
||||
'name': 'initial_srvs',
|
||||
@ -190,7 +217,7 @@ class ServicesPools(ModelHandler):
|
||||
'label': ugettext('Initial available services'),
|
||||
'tooltip': ugettext('Services created initially for this service pool'),
|
||||
'type': gui.InputField.NUMERIC_TYPE,
|
||||
'order': 110,
|
||||
'order': 130,
|
||||
'tab': ugettext('Availability'),
|
||||
}, {
|
||||
'name': 'cache_l1_srvs',
|
||||
@ -199,7 +226,7 @@ class ServicesPools(ModelHandler):
|
||||
'label': ugettext('Services to keep in cache'),
|
||||
'tooltip': ugettext('Services kept in cache for improved user service assignation'),
|
||||
'type': gui.InputField.NUMERIC_TYPE,
|
||||
'order': 111,
|
||||
'order': 131,
|
||||
'tab': ugettext('Availability'),
|
||||
}, {
|
||||
'name': 'cache_l2_srvs',
|
||||
@ -208,7 +235,7 @@ class ServicesPools(ModelHandler):
|
||||
'label': ugettext('Services to keep in L2 cache'),
|
||||
'tooltip': ugettext('Services kept in cache of level2 for improved service generation'),
|
||||
'type': gui.InputField.NUMERIC_TYPE,
|
||||
'order': 112,
|
||||
'order': 132,
|
||||
'tab': ugettext('Availability'),
|
||||
}, {
|
||||
'name': 'max_srvs',
|
||||
@ -217,22 +244,8 @@ class ServicesPools(ModelHandler):
|
||||
'label': ugettext('Maximum number of services to provide'),
|
||||
'tooltip': ugettext('Maximum number of service (assigned and L1 cache) that can be created for this service'),
|
||||
'type': gui.InputField.NUMERIC_TYPE,
|
||||
'order': 113,
|
||||
'order': 133,
|
||||
'tab': ugettext('Availability'),
|
||||
}, {
|
||||
'name': 'show_transports',
|
||||
'value': True,
|
||||
'label': ugettext('Show transports'),
|
||||
'tooltip': ugettext('If active, alternative transports for user will be shown'),
|
||||
'type': gui.InputField.CHECKBOX_TYPE,
|
||||
'order': 120,
|
||||
}, {
|
||||
'name': 'allow_users_remove',
|
||||
'value': False,
|
||||
'label': ugettext('Allow removal by users'),
|
||||
'tooltip': ugettext('If active, the user will be allowed to remove the service "manually". Be care with this, because the user will have the "poser" to delete it\'s own service'),
|
||||
'type': gui.InputField.CHECKBOX_TYPE,
|
||||
'order': 121,
|
||||
}]:
|
||||
self.addField(g, f)
|
||||
|
||||
|
@ -55,8 +55,8 @@ class AssignedAndUnused(Job):
|
||||
def run(self):
|
||||
since_state = getSqlDatetime() - timedelta(seconds=self.frecuency)
|
||||
for ds in DeployedService.objects.all():
|
||||
# Skips checking deployed services in maintenance mode
|
||||
if ds.isInMaintenance() is True:
|
||||
# Skips checking deployed services in maintenance mode or ignores assigned and unused
|
||||
if ds.isInMaintenance() is True or ds.ignores_unused:
|
||||
continue
|
||||
# If do not needs os manager, this is
|
||||
if ds.osmanager is not None:
|
||||
|
@ -0,0 +1,20 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.9 on 2017-11-29 09:28
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('uds', '0024_auto_20171025_1405'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='deployedservice',
|
||||
name='ignores_unused',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
@ -62,11 +62,11 @@ import logging
|
||||
import pickle
|
||||
import six
|
||||
|
||||
__updated__ = '2017-10-25'
|
||||
|
||||
__updated__ = '2017-11-29'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class DeployedService(UUIDModel, TaggingMixin):
|
||||
'''
|
||||
@ -84,6 +84,7 @@ class DeployedService(UUIDModel, TaggingMixin):
|
||||
state_date = models.DateTimeField(default=NEVER)
|
||||
show_transports = models.BooleanField(default=True)
|
||||
allow_users_remove = models.BooleanField(default=False)
|
||||
ignores_unused = models.BooleanField(default=False)
|
||||
image = models.ForeignKey(Image, null=True, blank=True, related_name='deployedServices', on_delete=models.SET_NULL)
|
||||
|
||||
servicesPoolGroup = models.ForeignKey(ServicesPoolGroup, null=True, blank=True, related_name='servicesPools', on_delete=models.SET_NULL)
|
||||
@ -93,14 +94,12 @@ class DeployedService(UUIDModel, TaggingMixin):
|
||||
fallbackAccess = models.CharField(default=states.action.ALLOW, max_length=8)
|
||||
actionsCalendars = models.ManyToManyField(Calendar, related_name='actionsSP', through='CalendarAction')
|
||||
|
||||
|
||||
initial_srvs = models.PositiveIntegerField(default=0)
|
||||
cache_l1_srvs = models.PositiveIntegerField(default=0)
|
||||
cache_l2_srvs = models.PositiveIntegerField(default=0)
|
||||
max_srvs = models.PositiveIntegerField(default=0)
|
||||
current_pub_revision = models.PositiveIntegerField(default=1)
|
||||
|
||||
|
||||
# Meta service related
|
||||
meta_pools = models.ManyToManyField('self', symmetrical=False)
|
||||
|
||||
@ -218,7 +217,6 @@ class DeployedService(UUIDModel, TaggingMixin):
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def isAccessAllowed(self, chkDateTime=None):
|
||||
'''
|
||||
Checks if the access for a service pool is allowed or not (based esclusively on associated calendars)
|
||||
@ -265,7 +263,6 @@ class DeployedService(UUIDModel, TaggingMixin):
|
||||
|
||||
return int((deadLine - chkDateTime).total_seconds())
|
||||
|
||||
|
||||
def storeValue(self, name, value):
|
||||
'''
|
||||
Stores a value inside custom storage
|
||||
|
@ -55,8 +55,7 @@ from uds.models.Util import getSqlDatetime
|
||||
|
||||
import logging
|
||||
|
||||
__updated__ = '2017-10-26'
|
||||
|
||||
__updated__ = '2017-11-29'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -506,5 +505,6 @@ class UserService(UUIDModel):
|
||||
|
||||
logger.debug('Deleted user service {0}'.format(toDelete))
|
||||
|
||||
|
||||
# Connects a pre deletion signal to Authenticator
|
||||
signals.pre_delete.connect(UserService.beforeDelete, sender=UserService)
|
||||
|
Loading…
x
Reference in New Issue
Block a user