Revision 22e52ede logic/utils.py

b/logic/utils.py
33 33
        vm._backendjobstatus in ('queued', 'waiting', 'running'):
34 34
        return "REBOOT"
35 35
    return r
36

  
37

  
38
def calculate_cost(start_date, end_date, cost):
39
    """Calculate the total cost for the specified duration"""
40
    td = end_date - start_date
41
    sec = float(td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / float(10**6)
42
    total_hours = float(sec) / float(60.0*60.0)
43
    total_cost = float(cost)*total_hours
44

  
45
    return round(total_cost)

Also available in: Unified diff