Commit 66302657 authored by Georgios Gousios's avatar Georgios Gousios
Browse files

Skip deleted and suspended VMs from reconciliation

parent e0fd9645
......@@ -61,13 +61,15 @@ class Command(NoArgsCommand):
def handle_noargs(self, **options):
now = datetime.now()
last_update = timedelta(minutes = 30)
not_updated = VirtualMachine.objects.filter(updated__lte = (now - last_update))
last_update = timedelta(minutes = settings.RECONCILIATION_MIN)
not_updated = VirtualMachine.objects.filter(deleted = False) \
.filter(suspended = False) \
.filter(updated__lte = (now - last_update))
all = VirtualMachine.objects.all()
to_update = all.count() / settings.RECONCILIATION_MIN
vm_ids = map(lambda x: x.id, VirtualMachine.objects.all()[:to_update])
vm_ids = map(lambda x: x.id, not_updated[:to_update])
sent = False
self.open_channel()
for vmid in vm_ids :
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment