mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-22 13:34:04 +03:00
* Now cleanUDS cleans up possible locks also.
This command is designed to be executed with UDS backend stopped, so be care!! :) * Added deadLine calculation to ServicePool based on access calendars
This commit is contained in:
parent
c73dae361f
commit
dbcdc84b3b
@ -37,6 +37,8 @@ from django.core.cache import cache
|
||||
|
||||
from uds.core.util.Config import GlobalConfig
|
||||
from uds.core.util.Cache import Cache
|
||||
from uds.core.util.State import State
|
||||
from uds.models import Scheduler
|
||||
|
||||
import logging
|
||||
import sys
|
||||
@ -52,9 +54,18 @@ class Command(BaseCommand):
|
||||
sys.stdout.write("Cleaning up UDS\n")
|
||||
GlobalConfig.initialize()
|
||||
|
||||
sys.stdout.write("Cache...\n")
|
||||
# UDSs cache
|
||||
Cache.cleanUp()
|
||||
# Django caches
|
||||
cache.clear()
|
||||
|
||||
sys.stdout.write("Releasing schedulers...\n")
|
||||
# Release all Schedulers
|
||||
Scheduler.objects.all().update(owner_server='', state=State.FOR_EXECUTE)
|
||||
|
||||
sys.stdout.write("Reseting UDS Theme (setting to html5)...\n")
|
||||
# Reset theme to html5
|
||||
GlobalConfig.UDS_THEME.set('html5')
|
||||
|
||||
sys.stdout.write("UDS Cleaned UP\n")
|
@ -57,10 +57,10 @@ from uds.models.Util import getSqlDatetime
|
||||
|
||||
from uds.core.util.calendar import CalendarChecker
|
||||
|
||||
from datetime import timedelta
|
||||
from datetime import datetime, timedelta
|
||||
import logging
|
||||
|
||||
__updated__ = '2016-04-26'
|
||||
__updated__ = '2016-05-18'
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -207,6 +207,28 @@ class DeployedService(UUIDModel, TaggingMixin):
|
||||
|
||||
return access == states.action.ALLOW
|
||||
|
||||
def getDeadline(self, chkDateTime=None):
|
||||
'''
|
||||
Gets the deadline for an access on chkDateTime
|
||||
'''
|
||||
if chkDateTime is None:
|
||||
chkDateTime = getSqlDatetime()
|
||||
|
||||
if self.isAccessAllowed(chkDateTime) is False:
|
||||
return 0
|
||||
|
||||
deadLine = None
|
||||
for ac in self.calendaraccess_set.all():
|
||||
if ac.access == states.action.ALLOW:
|
||||
nextE = CalendarChecker(ac.calendar).nextEvent(chkDateTime, False)
|
||||
if deadLine is None or deadLine > nextE:
|
||||
deadLine = nextE
|
||||
|
||||
if deadLine is None:
|
||||
return None
|
||||
|
||||
return int((deadLine - chkDateTime).total_seconds())
|
||||
|
||||
|
||||
def storeValue(self, name, value):
|
||||
'''
|
||||
|
File diff suppressed because one or more lines are too long
@ -69,6 +69,9 @@ This states displays as default
|
||||
padding-right: 2px;
|
||||
}
|
||||
|
||||
.row-state-S {
|
||||
color: gray;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.label-tbl-button {
|
||||
@ -80,3 +83,4 @@ This states displays as default
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user