Revision f533f224 logic/management/commands/reconcile.py
b/logic/management/commands/reconcile.py | ||
---|---|---|
52 | 52 |
) |
53 | 53 |
|
54 | 54 |
def handle(self, all_vms = False, interval = 1, **options): |
55 |
all = VirtualMachine.objects.all() |
|
55 |
all = VirtualMachine.objects.all().filter(deleted = False) \ |
|
56 |
.filter(suspended = False) |
|
56 | 57 |
|
57 | 58 |
if not all_vms: |
58 | 59 |
now = datetime.now() |
59 | 60 |
last_update = timedelta(minutes = settings.RECONCILIATION_MIN) |
60 | 61 |
not_updated = VirtualMachine.objects \ |
61 |
.filter(deleted = False) \ |
|
62 |
.filter(suspended = False) \ |
|
63 |
.filter(updated__lte = (now - last_update)) |
|
62 |
.filter(updated__lte = (now - last_update)) |
|
64 | 63 |
|
65 | 64 |
to_update = ((all.count() / settings.RECONCILIATION_MIN) * interval) |
66 | 65 |
else: |
... | ... | |
73 | 72 |
msg = dict(type = "reconcile", vmid = vmid) |
74 | 73 |
try: |
75 | 74 |
amqp_connection.send(json.dumps(msg), settings.EXCHANGE_CRON, |
76 |
"reconciliation.%s"%vmid)
|
|
75 |
"reconciliation.%s" % vmid)
|
|
77 | 76 |
except AMQPError as e: |
78 | 77 |
print >> sys.stderr, 'Error sending reconciliation request: %s' % e |
79 | 78 |
raise |
Also available in: Unified diff