mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-03 01:17:56 +03:00
Fixed an small bug when checking service is in maintenance
This commit is contained in:
parent
7d02f3682d
commit
6371a24d23
@ -93,7 +93,7 @@ class Connection(Handler):
|
||||
services.append({'id': 'A' + svr.uuid,
|
||||
'name': svr['name'],
|
||||
'transports': trans,
|
||||
'maintenance': svr.deployed_service.service.provider.maintenance_mode,
|
||||
'maintenance': svr.isInMaintenance(),
|
||||
'in_use': svr.in_use})
|
||||
|
||||
logger.debug(services)
|
||||
@ -115,7 +115,7 @@ class Connection(Handler):
|
||||
services.append({'id': 'F' + svr.uuid,
|
||||
'name': svr.name,
|
||||
'transports': trans,
|
||||
'maintenance': svr.service.provider.maintenance_mode,
|
||||
'maintenance': svr.isInMaintenance(),
|
||||
'in_use': in_use})
|
||||
|
||||
logger.debug('Services: {0}'.format(services))
|
||||
|
@ -87,7 +87,7 @@ class ServicesPools(ModelHandler):
|
||||
'parent': item.service.name,
|
||||
'parent_type': item.service.data_type,
|
||||
'comments': item.comments,
|
||||
'state': item.state if item.service.provider.maintenance_mode is False else State.MAINTENANCE,
|
||||
'state': item.state if item.isInMaintenance() is False else State.MAINTENANCE,
|
||||
'thumb': item.image.thumb64 if item.image is not None else DEFAULT_THUMB_BASE64,
|
||||
'service_id': item.service.uuid,
|
||||
'provider_id': item.service.provider.uuid,
|
||||
|
@ -56,8 +56,7 @@ class AssignedAndUnused(Job):
|
||||
since_state = getSqlDatetime() - timedelta(seconds=self.frecuency)
|
||||
for ds in DeployedService.objects.all():
|
||||
# Skips checking deployed services in maintenance mode
|
||||
if ds.service.provider.maintenance_mode is True:
|
||||
logger.warn('Skipped {} because it is in maintenance mode'.format(ds.name))
|
||||
if ds.isInMaintenance() is True:
|
||||
continue
|
||||
# If do not needs os manager, this is
|
||||
if ds.osmanager is not None:
|
||||
|
@ -131,7 +131,7 @@ class DeployedServiceRemover(Job):
|
||||
for ds in rems:
|
||||
try:
|
||||
# Skips checking deployed services in maintenance mode
|
||||
if ds.service.provider.maintenance_mode is False:
|
||||
if ds.isInMaintenance():
|
||||
self.startRemovalOf(ds)
|
||||
except Exception as e1:
|
||||
logger.error('Error removing {}: {}'.format(ds, e1))
|
||||
@ -145,6 +145,9 @@ class DeployedServiceRemover(Job):
|
||||
if len(rems) > 0:
|
||||
logger.debug('Found a deployed service in removing state, continuing removal of {0}'.format(rems))
|
||||
for ds in rems:
|
||||
try:
|
||||
# Skips checking deployed services in maintenance mode
|
||||
if ds.service.provider.maintenance_mode is False:
|
||||
if ds.isInMaintenance() is False:
|
||||
self.continueRemovalOf(ds)
|
||||
except Exception:
|
||||
logger.exception('Removing deployed service')
|
||||
|
@ -78,4 +78,7 @@ class UserServiceRemover(Job):
|
||||
removables = UserService.objects.filter(state=State.REMOVABLE, state_date__lt=removeFrom,
|
||||
deployed_service__service__provider__maintenance_mode=False)[0:UserServiceRemover.removeAtOnce]
|
||||
for us in removables:
|
||||
try:
|
||||
UserServiceManager.manager().remove(us)
|
||||
except Exception:
|
||||
logger.exception('Exception removing user service')
|
||||
|
@ -55,7 +55,7 @@ from uds.models.Util import getSqlDatetime
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
__updated__ = '2015-06-12'
|
||||
__updated__ = '2015-11-16'
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -175,7 +175,7 @@ class DeployedService(UUIDModel):
|
||||
return False
|
||||
|
||||
def isInMaintenance(self):
|
||||
return self.service.provider.maintenance_mode
|
||||
return self.service is not None and self.service.provider.maintenance_mode
|
||||
|
||||
def storeValue(self, name, value):
|
||||
'''
|
||||
|
@ -49,7 +49,7 @@ import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
__updated__ = '2015-05-05'
|
||||
__updated__ = '2015-11-16'
|
||||
|
||||
|
||||
def about(request):
|
||||
@ -124,7 +124,7 @@ def index(request):
|
||||
'transports': trans,
|
||||
'imageId': imageId,
|
||||
'show_transports': svr.deployed_service.show_transports,
|
||||
'maintenance': svr.deployed_service.service.provider.maintenance_mode,
|
||||
'maintenance': svr.deployed_service.isInMaintenance(),
|
||||
'in_use': svr.in_use,
|
||||
})
|
||||
|
||||
@ -167,7 +167,7 @@ def index(request):
|
||||
'transports': trans,
|
||||
'imageId': imageId,
|
||||
'show_transports': svr.show_transports,
|
||||
'maintenance': svr.service.provider.maintenance_mode,
|
||||
'maintenance': svr.isInMaintenance(),
|
||||
'in_use': in_use,
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user