diff --git a/server/src/uds/REST/methods/config.py b/server/src/uds/REST/methods/config.py index a0a44bd7c..8084f174d 100644 --- a/server/src/uds/REST/methods/config.py +++ b/server/src/uds/REST/methods/config.py @@ -60,7 +60,8 @@ class Config(Handler): 'value': cfg.get(), 'crypt': cfg.isCrypted(), 'longText': cfg.isLongText(), - 'type': cfg.getType() + 'type': cfg.getType(), + 'params': cfg.getParams() } logger.debug('Configuration: {0}'.format(res)) return res diff --git a/server/src/uds/core/util/Config.py b/server/src/uds/core/util/Config.py index 3b493e556..ae7552f54 100644 --- a/server/src/uds/core/util/Config.py +++ b/server/src/uds/core/util/Config.py @@ -47,6 +47,8 @@ CLUSTER_SECTION = 'Cluster' saveLater = [] getLater = [] +# For custom params (for choices mainly) +configParams = {} class Config(object): ''' @@ -58,10 +60,13 @@ class Config(object): LONGTEXT_FIELD = 1 NUMERIC_FIELD = 2 BOOLEAN_FIELD = 3 + CHOICE_FIELD = 4 # Choice fields must set its parameters on global "configParams" (better by calling ".setParams" method) class _Value(object): def __init__(self, section, key, default='', crypt=False, longText=False, **kwargs): + logger.debug('Var: {} {} KWARGS: {}'.format(section, key, kwargs)) self._type = kwargs.get('type', -1) + self._section = section self._key = key self._crypt = crypt @@ -90,7 +95,7 @@ class Config(object): self._data = readed.value self._crypt = [self._crypt, True][readed.crypt] # True has "higher" precedende than False self._longText = readed.long - if readed.field_type == -1 and self._type != -1: + if self._type != -1: # readed.field_type == -1 and readed.field_type = self._type readed.save() self._type = readed.field_type @@ -106,6 +111,9 @@ class Config(object): else: return self._data + def setParams(self, params): + configParams[self._section.name() + self._key] = params + def getInt(self, force=False): try: return int(self.get(force)) @@ -137,6 +145,9 @@ class Config(object): def getType(self): return self._type + def getParams(self): + return configParams.get(self._section.name() + self._key, None) + def set(self, value): if GlobalConfig.initDone is False: saveLater.append((self, value)) @@ -298,7 +309,7 @@ class GlobalConfig(object): CLUSTER_ELEGIBLE_MEMORYLOAD = Config.section(CLUSTER_SECTION).value('Migration Free Memory', '40', type=Config.NUMERIC_FIELD) # Gui vars - UDS_THEME = Config.section(GLOBAL_SECTION).value('UDS Theme', 'html5', type=Config.TEXT_FIELD) + UDS_THEME = Config.section(GLOBAL_SECTION).value('UDS Theme', 'html5', type=Config.CHOICE_FIELD) RELOAD_TIME = Config.section(GLOBAL_SECTION).value('Page reload Time', '300', type=Config.NUMERIC_FIELD) # This is used so templates can change "styles" from admin interface @@ -306,6 +317,20 @@ class GlobalConfig(object): initDone = False + @staticmethod + def initThemes(): + import os + themes = [] + try: + for d in os.listdir(os.path.join(os.path.dirname(uds.__file__), 'templates', 'uds')): + if d != 'admin': + themes.append(d) + except Exception as e: + pass + + GlobalConfig.UDS_THEME.setParams(themes) + + @staticmethod def initialize(): if GlobalConfig.initDone is False: @@ -326,6 +351,13 @@ class GlobalConfig(object): logger.debug('Saving delayed value: {}'.format(c)) c.set(v) saveLater[:] = [] + + # Process some global config parameters + # GlobalConfig.UDS_THEME.setParams(['html5', 'semantic']) + + # Search for themes & set them + GlobalConfig.initThemes() + except Exception: logger.debug('Config table do not exists!!!, maybe we are installing? :-)') diff --git a/server/src/uds/core/util/request.py b/server/src/uds/core/util/request.py index 12cc8aa4a..57cc7ab3d 100644 --- a/server/src/uds/core/util/request.py +++ b/server/src/uds/core/util/request.py @@ -39,7 +39,7 @@ from uds.models import User import threading import logging -__updated__ = '2016-04-22' +__updated__ = '2016-04-25' logger = logging.getLogger(__name__) @@ -89,7 +89,7 @@ class GlobalRequestMiddleware(object): ''' Obtains the IP of a Django Request, even behind a proxy - Returns the obtained IP, that is always be a valid ip address. + Returns the obtained IP, that always will be a valid ip address. ''' behind_proxy = GlobalConfig.BEHIND_PROXY.getBool(False) try: diff --git a/server/src/uds/services/OVirt/OVirtProvider.py b/server/src/uds/services/OVirt/OVirtProvider.py index 184547a8b..0afe54d5c 100644 --- a/server/src/uds/services/OVirt/OVirtProvider.py +++ b/server/src/uds/services/OVirt/OVirtProvider.py @@ -45,7 +45,7 @@ from .client import oVirtClient import logging -__updated__ = '2016-04-18' +__updated__ = '2016-04-25' logger = logging.getLogger(__name__) @@ -97,7 +97,7 @@ class Provider(ServiceProvider): username = gui.TextField(length=32, label=_('Username'), order=3, tooltip=_('User with valid privileges on oVirt, (use "user@domain" form)'), required=True, defvalue='admin@internal') password = gui.PasswordField(lenth=32, label=_('Password'), order=4, tooltip=_('Password of the user of oVirt'), required=True) - maxPreparingServices = gui.NumericField(length=3, label=_('Creation concurrency'), defvalue='10', minValue=1, maxValue=65536, order=50, tooltip=_('Maximum number of concurrently removing VMs'), required=True, tab=gui.ADVANCED_TAB) + maxPreparingServices = gui.NumericField(length=3, label=_('Creation concurrency'), defvalue='10', minValue=1, maxValue=65536, order=50, tooltip=_('Maximum number of concurrently creating VMs'), required=True, tab=gui.ADVANCED_TAB) maxRemovingServices = gui.NumericField(length=3, label=_('Removal concurrency'), defvalue='5', minValue=1, maxValue=65536, order=51, tooltip=_('Maximum number of concurrently removing VMs'), required=True, tab=gui.ADVANCED_TAB) timeout = gui.NumericField(length=3, label=_('Timeout'), defvalue='10', order=90, tooltip=_('Timeout in seconds of connection to oVirt'), required=True, tab=gui.ADVANCED_TAB) diff --git a/server/src/uds/services/OpenNebula/Provider.py b/server/src/uds/services/OpenNebula/Provider.py index f01e3dc01..c0fb57418 100644 --- a/server/src/uds/services/OpenNebula/Provider.py +++ b/server/src/uds/services/OpenNebula/Provider.py @@ -50,7 +50,7 @@ import six # Python bindings for OpenNebula import oca -__updated__ = '2016-04-18' +__updated__ = '2016-04-25' logger = logging.getLogger(__name__) @@ -101,7 +101,7 @@ class Provider(ServiceProvider): username = gui.TextField(length=32, label=_('Username'), order=4, tooltip=_('User with valid privileges on OpenNebula'), required=True, defvalue='oneadmin') password = gui.PasswordField(lenth=32, label=_('Password'), order=5, tooltip=_('Password of the user of OpenNebula'), required=True) - maxPreparingServices = gui.NumericField(length=3, label=_('Creation concurrency'), defvalue='10', minValue=1, maxValue=65536, order=50, tooltip=_('Maximum number of concurrently removing VMs'), required=True, tab=gui.ADVANCED_TAB) + maxPreparingServices = gui.NumericField(length=3, label=_('Creation concurrency'), defvalue='10', minValue=1, maxValue=65536, order=50, tooltip=_('Maximum number of concurrently creating VMs'), required=True, tab=gui.ADVANCED_TAB) maxRemovingServices = gui.NumericField(length=3, label=_('Removal concurrency'), defvalue='5', minValue=1, maxValue=65536, order=51, tooltip=_('Maximum number of concurrently removing VMs'), required=True, tab=gui.ADVANCED_TAB) timeout = gui.NumericField(length=3, label=_('Timeout'), defvalue='10', order=90, tooltip=_('Timeout in seconds of connection to OpenNebula'), required=True, tab=gui.ADVANCED_TAB) diff --git a/server/src/uds/services/OpenStack/Provider.py b/server/src/uds/services/OpenStack/Provider.py index e39f4711c..63556b885 100644 --- a/server/src/uds/services/OpenStack/Provider.py +++ b/server/src/uds/services/OpenStack/Provider.py @@ -44,7 +44,7 @@ from . import openStack import logging -__updated__ = '2016-04-18' +__updated__ = '2016-04-25' logger = logging.getLogger(__name__) @@ -105,7 +105,7 @@ class Provider(ServiceProvider): username = gui.TextField(length=64, label=_('Username'), order=9, tooltip=_('User with valid privileges on OpenStack'), required=True, defvalue='admin') password = gui.PasswordField(lenth=32, label=_('Password'), order=10, tooltip=_('Password of the user of OpenStack'), required=True) - maxPreparingServices = gui.NumericField(length=3, label=_('Creation concurrency'), defvalue='10', minValue=1, maxValue=65536, order=50, tooltip=_('Maximum number of concurrently removing VMs'), required=True, tab=gui.ADVANCED_TAB) + maxPreparingServices = gui.NumericField(length=3, label=_('Creation concurrency'), defvalue='10', minValue=1, maxValue=65536, order=50, tooltip=_('Maximum number of concurrently creating VMs'), required=True, tab=gui.ADVANCED_TAB) maxRemovingServices = gui.NumericField(length=3, label=_('Removal concurrency'), defvalue='5', minValue=1, maxValue=65536, order=51, tooltip=_('Maximum number of concurrently removing VMs'), required=True, tab=gui.ADVANCED_TAB) timeout = gui.NumericField(length=3, label=_('Timeout'), defvalue='10', minValue=1, maxValue=128, order=99, tooltip=_('Timeout in seconds of connection to OpenStack'), required=True, tab=gui.ADVANCED_TAB) diff --git a/server/src/uds/services/PhysicalMachines/IPMachinesService.py b/server/src/uds/services/PhysicalMachines/IPMachinesService.py index d67c10aa1..4f952eba9 100644 --- a/server/src/uds/services/PhysicalMachines/IPMachinesService.py +++ b/server/src/uds/services/PhysicalMachines/IPMachinesService.py @@ -48,7 +48,7 @@ class IPMachinesService(services.Service): ipList = gui.EditableList(label=_('List of IPS')) # Description of service - typeName = _('Physical machines accessed by ip') + typeName = _('Static IP machines service') typeType = 'IPMachinesService' typeDescription = _('This service provides access to POWERED-ON Machines by ip') iconFile = 'machine.png' diff --git a/server/src/uds/services/PhysicalMachines/ServiceProvider.py b/server/src/uds/services/PhysicalMachines/ServiceProvider.py index 5379a5815..37aa17cce 100644 --- a/server/src/uds/services/PhysicalMachines/ServiceProvider.py +++ b/server/src/uds/services/PhysicalMachines/ServiceProvider.py @@ -40,9 +40,9 @@ class PhysicalMachinesProvider(services.ServiceProvider): # What services do we offer? offers = [] - typeName = 'Physical Machines Provider' + typeName = 'Static IP Machines Provider' typeType = 'PhysicalMachinesServiceProvider' - typeDescription = 'Provides connection to Virtual Center Services' + typeDescription = 'Provides connection to machines by IP' iconFile = 'provider.png' from .IPMachinesService import IPMachinesService diff --git a/server/src/uds/services/Xen/XenProvider.py b/server/src/uds/services/Xen/XenProvider.py index a032a8def..cd813a5cd 100644 --- a/server/src/uds/services/Xen/XenProvider.py +++ b/server/src/uds/services/Xen/XenProvider.py @@ -48,7 +48,7 @@ import logging logger = logging.getLogger(__name__) -__updated__ = '2016-04-18' +__updated__ = '2016-04-25' CACHE_TIME_FOR_SERVER = 1800 @@ -99,7 +99,7 @@ class Provider(ServiceProvider): username = gui.TextField(length=32, label=_('Username'), order=2, tooltip=_('User with valid privileges on XenServer'), required=True, defvalue='root') password = gui.PasswordField(lenth=32, label=_('Password'), order=3, tooltip=_('Password of the user of XenServer'), required=True) - maxPreparingServices = gui.NumericField(length=3, label=_('Creation concurrency'), defvalue='10', minValue=1, maxValue=65536, order=50, tooltip=_('Maximum number of concurrently removing VMs'), required=True, tab=gui.ADVANCED_TAB) + maxPreparingServices = gui.NumericField(length=3, label=_('Creation concurrency'), defvalue='10', minValue=1, maxValue=65536, order=50, tooltip=_('Maximum number of concurrently creating VMs'), required=True, tab=gui.ADVANCED_TAB) maxRemovingServices = gui.NumericField(length=3, label=_('Removal concurrency'), defvalue='5', minValue=1, maxValue=65536, order=51, tooltip=_('Maximum number of concurrently removing VMs'), required=True, tab=gui.ADVANCED_TAB) macsRange = gui.TextField(length=36, label=_('Macs range'), defvalue='02:46:00:00:00:00-02:46:00:FF:FF:FF', order=90, rdonly=True, diff --git a/server/src/uds/static/adm/js/gui-d-config.coffee b/server/src/uds/static/adm/js/gui-d-config.coffee index 27132560c..4b3d5c06a 100644 --- a/server/src/uds/static/adm/js/gui-d-config.coffee +++ b/server/src/uds/static/adm/js/gui-d-config.coffee @@ -19,7 +19,6 @@ gui.configuration.link = -> val = if $element.attr('type') is 'checkbox' then (if $element.is(":checked") then "1" else "0") else $element.val() $element.attr "data-val", val - # Add handlers to buttons $("#form_config .button-undo").on "click", (event) -> fld = $(this).attr("data-fld") @@ -56,4 +55,4 @@ gui.configuration.link = -> ), gui.failRequestModalFnc return - return \ No newline at end of file + return diff --git a/server/src/uds/templates/uds/admin/index.html b/server/src/uds/templates/uds/admin/index.html index 36d4be29f..fefdd508d 100644 --- a/server/src/uds/templates/uds/admin/index.html +++ b/server/src/uds/templates/uds/admin/index.html @@ -189,6 +189,7 @@ {% js_template 'dashboard' %} {% js_template 'restricted' %} {% js_template 'providers' %} + {% js_template 'service-info' %} {% js_template 'authenticators' %} {% js_template 'osmanagers' %} {% js_template 'connectivity' %} diff --git a/server/src/uds/templates/uds/admin/tmpl/configuration.html b/server/src/uds/templates/uds/admin/tmpl/configuration.html index eee4afe2d..a1c16f1ae 100644 --- a/server/src/uds/templates/uds/admin/tmpl/configuration.html +++ b/server/src/uds/templates/uds/admin/tmpl/configuration.html @@ -47,13 +47,21 @@ {{# ifequals value.type 1 }} {{ else }} - {{# ifequals value.type 3 }} - - {{ else }} -
- -
- {{/ ifequals }} + {{# ifequals value.type 3 }} + + {{ else }} + {{# ifequals value.type 4 }} + + {{ else }} +
+ +
+ {{/ ifequals }} + {{/ ifequals }} {{/ ifequals }} {{/ if }} @@ -64,7 +72,7 @@ {{ unset_var "cfg_section" }} {{/ eachKey }} - +
@@ -73,4 +81,4 @@
-{% endverbatim %} \ No newline at end of file +{% endverbatim %} diff --git a/server/src/uds/templates/uds/semantic/login.html b/server/src/uds/templates/uds/semantic/login.html index a826ea34e..d7fb05c7f 100644 --- a/server/src/uds/templates/uds/semantic/login.html +++ b/server/src/uds/templates/uds/semantic/login.html @@ -60,76 +60,80 @@ {% endblock %} {% block body %} +
+
+
+ {% if form.errors %} +
+ + {% trans 'invalid credentials'|capfirst %} +
+ {% endif %} +
+ {% csrf_token %} + {% for hidden in form.hidden_fields %} + {{ hidden }} + {% endfor %} +