Added job to update the service groups on a daily basis

This commit is contained in:
2010-09-21 10:57:27 +01:00
parent 18a3f8751f
commit 33c526801a
2 changed files with 28 additions and 0 deletions

View File

@@ -7,3 +7,4 @@ ROOT=/home/matalok/auth/auth
@daily $ROOT/run-cron.py eve_api.cron CorpManagementUpdate > $ROOT/logs/corpman-update.log 2>&1
0 */6 * * * $ROOT/run-cron.py eve_api.cron AllianceUpdate > $ROOT/logs/alliance-update.log 2>&1
@daily $ROOT/run-cron.py eve_proxy.cron ClearStaleCache > $ROOT/logs/cache-clear.log 2>&1
@daily $ROOT/run-cron.py sso.cron UpdateServicegroups > $ROOT/logs/servicegroup-update.log 2>&1

View File

@@ -46,3 +46,30 @@ class ValidateDisabledUsers():
api.settings = servacc.service.settings
if not api.disable_user(servacc.service_uid):
self._logger.error('Error disabling %s on %s' % (servacc, servacc.service))
class UpdateServiceGroups():
"""
Cycles through all service accounts and updates group access.
"""
# run daily
run_every = 84600
@property
def _logger(self):
if not hasattr(self, '__logger'):
self.__logger = logging.getLogger(__name__)
return self.__logger
def job(self):
for serv in Service.objects.filter(active=1):
self._logger.info('Updating %s service' % serv)
api = serv.api_class
for servacc in ServiceAccount.objects.filter(active=1, service=serv):
self._logger.info('Processing %s' % servacc)
try:
api.update_groups(servacc.service_uid, servacc.user.groups.all())
except:
self._logger.error('Error updating %s' % servacc)