Commit f2148cee by Őry Máté

vm: add periodic node updates

parent 45f1d0df
...@@ -7,7 +7,9 @@ HOSTNAME = "localhost" ...@@ -7,7 +7,9 @@ HOSTNAME = "localhost"
celery = Celery('manager', backend='amqp', celery = Celery('manager', backend='amqp',
broker=getenv("AMQP_URI"), broker=getenv("AMQP_URI"),
include=['vm.tasks.local_tasks', 'storage.tasks.local_tasks', include=['vm.tasks.local_tasks',
'vm.tasks.local_periodic_tasks',
'storage.tasks.local_tasks',
'firewall.tasks.local_tasks']) 'firewall.tasks.local_tasks'])
celery.conf.update( celery.conf.update(
...@@ -23,6 +25,11 @@ celery.conf.update( ...@@ -23,6 +25,11 @@ celery.conf.update(
'schedule': timedelta(seconds=5), 'schedule': timedelta(seconds=5),
'options': {'queue': 'localhost.man'} 'options': {'queue': 'localhost.man'}
}, },
'vm.periodic_tasks': {
'task': 'vm.tasks.local_periodic_tasks.update_domain_states',
'schedule': timedelta(seconds=10),
'options': {'queue': 'localhost.man'}
},
} }
) )
...@@ -850,6 +850,8 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel): ...@@ -850,6 +850,8 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
logger.debug('Instance %s state changed ' logger.debug('Instance %s state changed '
'(db: %s, new: %s)', '(db: %s, new: %s)',
self, self.state, new_state) self, self.state, new_state)
self.state = new_state
self.save()
class InstanceActivity(ActivityModel): class InstanceActivity(ActivityModel):
......
from manager.mancelery import celery
from vm.models import Node
@celery.task
def update_domain_states():
nodes = Node.objects.filter(enabled=True).all()
for node in nodes:
node.update_vm_states()
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 sign in to comment