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

chore: Refactor machine name sanitization method

This commit is contained in:
Adolfo Gómez García 2024-05-05 02:56:06 +02:00
parent 029224c749
commit 397523c9a3
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23
2 changed files with 3 additions and 3 deletions

View File

@ -311,8 +311,8 @@ class DynamicPublication(services.Publication, autoserializable.AutoSerializable
# First we should create a full clone, so base machine do not get fullfilled with "garbage" delta disks...
# Add a number based on current time to avoid collisions
self._name = self.service().sanitize_machine_name(
f'UDS-Pub {self.servicepool_name()}-{int(time.time())%256:2X} {self.revision()}'
self._name = self.service().sanitized_name(
f'UDS-Pub-{self.servicepool_name()}-{int(time.time())%256:2X}-{self.revision()}'
)
self._is_flagged_for_destroy = False

View File

@ -109,7 +109,7 @@ class DynamicService(services.Service, abc.ABC): # pylint: disable=too-many-pub
def get_lenname(self) -> int:
return self.lenname.value
def sanitize_machine_name(self, name: str) -> str:
def sanitized_name(self, name: str) -> str:
"""
Sanitize machine name
Override it to provide a custom name sanitizer