1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-22 13:34:04 +03:00

* Added minimun values for Service Pool form numeric fields

* Added support for key "minValue" for numeric ui fields
* Fixed cache updater to take into account those services pools that has
initial or l1 cache to 0
* Fixed old (legacy) uds actor logging
* Fixed index view for pools that do not have assigned services
*
This commit is contained in:
Adolfo Gómez García 2015-01-31 11:14:24 +01:00
parent e3e652d4e1
commit e1bbbece43
12 changed files with 53 additions and 27 deletions

View File

@ -145,6 +145,7 @@ class ServicesPools(ModelHandler):
}, {
'name': 'initial_srvs',
'value': '0',
'minValue': '0',
'label': ugettext('Initial available services'),
'tooltip': ugettext('Services created initially for this service pool'),
'type': gui.InputField.NUMERIC_TYPE,
@ -152,6 +153,7 @@ class ServicesPools(ModelHandler):
}, {
'name': 'cache_l1_srvs',
'value': '0',
'minValue': '0',
'label': ugettext('Services to keep in cache'),
'tooltip': ugettext('Services keeped in cache for improved user service assignation'),
'type': gui.InputField.NUMERIC_TYPE,
@ -159,6 +161,7 @@ class ServicesPools(ModelHandler):
}, {
'name': 'cache_l2_srvs',
'value': '0',
'minValue': '0',
'label': ugettext('Services to keep in L2 cache'),
'tooltip': ugettext('Services keeped in cache of level2 for improved service generation'),
'type': gui.InputField.NUMERIC_TYPE,
@ -166,6 +169,7 @@ class ServicesPools(ModelHandler):
}, {
'name': 'max_srvs',
'value': '0',
'minValue': '1',
'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,

View File

@ -47,7 +47,7 @@ import logging
logger = logging.getLogger(__name__)
__updated__ = '2015-01-27'
__updated__ = '2015-01-31'
# a few constants
@ -84,6 +84,7 @@ class BaseModelHandler(Handler):
'required': field.get('required', False),
'defvalue': field.get('value', ''),
'value': field.get('value', ''),
'minValue': field.get('minValue', '987654321'),
'label': field.get('label', ''),
'length': field.get('length', 128),
'multiline': field.get('multiline', 0),

View File

@ -356,6 +356,9 @@ class gui(object):
'''
def __init__(self, **options):
super(self.__class__, self).__init__(**options)
minValue = options.get('minValue', '987654321')
self._data['minValue'] = int(minValue)
self._type(gui.InputField.NUMERIC_TYPE)
def num(self):

View File

@ -76,7 +76,7 @@ class ServiceCacheUpdater(Job):
# First we get all deployed services that could need cache generation
DeployedService.objects.update()
# We start filtering out the deployed services that do not need caching at all.
whichNeedsCaching = DeployedService.objects.filter(Q(initial_srvs__gte=0) | Q(cache_l1_srvs__gte=0)).filter(max_srvs__gte=0, state=State.ACTIVE,
whichNeedsCaching = DeployedService.objects.filter(Q(initial_srvs__gte=0) | Q(cache_l1_srvs__gte=0)).filter(max_srvs__gt=0, state=State.ACTIVE,
service__provider__maintenance_mode=False)[:]
# We will get the one that proportionally needs more cache

View File

@ -120,7 +120,7 @@ class LinuxOsManager(osmanagers.OSManager):
except Exception:
logger.debug('Do not understand level {}'.format(level))
level = log.INFO
log.doLog(service, int(level), msg, origin)
log.doLog(service, level, msg, origin)
except Exception:
log.doLog(service, log.ERROR, "do not understand {0}".format(data), origin)

View File

@ -124,8 +124,9 @@ class WindowsOsManager(osmanagers.OSManager):
logger.debug('Do not understand level {}'.format(level))
level = log.INFO
log.doLog(service, int(level), msg, origin)
log.doLog(service, level, msg, origin)
except Exception:
logger.exception('LinuxOs Manager message log: ')
log.doLog(service, log.ERROR, "do not understand {0}".format(data), origin)
def process(self, service, msg, data, options):

View File

@ -143,7 +143,7 @@ gui.providers.link = (event) ->
text: gettext("Maintenance")
css: "disabled"
click: (val, value, btn, tbl, refreshFnc) ->
gui.promptModal gettext("Maintenance Mode"), (if val.maintenance_mode is gettext('Enabled') then gettext("Enter Maintenance Mode?") else gettext("Exit Maintenance Mode?")),
gui.promptModal gettext("Maintenance Mode"), (if val.maintenance_mode is false then gettext("Enter Maintenance Mode?") else gettext("Exit Maintenance Mode?")),
onYes: ->
gui.doLog 'Val: ', val
api.providers.maintenance val.id, (->
@ -162,7 +162,7 @@ gui.providers.link = (event) ->
$(btn).empty().append(gettext("Maintenance"))
return
$(btn).removeClass("disabled").addClass "btn3d-warning"
$(btn).empty().append('<div>' + (if val.maintenance_mode is gettext('Enabled') then gettext('Enter maintenance Mode') else gettext('Exit Maintenance Mode')) + '</div>')
$(btn).empty().append('<div>' + (if val.maintenance_mode is false then gettext('Enter maintenance Mode') else gettext('Exit Maintenance Mode')) + '</div>')
return
}
"delete"

View File

@ -39,11 +39,12 @@
$.each value, (undefined_, val) ->
newValue.push val.id
return
value = newValue
originalValues[f.name] = value # Store original value
html += api.templates.evaluate("tmpl_fld_" + f.gui.type,
value: value # If no value present, use default value
minValue: f.gui.minValue
values: f.gui.values
label: f.gui.label
length: f.gui.length

View File

@ -70,15 +70,20 @@
$(selector + " .selectpicker").selectpicker()
# Activate Touchspinner
tspn = $(selector + " input[type=numeric]:not([readonly])")
tspn.attr("type", "text")
tspn.TouchSpin
verticalbuttons: true
verticalupclass: 'glyphicon glyphicon-plus'
verticaldownclass: 'glyphicon glyphicon-minus'
min: -99999
max: 99999
decimals: 0
$.each $(selector + " input[type=numeric]:not([readonly])"), (index, tspn) ->
$tspn = $(tspn)
minVal = parseInt $tspn.attr("data-minval")
if minVal == 987654321
minVal = -999999
gui.doLog minVal
$tspn.attr("type", "text")
$tspn.TouchSpin
verticalbuttons: true
verticalupclass: 'glyphicon glyphicon-plus'
verticaldownclass: 'glyphicon glyphicon-minus'
min: minVal
max: 999999
decimals: 0
# TEST: cooler on mobile devices
$(selector + " .selectpicker").selectpicker "mobile" if /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)

View File

@ -1,6 +1,6 @@
{% extends "uds/admin/tmpl/fld/form-group.html" %}
{% block field %}
{% verbatim %}
<input type="{% endverbatim %}{% block type %}text{% endblock %}{% verbatim %}" class="form-control {{ css }}" name="{{ name }}" id="{{ name }}_field" placeholder="{{ tooltip }}" value="{{ value }}"{{# if readonly }} readonly{{/ if }} {{# if required }} required {{/ if }}>
<input type="{% endverbatim %}{% block type %}text{% endblock %}{% verbatim %}" class="form-control {{ css }}" name="{{ name }}" id="{{ name }}_field" placeholder="{{ tooltip }}" value="{{ value }}"{{# if readonly }} readonly{{/ if }} {{# if required }} required {{/ if }} data-minval="{{ minValue }}">
{% endverbatim %}
{% endblock %}

View File

@ -122,7 +122,12 @@ def index(request):
else:
imageId = 'x'
# Locate if user service has any already assigned user service for this
ads = UserServiceManager.manager().getExistingAssignationForUser(svr, request.user)
if ads is None:
in_use = False
else:
in_use = ads.in_use
services.append({'id': 'F' + svr.uuid,
'name': svr.name,
@ -130,7 +135,7 @@ def index(request):
'imageId': imageId,
'show_transports': svr.show_transports,
'maintenance': svr.service.provider.maintenance_mode,
'in_use': ads.in_use})
'in_use': in_use})
logger.debug('Services: {0}'.format(services))

View File

@ -57,21 +57,27 @@ def message_fnc(id_, message, data):
'''
ids = id_.split(",")[:5] # Limit ids received to five...
logger.debug("Called message for id_ {0}, message \"{1}\" and data \"{2}\"".format(ids, message, data))
# Fix: Log used to send "INFO", "DEBUG", .. as level instead of numeric
# Now, we use levels, so for "legacy" actors we can do logs correctly
if message == 'log':
try:
msg, level = data.split('\t')
logger.debug('Msg: {}, level: "{}"'.format(msg, level))
level = "{}".format(log.logLevelFromStr(level))
logger.debug('Level: "{}"'.format(level))
data = '\t'.join([msg, level])
except Exception:
logger.exception("Exception at log")
data = data.replace('\t', ' ') + '\t10000' # Other
res = ""
try:
services = UserService.objects.filter(unique_id__in=ids, state__in=[State.USABLE, State.PREPARING])
if services.count() == 0:
res = ""
else:
inUse = services[0].in_use
res = services[0].getInstance().osmanager().process(services[0], message, data)
services = UserService.objects.filter(unique_id__in=ids, state__in=[State.USABLE, State.PREPARING])
if services.count() > 0 and services[0].in_use != inUse: # If state changed, log it
type_ = inUse and 'logout' or 'login'
uniqueId = services[0].unique_id
serviceIp = services[0].getInstance().getIp()
username = data
log.useLog(type_, uniqueId, serviceIp, username)
res = services[0].getInstance().osmanager().process(services[0], message, data, None)
except Exception as e:
logger.error("Exception at message (client): {0}".format(e))
res = ""