From b777919f523acf13a4c5e398bfef7fe6e5b49eab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Mon, 16 Nov 2015 20:22:58 +0100 Subject: [PATCH] A few improvements --- server/src/uds/core/workers/DeployedServiceCleaner.py | 7 ++++++- server/src/uds/models/Provider.py | 5 ++++- server/src/uds/models/Service.py | 5 ++++- server/src/uds/models/ServicesPool.py | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/server/src/uds/core/workers/DeployedServiceCleaner.py b/server/src/uds/core/workers/DeployedServiceCleaner.py index 0b1cd172..da5d746b 100644 --- a/server/src/uds/core/workers/DeployedServiceCleaner.py +++ b/server/src/uds/core/workers/DeployedServiceCleaner.py @@ -65,6 +65,11 @@ class DeployedServiceRemover(Job): super(DeployedServiceRemover, self).__init__(environment) def startRemovalOf(self, ds): + if ds.service is None: # Maybe an inconsistent value? + logger.error('Found service pool {} without service') + ds.delete() + return + # Get publications in course...., can be at most 1!!! logger.debug('Removal process of {0}'.format(ds)) @@ -131,7 +136,7 @@ class DeployedServiceRemover(Job): for ds in rems: try: # Skips checking deployed services in maintenance mode - if ds.isInMaintenance(): + if ds.isInMaintenance() is False: self.startRemovalOf(ds) except Exception as e1: logger.error('Error removing {}: {}'.format(ds, e1)) diff --git a/server/src/uds/models/Provider.py b/server/src/uds/models/Provider.py index dc6e98b3..28d04d22 100644 --- a/server/src/uds/models/Provider.py +++ b/server/src/uds/models/Provider.py @@ -43,7 +43,7 @@ from uds.models.ManagedObjectModel import ManagedObjectModel import logging -__updated__ = '2015-05-12' +__updated__ = '2015-11-16' logger = logging.getLogger(__name__) @@ -77,6 +77,9 @@ class Provider(ManagedObjectModel): ''' return services.factory().lookup(self.data_type) + def isInMaintenance(self): + return self.maintenance_mode + def __str__(self): return u"{0} of type {1} (id:{2})".format(self.name, self.data_type, self.id) diff --git a/server/src/uds/models/Service.py b/server/src/uds/models/Service.py index dd54b40c..b69e94b7 100644 --- a/server/src/uds/models/Service.py +++ b/server/src/uds/models/Service.py @@ -47,7 +47,7 @@ from uds.models.Provider import Provider import logging -__updated__ = '2015-05-12' +__updated__ = '2015-11-16' logger = logging.getLogger(__name__) @@ -122,6 +122,9 @@ class Service(ManagedObjectModel): ''' return self.provider.getType().getServiceByType(self.data_type) + def isInMaintenance(self): + return self.provider is not None and self.provider.isInMaintenance() + def __str__(self): return u"{0} of type {1} (id:{2})".format(self.name, self.data_type, self.id) diff --git a/server/src/uds/models/ServicesPool.py b/server/src/uds/models/ServicesPool.py index e3efd5ba..4f4a7077 100644 --- a/server/src/uds/models/ServicesPool.py +++ b/server/src/uds/models/ServicesPool.py @@ -175,7 +175,7 @@ class DeployedService(UUIDModel): return False def isInMaintenance(self): - return self.service is not None and self.service.provider.maintenance_mode + return self.service is not None and self.service.isInMaintenance() def storeValue(self, name, value): '''