Deleted resource backend support
This commit is contained in:
parent
ab6d027f01
commit
a0ccb5c420
|
@ -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()
|
||||||
|
|
Loading…
Reference in a new issue