Statistics
| Branch: | Tag: | Revision:

root / db / charger.py @ 738c4d47

History | View | Annotate | Download (558 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

    
12
def periodically_charge():
13
    """Scan all virtual machines and charge each user"""
14
    all_vms = VirtualMachine.objects.all()
15
    
16
    if not len(all_vms):
17
        print "No virtual machines found"
18
        return
19
    
20
    for vm in all_vms:
21
        # Running and Stopped is charged, else the cost is zero
22
        vm.charge()
23

    
24
# vim: set ts=4 sts=4 sw=4 et ai :