Commit acd52b30 authored by Vassilios Karakoidas's avatar Vassilios Karakoidas
Browse files

charger.py works with the refacctored code

parent 86765c6b
......@@ -39,7 +39,7 @@ Notes
5) The checkout directory name "synnefo" is mandatory
6) In Mac computers with Snow Leopard, you may have a problem installing pycurl. Remember to set 64-bit arch when you install it.
6) For Mac computers with Snow Leopard, you may have a problem installing pycurl. Remember to set 64-bit arch when you install it.
env ARCHFLAGS="-arch x86_64" ./bin/pip install pycurl
......
......@@ -8,17 +8,18 @@
from db.models import *
from logic import credits
def periodically_charge():
"""Scan all virtual machines and charge each user"""
all_vms = VirtualMachine.objects.all()
active_vms = VirtualMachine.objects.filter(delete=False)
if not len(all_vms):
if not len(active_vms):
print "No virtual machines found"
return
for vm in all_vms:
for vm in active_vms:
# Running and Stopped is charged, else the cost is zero
vm.charge()
credits.charge(vm)
# vim: set ts=4 sts=4 sw=4 et ai :
......@@ -19,7 +19,7 @@ class SynnefoUser(models.Model):
def get_limit(self, limit_name):
"""Returns the limit value for the specified limit"""
limit_objs = Limit.objects.filter(name=limit_name, user=self)
limit_objs = Limit.objects.filter(name=limit_name, user=self)
if len(limit_objs) == 1:
return limit_objs[0].value
......
......@@ -29,7 +29,3 @@ class FlavorTestCase(TestCase):
f_name = flavor.name
self.assertEqual(f_name, 'C1R1024D10', 'flavor.name is not generated correctly, C1R1024D10! (%s)' % (f_name,))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment