OpenStack-Cinder: create volume data/code flow
July 16, 2013 3 Comments
Hello Folks,
I guess, its been quite some time since my last post. Actually, didn’t get time some free time cover up this post.
Thanks to dear friend Rahul Updadhyaya, he has pull me out today to write this up 🙂
Apologize for not putting diagrams right now, will work on it sooner.
This post is about cinder create volume data/code flow.
Example: cinder create 1 –display-name firstvol –volume-type FCVolumeType
1. Start with calling the cinder api:
File: cinder/api/v1/volumes.py
Method: def create(self, req, body): #validates cinder api arguments.
2. Above method calls “cinder.volume.api.API”, taken from “volume_api_class” a flag from cinder.conf.
self.volume_api.create() # here self.volume_api created from “cinder.volume.api.API”
File: cinder.volume.api.API
Method: def create(self….)
This function store necessary data into database with volume status as ‘creating’.
3. Above method further calls cinder schedule.
self.scheduler_rpcapi.create_volume() # Making asynchronous cast on cinder-scheduler
4. Next asynchronous cast makes it to the cinder/scheduler/manager.py def create_volume()
this in turn calls: self.driver.schedule_create_volume() #here, the self.driver points to scheduler_driver flag in cinder.conf
Now, this could be SimpleScheduler or FilterScheduler (in case of multi-backend)
5. Incase of SimpleScheduler, above method calls
File: cinder/scheduler/simple.py
Method: def schedule_create_volume()
above method next calls: self.volume_rpcapi.create_volume() # which makes asynchronous cast on selected host
Here, you can view host info with #cinder-manger host list
6. Message is reached to volume/manager.py
File: cinder/volume/manager.py
Method: def create_volume() # calls _create_volume() and make call to volume driver’s create_volume()
self.driver.create_volume() # driver is chosen with volume_driver flag from cinder.conf, this return metadata about volume
And volume status is changed from ‘creating’ to ‘available’.