[openstack-dev] [nova] nova boot from image created volume

李田清 tianqing at unitedstack.com
Fri Apr 7 03:07:16 UTC 2017


Thanks Matt.






 
 
------------------ Original ------------------
From:  "Matt Riedemann"<mriedemos at gmail.com>;
Date:  Fri, Apr 7, 2017 00:18 AM
To:  "openstack-dev"<openstack-dev at lists.openstack.org>; 

Subject:  Re: [openstack-dev] [nova] nova boot from image created volume

 
On 4/6/2017 10:05 AM, Jay Pipes wrote:
>> jaypipes at serialcoder:~/src/git.openstack.org/openstack/nova/nova$
>> ack-grep --ignore-dir tests --ignore-dir locale "volume_api.create"
>> compute/api.py
>> 2982:                snapshot = self.volume_api.create_snapshot_force(
>>
>> api/openstack/compute/volumes.py
>> 185:            new_volume = self.volume_api.create(
>> 582:            create_func = self.volume_api.create_snapshot_force
>> 584:            create_func = self.volume_api.create_snapshot
>>
>> virt/block_device.py
>> 63:    :returns: The availability_zone value to pass to volume_api.create
>> 487:            vol = volume_api.create(context, self.volume_size, '',
>> '',
>> 508:            vol = volume_api.create(context, self.volume_size,
>> 530:            vol = volume_api.create(context, self.volume_size,
>> vol_name, '',
>
> Best,
> -jay
>
> On 04/06/2017 03:29 AM, 李田清 wrote:
>> Hello,
>>     If we use nova boot from image and created volume, i think the
>> nova will
>>     use volume/cinder.py:create to create volume. But after insert pdb,
>> i do not find
>>     the specific code of line to call the create. Can someone help me to
>> point out the
>>     code of the line? Thanks a lot.
>>
>>
>> __________________________________________________________________________
>>
>> OpenStack Development Mailing List (not for usage questions)
>> Unsubscribe:
>> OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>>
>
> __________________________________________________________________________
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

For the case you're looking for, the volume is created here:

https://github.com/openstack/nova/blob/8d9bf947a4c8654a30e016a5d95d9bec55447506/nova/virt/block_device.py#L508

That happens when the compute manager is preparing block devices to 
attach to the instance while building it on the compute host.

After the volume is created and nova gets the volume ID back, we wait 
for it to be available before we can attach it:

https://github.com/openstack/nova/blob/8d9bf947a4c8654a30e016a5d95d9bec55447506/nova/virt/block_device.py#L512

Which uses this function passed in from the compute manager (yes, it's 
gross tight coupling):

https://github.com/openstack/nova/blob/8d9bf947a4c8654a30e016a5d95d9bec55447506/nova/compute/manager.py#L1221

And finally it attaches the volume to the instance via a call to the 
parent class:

https://github.com/openstack/nova/blob/8d9bf947a4c8654a30e016a5d95d9bec55447506/nova/virt/block_device.py#L516

I hope this helps. It only took me 4 years to memorize the flow. :)






-- 

Thanks,

Matt

__________________________________________________________________________
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20170407/33796cd2/attachment-0001.html>


More information about the OpenStack-dev mailing list