execute a periodic task

Asked by Jacopo

Hi,

i'm doing a thesis work on nova and i need to add a periodic task to execute. I'll find the decorator "@periodic_task" and it seems to do what i want. But now i don't know how to add some code to execute. I try to add a module in the source and launch a script installation, but my file isn't compiled. Then i try insert a function in a module (nova.scheduler.manager.py) whit the decorator, but also it didn't work (i insert a simple print to file to test it).

Maybe it is a really simple thing, but i'm totally new to python and openstack developing, and can't find an answer on the documentation.

Question information

Language:
English Edit question
Status:
Solved
For:
OpenStack Compute (nova) Edit question
Assignee:
No assignee Edit question
Solved by:
Sandy Walsh
Solved:
Last query:
Last reply:
Revision history for this message
Best Sandy Walsh (sandy-walsh) said :
#1
Revision history for this message
Jacopo (jacopo85) said :
#2

It works perfectly, thank you so much.

Can i ask you one more thing here? (Maybe i have to open another topic; if so, i'll do ti)

I have to retrieve information about hosts and instances. For the hosts i find something in nova.scheduler.host_manager.py, and for the instances i find it in nova.copute.api.py. What i want to know is if it's the correct way to retreive information, or i have to acces to the db with the nova.db module

Revision history for this message
Jacopo (jacopo85) said :
#3

Thanks Sandy Walsh, that solved my question.

Revision history for this message
Sandy Walsh (sandy-walsh) said :
#4

Nova doesn't use a db service. Instead it's just a library that all modules (except Compute) can access directly.

Look at nova.db.api for the function you need. It'll all be in there.

Glad it worked for you!

-S