mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-13 13:17:54 +03:00
Added experimental features flag for turning on/off highly experimenal features not intended for production environments
This commit is contained in:
parent
52437afcf8
commit
92b4aadfbb
@ -42,6 +42,7 @@ from uds.core import services
|
||||
from uds.core.util import log
|
||||
from uds.core.util import permissions
|
||||
from uds.core.util.model import processUuid
|
||||
from uds.core.util.config import GlobalConfig
|
||||
from uds.core.environment import Environment
|
||||
from uds.core.ui.images import DEFAULT_THUMB_BASE64
|
||||
from uds.core.ui import gui
|
||||
@ -220,11 +221,10 @@ class Services(DetailHandler): # pylint: disable=too-many-public-methods
|
||||
{'name': {'title': _('Service name'), 'visible': True, 'type': 'iconType'}},
|
||||
{'comments': {'title': _('Comments')}},
|
||||
{'type_name': {'title': _('Type')}},
|
||||
{'proxy': {'title': _('Proxy')}},
|
||||
{'deployed_services_count': {'title': _('Services Pools'), 'type': 'numeric'}},
|
||||
{'user_services_count': {'title': _('User services'), 'type': 'numeric'}},
|
||||
{'tags': {'title': _('tags'), 'visible': False}},
|
||||
]
|
||||
] + ([{'proxy': {'title': _('Proxy')}}] if GlobalConfig.EXPERIMENTAL_FEATURES.getBool() else [])
|
||||
|
||||
def getTypes(self, parent: 'Provider', forType: typing.Optional[str]) -> typing.Iterable[typing.Dict[str, typing.Any]]:
|
||||
logger.debug('getTypes parameters: %s, %s', parent, forType)
|
||||
@ -260,16 +260,23 @@ class Services(DetailHandler): # pylint: disable=too-many-public-methods
|
||||
|
||||
service = serviceType(Environment.getTempEnv(), parentInstance) # Instantiate it so it has the opportunity to alter gui description based on parent
|
||||
localGui = self.addDefaultFields(service.guiDescription(service), ['name', 'comments', 'tags'])
|
||||
for field in [{
|
||||
'name': 'proxy_id',
|
||||
'values': [gui.choiceItem(-1, '')] + gui.sortedChoices([gui.choiceItem(v.uuid, v.name) for v in models.Proxy.objects.all()]),
|
||||
'label': _('Proxy'),
|
||||
'tooltip': _('Proxy for services behind a firewall'),
|
||||
'type': gui.InputField.CHOICE_TYPE,
|
||||
'tab': _('Advanced'),
|
||||
'order': 132,
|
||||
},]:
|
||||
self.addField(localGui, field)
|
||||
if GlobalConfig.EXPERIMENTAL_FEATURES.getBool():
|
||||
self.addField(localGui, {
|
||||
'name': 'proxy_id',
|
||||
'values': [gui.choiceItem(-1, '')] + gui.sortedChoices([gui.choiceItem(v.uuid, v.name) for v in models.Proxy.objects.all()]),
|
||||
'label': _('Proxy'),
|
||||
'tooltip': _('Proxy for services behind a firewall'),
|
||||
'type': gui.InputField.CHOICE_TYPE,
|
||||
'tab': _('Advanced'),
|
||||
'order': 132,
|
||||
})
|
||||
else:
|
||||
self.addField(localGui, {
|
||||
'name': 'proxy_id',
|
||||
'value': '-1',
|
||||
'type': gui.InputField.HIDDEN_TYPE,
|
||||
})
|
||||
|
||||
|
||||
return localGui
|
||||
|
||||
|
@ -45,7 +45,7 @@ def _requestActor(
|
||||
|
||||
proxy = userService.deployed_service.proxy
|
||||
try:
|
||||
if proxy is not None:
|
||||
if proxy:
|
||||
r = proxy.doProxyRequest(url=url, data=data, timeout=TIMEOUT)
|
||||
else:
|
||||
if data is None:
|
||||
|
@ -40,22 +40,17 @@ from uds.core.managers import cryptoManager
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
GLOBAL_SECTION: str = 'UDS'
|
||||
SECURITY_SECTION: str = 'Security'
|
||||
CLUSTER_SECTION: str = 'Cluster'
|
||||
|
||||
# For save when initialized
|
||||
SECURITY_SECTION: str = 'Security'
|
||||
# CLUSTER_SECTION: str = 'Cluster'
|
||||
|
||||
_saveLater = []
|
||||
_getLater = []
|
||||
|
||||
# For custom params (for choices mainly)
|
||||
_configParams = {}
|
||||
|
||||
|
||||
class Config:
|
||||
"""
|
||||
Keeps persistence configuration data
|
||||
"""
|
||||
|
||||
# Fields types, so inputs get more "beautiful"
|
||||
TEXT_FIELD: int = 0
|
||||
LONGTEXT_FIELD: int = 1
|
||||
@ -317,19 +312,19 @@ class GlobalConfig:
|
||||
# Clusters related vars
|
||||
|
||||
# Maximum desired CPU Load. If cpu is over this value, a migration of a service is "desirable"
|
||||
CLUSTER_MIGRATE_CPULOAD: Config.Value = Config.section(CLUSTER_SECTION).value('Migration CPU Load', '80', type=Config.NUMERIC_FIELD)
|
||||
# CLUSTER_MIGRATE_CPULOAD: Config.Value = Config.section(CLUSTER_SECTION).value('Migration CPU Load', '80', type=Config.NUMERIC_FIELD)
|
||||
# Maximum CPU Load for a node to be elegible for destination of a migration
|
||||
CLUSTER_ELEGIBLE_CPULOAD: Config.Value = Config.section(CLUSTER_SECTION).value('Destination CPU Load', '60', type=Config.NUMERIC_FIELD)
|
||||
# CLUSTER_ELEGIBLE_CPULOAD: Config.Value = Config.section(CLUSTER_SECTION).value('Destination CPU Load', '60', type=Config.NUMERIC_FIELD)
|
||||
# Minimum desired Memory free for a cluster node. If free memory (in %) is under this percentage,
|
||||
# a migration of a service inside this node is "desirable"
|
||||
CLUSTER_MIGRATE_MEMORYLOAD: Config.Value = Config.section(CLUSTER_SECTION).value('Migration Free Memory', '20', type=Config.NUMERIC_FIELD)
|
||||
# CLUSTER_MIGRATE_MEMORYLOAD: Config.Value = Config.section(CLUSTER_SECTION).value('Migration Free Memory', '20', type=Config.NUMERIC_FIELD)
|
||||
# Minimum Free memory for a node to be elegible for a destination of a migration
|
||||
CLUSTER_ELEGIBLE_MEMORYLOAD: Config.Value = Config.section(CLUSTER_SECTION).value('Migration Free Memory', '40', type=Config.NUMERIC_FIELD)
|
||||
# CLUSTER_ELEGIBLE_MEMORYLOAD: Config.Value = Config.section(CLUSTER_SECTION).value('Migration Free Memory', '40', type=Config.NUMERIC_FIELD)
|
||||
|
||||
RELOAD_TIME: Config.Value = Config.section(GLOBAL_SECTION).value('Page reload Time', '300', type=Config.NUMERIC_FIELD)
|
||||
|
||||
# Custom message for error when limiting by calendar
|
||||
LIMITED_BY_CALENDAR_TEXT: Config.Value = Config.section(GLOBAL_SECTION).value('Calendar access denied text', '', type=Config.TEXT_FIELD) # Defaults to Nothing
|
||||
# Custom message for error when limiting by calendar
|
||||
|
||||
# This is used so templates can change "styles" from admin interface
|
||||
LOWERCASE_USERNAME: Config.Value = Config.section(SECURITY_SECTION).value('Convert username to lowercase', '1', type=Config.BOOLEAN_FIELD)
|
||||
@ -342,6 +337,8 @@ class GlobalConfig:
|
||||
SITE_COPYRIGHT: Config.Value = Config.section(GLOBAL_SECTION).value('Site copyright info', '© Virtual Cable S.L.U.', type=Config.TEXT_FIELD)
|
||||
SITE_COPYRIGHT_LINK: Config.Value = Config.section(GLOBAL_SECTION).value('Site copyright link', 'https://www.udsenterprise.com', type=Config.TEXT_FIELD)
|
||||
|
||||
EXPERIMENTAL_FEATURES: Config.Value = Config.section(GLOBAL_SECTION).value('Experimental Features', '0', type=Config.BOOLEAN_FIELD)
|
||||
|
||||
_initDone = False
|
||||
|
||||
@staticmethod
|
||||
|
File diff suppressed because one or more lines are too long
@ -92,6 +92,6 @@
|
||||
</svg>
|
||||
</div>
|
||||
</uds-root>
|
||||
<script src="/uds/res/admin/runtime.js?stamp=1582122757" defer></script><script src="/uds/res/admin/polyfills-es5.js?stamp=1582122757" nomodule defer></script><script src="/uds/res/admin/polyfills.js?stamp=1582122757" defer></script><script src="/uds/res/admin/main.js?stamp=1582122757" defer></script></body>
|
||||
<script src="/uds/res/admin/runtime.js?stamp=1582589736" defer></script><script src="/uds/res/admin/polyfills-es5.js?stamp=1582589736" nomodule defer></script><script src="/uds/res/admin/polyfills.js?stamp=1582589736" defer></script><script src="/uds/res/admin/main.js?stamp=1582589736" defer></script></body>
|
||||
|
||||
</html>
|
||||
|
@ -109,6 +109,7 @@ def udsJs(request: 'HttpRequest') -> str:
|
||||
'csrf_field': CSRF_FIELD,
|
||||
'csrf': csrf_token,
|
||||
'image_size': Image.MAX_IMAGE_SIZE,
|
||||
'experimental_features': GlobalConfig.EXPERIMENTAL_FEATURES.getBool(),
|
||||
'reload_time': GlobalConfig.RELOAD_TIME.getInt(True),
|
||||
'site_name': GlobalConfig.SITE_NAME.get(),
|
||||
'site_copyright_info': GlobalConfig.SITE_COPYRIGHT.get(),
|
||||
|
Loading…
Reference in New Issue
Block a user