[Openstack-zh] Mitaka nova/cinder LVM的代码的分布 (nova-13.0.0 cinder-8.0.0)

wk 304702903 at qq.com
Mon Aug 22 08:31:16 UTC 2016


hi:
    请教个cinder的问题。
    使用本地的lvm做cinder的物理存储。猜测lvm相关的代码在cinder-8.0.0\cinder\volume\drivers\lvm.py里面。
但是没有调用lvm的lvcreate命令:
    def _create_volume(self, name, size, lvm_type, mirror_count, vg=None):
        vg_ref = self.vg
        if vg is not None:
            vg_ref = vg


        vg_ref.create_volume(name, size, lvm_type, mirror_count)



真正干活的lvcreate是在:
[root at opentest stack]# vi ./nova/nova/virt/libvirt/storage/lvm.py
from oslo_concurrency import processutils
from oslo_log import log as logging
from oslo_utils import units
import six


import nova.conf
from nova import exception
from nova.i18n import _
from nova.i18n import _LW
from nova.virt.libvirt import utils


CONF = nova.conf.CONF
LOG = logging.getLogger(__name__)


def create_volume(vg, lv, size, sparse=False):
    """Create LVM image.
    Creates a LVM image with given size.
    :param vg: existing volume group which should hold this image
    :param lv: name for this image (logical volume)
    :size: size of image in bytes
    :sparse: create sparse logical volume
    """
    if sparse:
        preallocated_space = 64 * units.Mi
        check_size(vg, lv, preallocated_space)
        if free_space < size:
            LOG.warning(_LW('Volume group %(vg)s will not be able'
                         ' to hold sparse volume %(lv)s.'
                         ' Virtual volume size is %(size)d bytes,'
                         ' but free space on volume group is'
                         ' only %(free_space)db.'),
                        {'vg': vg,
                         'free_space': free_space,
                         'size': size,
                         'lv': lv})


        cmd = ('lvcreate', '-L', '%db' % preallocated_space,
                '--virtualsize', '%db' % size, '-n', lv, vg)


很奇怪啊,难道nova使用lvm时,不是cinder来干活么?
这与Laying Cinder Block (Volumes) In OpenStack, Part 1: The Basics很比一致啊,看里面的图,cinder的绿线是做管理命令。https://cloudarchitectmusings.com/2013/11/18/laying-cinder-block-volumes-in-openstack-part-1-the-basics/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-zh/attachments/20160822/1f1d99e5/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: B3A94E1C at E94F575D.54B8BA57.jpg
Type: image/jpeg
Size: 92047 bytes
Desc: not available
URL: <http://lists.openstack.org/pipermail/openstack-zh/attachments/20160822/1f1d99e5/attachment-0001.jpg>


More information about the Openstack-zh mailing list