Deleted resource backend support

This commit is contained in:
Marc Aymerich 2015-05-13 14:28:41 +00:00
parent ab6d027f01
commit a0ccb5c420
1 changed files with 6 additions and 6 deletions

View File

@ -128,20 +128,20 @@ class Resource(models.Model):
def sync_periodic_task(self): def sync_periodic_task(self):
name = 'monitor.%s' % str(self) name = 'monitor.%s' % str(self)
if resource.pk and resource.crontab: if self.pk and self.crontab:
try: try:
task = PeriodicTask.objects.get(name=name) task = PeriodicTask.objects.get(name=name)
except PeriodicTask.DoesNotExist: except PeriodicTask.DoesNotExist:
if resource.is_active: if self.is_active:
PeriodicTask.objects.create( PeriodicTask.objects.create(
name=name, name=name,
task='resources.Monitor', task='resources.Monitor',
args=[resource.pk], args=[self.pk],
crontab=resource.crontab crontab=self.crontab
) )
else: else:
if task.crontab != resource.crontab: if task.crontab != self.crontab:
task.crontab = resource.crontab task.crontab = self.crontab
task.save(update_fields=['crontab']) task.save(update_fields=['crontab'])
else: else:
PeriodicTask.objects.filter(name=name).delete() PeriodicTask.objects.filter(name=name).delete()