root / db / charger.py @ dd53338a
History | View | Annotate | Download (616 Bytes)
1 |
#
|
---|---|
2 |
# Charger - Administration script
|
3 |
#
|
4 |
# Executed hourly to charge vm usage for each user
|
5 |
#
|
6 |
# Copyright 2010 Greek Research and Technology Network
|
7 |
#
|
8 |
|
9 |
from synnefo.db.models import VirtualMachine |
10 |
|
11 |
from logic import credits |
12 |
|
13 |
def periodically_charge(): |
14 |
"""Scan all virtual machines and charge each user"""
|
15 |
active_vms = VirtualMachine.objects.filter(deleted=False)
|
16 |
|
17 |
if not len(active_vms): |
18 |
print "No virtual machines found" |
19 |
return
|
20 |
|
21 |
for vm in active_vms: |
22 |
# Running and Stopped is charged, else the cost is zero
|
23 |
credits.charge(vm) |
24 |
|
25 |
# vim: set ts=4 sts=4 sw=4 et ai :
|