Revision dfd19c2d logic/credits.py
b/logic/credits.py | ||
---|---|---|
47 | 47 |
vm.charged = datetime.now() |
48 | 48 |
|
49 | 49 |
# Only charge for a specific set of states |
50 |
if vm._operstate in charged_states:
|
|
50 |
if vm.operstate in charged_states: |
|
51 | 51 |
cost_list = [] |
52 | 52 |
|
53 | 53 |
# remember, we charge only for Started and Stopped |
54 |
if vm._operstate == 'STARTED':
|
|
54 |
if vm.operstate == 'STARTED': |
|
55 | 55 |
cost_list = get_cost_active(vm.flavor, start_datetime, vm.charged) |
56 |
elif vm._operstate == 'STOPPED':
|
|
56 |
elif vm.operstate == 'STOPPED': |
|
57 | 57 |
cost_list = get_cost_inactive(vm.flavor, start_datetime, vm.charged) |
58 | 58 |
|
59 | 59 |
# find the total vost |
60 | 60 |
total_cost = sum([x[1] for x in cost_list]) |
61 | 61 |
|
62 | 62 |
# add the debit entry |
63 |
description = "Server = %s, charge = %d for state: %s" % (vm.name, total_cost, vm._operstate)
|
|
63 |
description = "Server = %s, charge = %d for state: %s" % (vm.name, total_cost, vm.operstate) |
|
64 | 64 |
debit_account(vm.owner, total_cost, vm, description) |
65 | 65 |
|
66 | 66 |
vm.save() |
Also available in: Unified diff