From dfb15e892046d00ae90b0cf9dd7a76fa4270a9f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Fri, 22 Mar 2024 01:17:34 +0100 Subject: [PATCH] Refactorized "specializations" name to a more convenient "generics" --- .../{specializations => generics}/__init__.py | 0 .../dynamic_machine/__init__.py | 0 .../dynamic_machine/dynamic_publication.py | 0 .../dynamic_machine/dynamic_service.py | 0 .../dynamic_machine/dynamic_userservice.py | 0 .../fixed_machine/__init__.py | 0 .../fixed_machine/fixed_service.py | 0 .../fixed_machine/fixed_userservice.py | 0 .../src/uds/services/OpenStack/deployment_fixed.py | 2 +- server/src/uds/services/OpenStack/service_fixed.py | 4 ++-- .../src/uds/services/PhysicalMachines/deployment.py | 5 ++++- .../uds/services/PhysicalMachines/service_multi.py | 2 +- server/src/uds/services/Proxmox/deployment_fixed.py | 2 +- server/src/uds/services/Proxmox/deployment_linked.py | 2 +- server/src/uds/services/Proxmox/publication.py | 2 +- server/src/uds/services/Proxmox/service_fixed.py | 4 ++-- server/src/uds/services/Proxmox/service_linked.py | 12 ++++++------ .../src/uds/services/ProxmoxOrig/deployment_fixed.py | 2 +- server/src/uds/services/ProxmoxOrig/service_fixed.py | 4 ++-- server/src/uds/services/Xen/deployment_fixed.py | 2 +- server/src/uds/services/Xen/service_fixed.py | 4 ++-- .../services/openstack/test_userservice_fixed.py | 4 ++-- .../test_serialization_deployment.py | 7 +------ 23 files changed, 28 insertions(+), 30 deletions(-) rename server/src/uds/core/services/{specializations => generics}/__init__.py (100%) rename server/src/uds/core/services/{specializations => generics}/dynamic_machine/__init__.py (100%) rename server/src/uds/core/services/{specializations => generics}/dynamic_machine/dynamic_publication.py (100%) rename server/src/uds/core/services/{specializations => generics}/dynamic_machine/dynamic_service.py (100%) rename server/src/uds/core/services/{specializations => generics}/dynamic_machine/dynamic_userservice.py (100%) rename server/src/uds/core/services/{specializations => generics}/fixed_machine/__init__.py (100%) rename server/src/uds/core/services/{specializations => generics}/fixed_machine/fixed_service.py (100%) rename server/src/uds/core/services/{specializations => generics}/fixed_machine/fixed_userservice.py (100%) diff --git a/server/src/uds/core/services/specializations/__init__.py b/server/src/uds/core/services/generics/__init__.py similarity index 100% rename from server/src/uds/core/services/specializations/__init__.py rename to server/src/uds/core/services/generics/__init__.py diff --git a/server/src/uds/core/services/specializations/dynamic_machine/__init__.py b/server/src/uds/core/services/generics/dynamic_machine/__init__.py similarity index 100% rename from server/src/uds/core/services/specializations/dynamic_machine/__init__.py rename to server/src/uds/core/services/generics/dynamic_machine/__init__.py diff --git a/server/src/uds/core/services/specializations/dynamic_machine/dynamic_publication.py b/server/src/uds/core/services/generics/dynamic_machine/dynamic_publication.py similarity index 100% rename from server/src/uds/core/services/specializations/dynamic_machine/dynamic_publication.py rename to server/src/uds/core/services/generics/dynamic_machine/dynamic_publication.py diff --git a/server/src/uds/core/services/specializations/dynamic_machine/dynamic_service.py b/server/src/uds/core/services/generics/dynamic_machine/dynamic_service.py similarity index 100% rename from server/src/uds/core/services/specializations/dynamic_machine/dynamic_service.py rename to server/src/uds/core/services/generics/dynamic_machine/dynamic_service.py diff --git a/server/src/uds/core/services/specializations/dynamic_machine/dynamic_userservice.py b/server/src/uds/core/services/generics/dynamic_machine/dynamic_userservice.py similarity index 100% rename from server/src/uds/core/services/specializations/dynamic_machine/dynamic_userservice.py rename to server/src/uds/core/services/generics/dynamic_machine/dynamic_userservice.py diff --git a/server/src/uds/core/services/specializations/fixed_machine/__init__.py b/server/src/uds/core/services/generics/fixed_machine/__init__.py similarity index 100% rename from server/src/uds/core/services/specializations/fixed_machine/__init__.py rename to server/src/uds/core/services/generics/fixed_machine/__init__.py diff --git a/server/src/uds/core/services/specializations/fixed_machine/fixed_service.py b/server/src/uds/core/services/generics/fixed_machine/fixed_service.py similarity index 100% rename from server/src/uds/core/services/specializations/fixed_machine/fixed_service.py rename to server/src/uds/core/services/generics/fixed_machine/fixed_service.py diff --git a/server/src/uds/core/services/specializations/fixed_machine/fixed_userservice.py b/server/src/uds/core/services/generics/fixed_machine/fixed_userservice.py similarity index 100% rename from server/src/uds/core/services/specializations/fixed_machine/fixed_userservice.py rename to server/src/uds/core/services/generics/fixed_machine/fixed_userservice.py diff --git a/server/src/uds/services/OpenStack/deployment_fixed.py b/server/src/uds/services/OpenStack/deployment_fixed.py index 5ea2913f8..b86919be6 100644 --- a/server/src/uds/services/OpenStack/deployment_fixed.py +++ b/server/src/uds/services/OpenStack/deployment_fixed.py @@ -34,7 +34,7 @@ import logging import typing from uds.core import types -from uds.core.services.specializations.fixed_machine.fixed_userservice import FixedUserService, Operation +from uds.core.services.generics.fixed_machine.fixed_userservice import FixedUserService, Operation from uds.core.util import autoserializable from .openstack import types as openstack_types diff --git a/server/src/uds/services/OpenStack/service_fixed.py b/server/src/uds/services/OpenStack/service_fixed.py index 7f04d8470..e97e5ad71 100644 --- a/server/src/uds/services/OpenStack/service_fixed.py +++ b/server/src/uds/services/OpenStack/service_fixed.py @@ -35,8 +35,8 @@ import typing from django.utils.translation import gettext_noop as _ from uds.core import services, types -from uds.core.services.specializations.fixed_machine.fixed_service import FixedService -from uds.core.services.specializations.fixed_machine.fixed_userservice import FixedUserService +from uds.core.services.generics.fixed_machine.fixed_service import FixedService +from uds.core.services.generics.fixed_machine.fixed_userservice import FixedUserService from uds.core.ui import gui from uds.core.util import log diff --git a/server/src/uds/services/PhysicalMachines/deployment.py b/server/src/uds/services/PhysicalMachines/deployment.py index 970d93e8b..0ef0ce220 100644 --- a/server/src/uds/services/PhysicalMachines/deployment.py +++ b/server/src/uds/services/PhysicalMachines/deployment.py @@ -136,6 +136,9 @@ class IPMachineUserService(services.UserService, autoserializable.AutoSerializab def deploy_for_user(self, user: 'models.User') -> types.states.TaskState: logger.debug("Starting deploy of %s for user %s", self._ip, user) return self._deploy() + + def deploy_for_cache(self, level: types.services.CacheLevel) -> types.states.TaskState: + return self._error('Cache deploy not supported') def assign(self, ip: str) -> types.states.TaskState: logger.debug('Assigning from assignable with ip %s', ip) @@ -148,7 +151,7 @@ class IPMachineUserService(services.UserService, autoserializable.AutoSerializab dbService.save() return self._state - def error(self, reason: str) -> types.states.TaskState: + def _error(self, reason: str) -> types.states.TaskState: self._state = types.states.TaskState.ERROR self._ip = '' self._reason = reason diff --git a/server/src/uds/services/PhysicalMachines/service_multi.py b/server/src/uds/services/PhysicalMachines/service_multi.py index 674262d65..01244d94e 100644 --- a/server/src/uds/services/PhysicalMachines/service_multi.py +++ b/server/src/uds/services/PhysicalMachines/service_multi.py @@ -327,7 +327,7 @@ class IPMachinesService(IPServiceBase): self.storage.save_pickled(host.host, now) return ipmachine_instance.assign(host.as_identifier()) - return ipmachine_instance.error('IP already assigned') + return ipmachine_instance._error('IP already assigned') def process_login(self, id: str, remote_login: bool) -> None: ''' diff --git a/server/src/uds/services/Proxmox/deployment_fixed.py b/server/src/uds/services/Proxmox/deployment_fixed.py index 9188823f4..607effac5 100644 --- a/server/src/uds/services/Proxmox/deployment_fixed.py +++ b/server/src/uds/services/Proxmox/deployment_fixed.py @@ -34,7 +34,7 @@ import logging import typing from uds.core import types -from uds.core.services.specializations.fixed_machine.fixed_userservice import FixedUserService, Operation +from uds.core.services.generics.fixed_machine.fixed_userservice import FixedUserService, Operation from uds.core.util import autoserializable from . import client diff --git a/server/src/uds/services/Proxmox/deployment_linked.py b/server/src/uds/services/Proxmox/deployment_linked.py index 824233164..4558a7fb8 100644 --- a/server/src/uds/services/Proxmox/deployment_linked.py +++ b/server/src/uds/services/Proxmox/deployment_linked.py @@ -36,7 +36,7 @@ import logging import typing from uds.core import types, consts -from uds.core.services.specializations.dynamic_machine.dynamic_userservice import DynamicUserService, Operation +from uds.core.services.generics.dynamic_machine.dynamic_userservice import DynamicUserService, Operation from uds.core.managers.userservice import UserServiceManager from uds.core.util import autoserializable diff --git a/server/src/uds/services/Proxmox/publication.py b/server/src/uds/services/Proxmox/publication.py index 1a426127c..a3210a5cb 100644 --- a/server/src/uds/services/Proxmox/publication.py +++ b/server/src/uds/services/Proxmox/publication.py @@ -35,7 +35,7 @@ import typing from django.utils.translation import gettext as _ from uds.core import types -from uds.core.services.specializations.dynamic_machine.dynamic_publication import DynamicPublication +from uds.core.services.generics.dynamic_machine.dynamic_publication import DynamicPublication from uds.core.util import autoserializable # Not imported at runtime, just for type checking diff --git a/server/src/uds/services/Proxmox/service_fixed.py b/server/src/uds/services/Proxmox/service_fixed.py index d300ba53e..a3072f642 100644 --- a/server/src/uds/services/Proxmox/service_fixed.py +++ b/server/src/uds/services/Proxmox/service_fixed.py @@ -35,8 +35,8 @@ import typing from django.utils.translation import gettext_noop as _ from uds.core import services, types -from uds.core.services.specializations.fixed_machine.fixed_service import FixedService -from uds.core.services.specializations.fixed_machine.fixed_userservice import FixedUserService +from uds.core.services.generics.fixed_machine.fixed_service import FixedService +from uds.core.services.generics.fixed_machine.fixed_userservice import FixedUserService from uds.core.ui import gui from uds.core.util import log diff --git a/server/src/uds/services/Proxmox/service_linked.py b/server/src/uds/services/Proxmox/service_linked.py index 1d30ea289..8566c46b0 100644 --- a/server/src/uds/services/Proxmox/service_linked.py +++ b/server/src/uds/services/Proxmox/service_linked.py @@ -34,9 +34,9 @@ import typing from django.utils.translation import gettext_noop as _ from uds.core import types -from uds.core.services.specializations.dynamic_machine.dynamic_publication import DynamicPublication -from uds.core.services.specializations.dynamic_machine.dynamic_service import DynamicService -from uds.core.services.specializations.dynamic_machine.dynamic_userservice import DynamicUserService +from uds.core.services.generics.dynamic_machine.dynamic_publication import DynamicPublication +from uds.core.services.generics.dynamic_machine.dynamic_service import DynamicService +from uds.core.services.generics.dynamic_machine.dynamic_userservice import DynamicUserService from uds.core.ui import gui from uds.core.util import validators, log, fields @@ -48,9 +48,9 @@ from .publication import ProxmoxPublication if typing.TYPE_CHECKING: from . import client from .provider import ProxmoxProvider - from uds.core.services.specializations.dynamic_machine.dynamic_publication import DynamicPublication - from uds.core.services.specializations.dynamic_machine.dynamic_service import DynamicService - from uds.core.services.specializations.dynamic_machine.dynamic_userservice import DynamicUserService + from uds.core.services.generics.dynamic_machine.dynamic_publication import DynamicPublication + from uds.core.services.generics.dynamic_machine.dynamic_service import DynamicService + from uds.core.services.generics.dynamic_machine.dynamic_userservice import DynamicUserService logger = logging.getLogger(__name__) diff --git a/server/src/uds/services/ProxmoxOrig/deployment_fixed.py b/server/src/uds/services/ProxmoxOrig/deployment_fixed.py index 9188823f4..607effac5 100644 --- a/server/src/uds/services/ProxmoxOrig/deployment_fixed.py +++ b/server/src/uds/services/ProxmoxOrig/deployment_fixed.py @@ -34,7 +34,7 @@ import logging import typing from uds.core import types -from uds.core.services.specializations.fixed_machine.fixed_userservice import FixedUserService, Operation +from uds.core.services.generics.fixed_machine.fixed_userservice import FixedUserService, Operation from uds.core.util import autoserializable from . import client diff --git a/server/src/uds/services/ProxmoxOrig/service_fixed.py b/server/src/uds/services/ProxmoxOrig/service_fixed.py index 9e86ba68c..bade32042 100644 --- a/server/src/uds/services/ProxmoxOrig/service_fixed.py +++ b/server/src/uds/services/ProxmoxOrig/service_fixed.py @@ -35,8 +35,8 @@ import typing from django.utils.translation import gettext_noop as _ from uds.core import services, types -from uds.core.services.specializations.fixed_machine.fixed_service import FixedService -from uds.core.services.specializations.fixed_machine.fixed_userservice import FixedUserService +from uds.core.services.generics.fixed_machine.fixed_service import FixedService +from uds.core.services.generics.fixed_machine.fixed_userservice import FixedUserService from uds.core.ui import gui from uds.core.util import log diff --git a/server/src/uds/services/Xen/deployment_fixed.py b/server/src/uds/services/Xen/deployment_fixed.py index d01245d6c..9b123e504 100644 --- a/server/src/uds/services/Xen/deployment_fixed.py +++ b/server/src/uds/services/Xen/deployment_fixed.py @@ -34,7 +34,7 @@ import logging import typing from uds.core import types -from uds.core.services.specializations.fixed_machine.fixed_userservice import FixedUserService, Operation +from uds.core.services.generics.fixed_machine.fixed_userservice import FixedUserService, Operation from uds.core.util import log, autoserializable from . import xen_client diff --git a/server/src/uds/services/Xen/service_fixed.py b/server/src/uds/services/Xen/service_fixed.py index 29b685cf2..0d789e44e 100644 --- a/server/src/uds/services/Xen/service_fixed.py +++ b/server/src/uds/services/Xen/service_fixed.py @@ -35,8 +35,8 @@ import collections.abc from django.utils.translation import gettext_noop as _ from uds.core import consts, services, types -from uds.core.services.specializations.fixed_machine.fixed_service import FixedService -from uds.core.services.specializations.fixed_machine.fixed_userservice import FixedUserService +from uds.core.services.generics.fixed_machine.fixed_service import FixedService +from uds.core.services.generics.fixed_machine.fixed_userservice import FixedUserService from uds.core.ui import gui from uds.core.util import log from uds.core.util.decorators import cached diff --git a/server/tests/services/openstack/test_userservice_fixed.py b/server/tests/services/openstack/test_userservice_fixed.py index e977eb9dd..53b36ca68 100644 --- a/server/tests/services/openstack/test_userservice_fixed.py +++ b/server/tests/services/openstack/test_userservice_fixed.py @@ -58,8 +58,8 @@ class TestOpenstackLiveService(UDSTransactionTestCase): userservice.db_obj = mock.MagicMock(return_value=userservice_db) # Test Deploy for cache, should raise Exception due # to the fact fixed services cannot have cached items - with self.assertRaises(Exception): - userservice.deploy_for_cache(level=types.services.CacheLevel.L1) + state = userservice.deploy_for_cache(level=types.services.CacheLevel.L1) + self.assertEqual(state, types.states.TaskState.ERROR) state = userservice.deploy_for_user(models.User()) diff --git a/server/tests/services/physical_machines/test_serialization_deployment.py b/server/tests/services/physical_machines/test_serialization_deployment.py index cfce7f7a7..9573ce6a7 100644 --- a/server/tests/services/physical_machines/test_serialization_deployment.py +++ b/server/tests/services/physical_machines/test_serialization_deployment.py @@ -8,19 +8,14 @@ """ Author: Adolfo Gómez, dkmaster at dkmon dot com """ -import typing - # We use commit/rollback from tests.utils.test import UDSTestCase from uds.core.util import autoserializable from uds.core.environment import Environment -from uds.core.managers import crypto - -from django.conf import settings -from uds.services.PhysicalMachines import provider, deployment +from uds.services.PhysicalMachines import deployment class IPMachineUserServiceSerializationTest(UDSTestCase):