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