Mitaka nova/cinder LVM的代码的分布 (nova-13.0.0 cinder-8.0.0)
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是在nova目录下: [root@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)
以及cinder的cinder\brick\local_dev]\lvm.py, brick的代码为什么不放在cinder\volume\drivers\lvm.py里面? def create_volume(self, name, size_str, lv_type='default', mirror_count=0): """Creates a logical volume on the object's VG.
:param name: Name to use when creating Logical Volume :param size_str: Size to use when creating Logical Volume :param lv_type: Type of Volume (default or thin) :param mirror_count: Use LVM mirroring with specified count
"""
if lv_type == 'thin': pool_path = '%s/%s' % (self.vg_name, self.vg_thin_pool) cmd = LVM.LVM_CMD_PREFIX + ['lvcreate', '-T', '-V', size_str, '-n', name, pool_path] else: cmd = LVM.LVM_CMD_PREFIX + ['lvcreate', '-n', name, self.vg_name, '-L', size_str]
participants (1)
-
wk