diff --git a/actor/src/udsactor/linux/renamer/debian.py b/actor/src/udsactor/linux/renamer/debian.py index b8632dac9..7c198d03a 100644 --- a/actor/src/udsactor/linux/renamer/debian.py +++ b/actor/src/udsactor/linux/renamer/debian.py @@ -45,7 +45,8 @@ def rename(newName: str) -> bool: hostname.write(newName) # Force system new name - os.system('/bin/hostname %s' % newName) + os.system('/bin/hostname {}'.format(newName)) + os.system('/usr/bin/hostnamectl set-hostname {}'.format(newName)) # add name to "hosts" with open('/etc/hosts', 'r') as hosts: diff --git a/actor/src/udsactor/linux/renamer/opensuse.py b/actor/src/udsactor/linux/renamer/opensuse.py index 9537afaee..c142705fd 100644 --- a/actor/src/udsactor/linux/renamer/opensuse.py +++ b/actor/src/udsactor/linux/renamer/opensuse.py @@ -46,7 +46,8 @@ def rename(newName: str) -> bool: hostname.write(newName) # Force system new name - os.system('/bin/hostname %s' % newName) + os.system('/bin/hostname {}'.format(newName)) + os.system('/usr/bin/hostnamectl set-hostname {}'.format(newName)) # add name to "hosts" with open('/etc/hosts', 'r') as hosts: diff --git a/actor/src/udsactor/linux/renamer/redhat.py b/actor/src/udsactor/linux/renamer/redhat.py index 1a8543f41..3ad1ac810 100644 --- a/actor/src/udsactor/linux/renamer/redhat.py +++ b/actor/src/udsactor/linux/renamer/redhat.py @@ -46,7 +46,8 @@ def rename(newName: str) -> bool: hostname.write(newName) # Force system new name - os.system('/bin/hostname %s' % newName) + os.system('/bin/hostname {}'.format(newName)) + os.system('/usr/bin/hostnamectl set-hostname {}'.format(newName)) # add name to "hosts" with open('/etc/hosts', 'r') as hosts: diff --git a/server/src/server/settings.py.sample b/server/src/server/settings.py.sample index 7869be019..7258eea3e 100644 --- a/server/src/server/settings.py.sample +++ b/server/src/server/settings.py.sample @@ -19,9 +19,10 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 'OPTIONS': { - 'init_command': 'SET default_storage_engine=INNODB; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;', + # 'init_command': 'SET default_storage_engine=INNODB; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;', # 'init_command': 'SET storage_engine=INNODB, SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED', # 'init_command': 'SET storage_engine=MYISAM, SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED', + 'isolation_level': 'read committed', }, 'NAME': 'dbuds', # Or path to database file if using sqlite3. 'USER': 'dbuds', # Not used with sqlite3. diff --git a/server/src/uds/core/util/validators.py b/server/src/uds/core/util/validators.py index d5213c804..f83808751 100644 --- a/server/src/uds/core/util/validators.py +++ b/server/src/uds/core/util/validators.py @@ -76,6 +76,23 @@ def validateNumeric( return numericStr +def validateHostname(hostname: str, maxLength: int, asPattern: bool) -> str: + if len(hostname) > maxLength: + raise Module.ValidationException(_('{} exceeds maximum host name length.').format(hostname)) + + if hostname[-1] == ".": + hostname = hostname[:-1] # strip exactly one dot from the right, if present + + if asPattern: + allowed = re.compile("(?!-)[A-Z\d-]{1,63}$", re.IGNORECASE) + else: + allowed = re.compile("(?!-)[A-Z\d-]{1,63}(? int: """ diff --git a/server/src/uds/services/OpenNebula/service.py b/server/src/uds/services/OpenNebula/service.py index c5930b876..4da7be580 100644 --- a/server/src/uds/services/OpenNebula/service.py +++ b/server/src/uds/services/OpenNebula/service.py @@ -36,7 +36,7 @@ import typing from django.utils.translation import ugettext_noop as _ from uds.core.transports import protocols from uds.core.services import Service, types as serviceTypes -from uds.core.util import tools +from uds.core.util import validators from uds.core.ui import gui from .publication import LivePublication @@ -140,8 +140,10 @@ class LiveService(Service): Note that we check them throught FROM variables, that already has been initialized by __init__ method of base class, before invoking this. """ - if values: - tools.checkValidBasename(self.baseName.value, self.lenName.num()) + if not values: + return + + self.baseName.value = validators.validateHostname(self.baseName.value, maxLength=15-self.lenName.num(), asPattern=True) def parent(self) -> 'OpenNebulaProvider': return typing.cast('OpenNebulaProvider', super().parent())