[PATCH 10/17] Use LVMSnapshotDevice when populating the devicetree.
David Lehman
dlehman at redhat.com
Mon Jun 9 16:53:03 UTC 2014
On 06/06/2014 02:06 AM, Vratislav Podzimek wrote:
> On Thu, 2014-06-05 at 11:47 -0500, David Lehman wrote:
>> ---
>> blivet/devicetree.py | 38 ++++++++++++++++++++++++--------------
>> 1 file changed, 24 insertions(+), 14 deletions(-)
>>
>> diff --git a/blivet/devicetree.py b/blivet/devicetree.py
>> index ea82d89..94dab1d 100644
>> --- a/blivet/devicetree.py
>> +++ b/blivet/devicetree.py
>> @@ -28,7 +28,7 @@ import pprint
>> import copy
>>
>> from .errors import CryptoError, DeviceError, DeviceTreeError, DiskLabelCommitError, DMError, FSError, InvalidDiskLabelError, LUKSError, MDRaidError, StorageError
>> -from .devices import BTRFSDevice, BTRFSSubVolumeDevice, BTRFSVolumeDevice, DASDDevice, DMDevice, DMLinearDevice, DMRaidArrayDevice, DiskDevice, FcoeDiskDevice, FileDevice, LoopDevice, LUKSDevice, LVMLogicalVolumeDevice, LVMThinLogicalVolumeDevice, LVMThinPoolDevice, LVMVolumeGroupDevice, MDRaidArrayDevice, MultipathDevice, NoDevice, OpticalDevice, PartitionDevice, ZFCPDiskDevice, devicePathToName, iScsiDiskDevice
>> +from .devices import BTRFSDevice, BTRFSSubVolumeDevice, BTRFSVolumeDevice, DASDDevice, DMDevice, DMLinearDevice, DMRaidArrayDevice, DiskDevice, FcoeDiskDevice, FileDevice, LoopDevice, LUKSDevice, LVMLogicalVolumeDevice, LVMSnapShotDevice, LVMThinLogicalVolumeDevice, LVMThinSnapShotDevice, LVMThinPoolDevice, LVMVolumeGroupDevice, MDRaidArrayDevice, MultipathDevice, NoDevice, OpticalDevice, PartitionDevice, ZFCPDiskDevice, devicePathToName, iScsiDiskDevice
> I believe this deserves to be split into multiple lines.
I didn't add the long line, but I don't mind splitting it up.
>
>> from .deviceaction import ActionCreateDevice, ActionDestroyDevice, action_type_from_string, action_object_from_string
>> from . import formats
>> from .formats import getFormat
>> @@ -1391,6 +1391,7 @@ class DeviceTree(object):
>>
>> lv_class = LVMLogicalVolumeDevice
>> lv_parents = [vg_device]
>> + lv_kwargs = {}
>> name = "%s-%s" % (vg_name, lv_name)
>>
>> if self.getDeviceByName(name):
>> @@ -1407,17 +1408,16 @@ class DeviceTree(object):
>> return
>>
>> if origin_name.endswith("_vorigin]"):
>> - log.info("snapshot volume '%s' has vorigin", name)
>> - vg_device.voriginSnapshots[lv_name] = lv_size
>> - return
>> + lv_kwargs["vorigin"] = True
>> + origin = None
>> + else:
>> + origin_device_name = "%s-%s" % (vg_name, origin_name)
>> + addRequiredLV(origin_device_name,
>> + "failed to locate origin lv")
>> + origin = self.getDeviceByName(origin_device_name)
>>
>> - origin_device_name = "%s-%s" % (vg_name, origin_name)
>> - addRequiredLV(origin_device_name, "failed to locate origin lv")
>> - origin = self.getDeviceByName(origin_device_name)
>> - log.debug("adding %s to %s snapshot total", lv_size,
>> - origin.name)
>> - origin.snapshotSpace += lv_size
>> - return
>> + lv_kwargs["origin"] = origin
>> + lv_class = LVMSnapShotDevice
>> elif lv_attr[0] == 'v':
>> # skip vorigins
>> return
>> @@ -1454,19 +1454,29 @@ class DeviceTree(object):
>> pool_name = lvm.thinlvpoolname(vg_name, lv_name)
>> pool_device_name = "%s-%s" % (vg_name, pool_name)
>> addRequiredLV(pool_device_name, "failed to look up thin pool")
>> - lv_class = LVMThinLogicalVolumeDevice
>> +
>> + origin_name = lvm.lvorigin(vg_name, lv_name)
>> + if origin_name:
>> + origin_device_name = "%s-%s" % (vg_name, origin_name)
>> + addRequiredLV(origin_device_name, "failed to locate origin lv")
>> + origin = self.getDeviceByName(origin_device_name)
>> + lv_kwargs["origin"] = origin
>> + lv_class = LVMThinSnapShotDevice
>> + else:
>> + lv_class = LVMThinLogicalVolumeDevice
>> +
>> lv_parents = [self.getDeviceByName(pool_device_name)]
>> elif lv_name.endswith(']'):
>> # Internal LVM2 device
>> return
>> - elif lv_attr[0] not in '-mMrR':
>> + elif lv_attr[0] not in '-mMrRoO':
> This check deserves a comment.
Fair enough. I'll add one.
More information about the anaconda-patches
mailing list