[PATCH 12/17] Detect existing btrfs snapshots.
David Lehman
dlehman at redhat.com
Thu Jun 5 16:47:32 UTC 2014
---
blivet/devicetree.py | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index 94dab1d..288dc4a 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, LVMSnapShotDevice, LVMThinLogicalVolumeDevice, LVMThinSnapShotDevice, LVMThinPoolDevice, LVMVolumeGroupDevice, MDRaidArrayDevice, MultipathDevice, NoDevice, OpticalDevice, PartitionDevice, ZFCPDiskDevice, devicePathToName, iScsiDiskDevice
+from .devices import BTRFSDevice, BTRFSSubVolumeDevice, BTRFSSnapShotDevice, BTRFSVolumeDevice, DASDDevice, DMDevice, DMLinearDevice, DMRaidArrayDevice, DiskDevice, FcoeDiskDevice, FileDevice, LoopDevice, LUKSDevice, LVMLogicalVolumeDevice, LVMSnapShotDevice, LVMThinLogicalVolumeDevice, LVMThinSnapShotDevice, LVMThinPoolDevice, LVMVolumeGroupDevice, MDRaidArrayDevice, MultipathDevice, NoDevice, OpticalDevice, PartitionDevice, ZFCPDiskDevice, devicePathToName, iScsiDiskDevice
from .deviceaction import ActionCreateDevice, ActionDestroyDevice, action_type_from_string, action_object_from_string
from . import formats
from .formats import getFormat
@@ -1714,6 +1714,8 @@ class DeviceTree(object):
self._addDevice(btrfs_dev)
if not btrfs_dev.subvolumes:
+ snapshots = btrfs_dev.listSubVolumes(snapshotsOnly=True)
+ snapshot_ids = [s["id"] for s in snapshots]
for subvol_dict in btrfs_dev.listSubVolumes():
vol_id = subvol_dict["id"]
vol_path = subvol_dict["path"]
@@ -1737,11 +1739,16 @@ class DeviceTree(object):
fmt = getFormat("btrfs", device=btrfs_dev.path, exists=True,
volUUID=btrfs_dev.format.volUUID,
mountopts="subvol=%s" % vol_path)
- subvol = BTRFSSubVolumeDevice(vol_path,
- vol_id=vol_id,
- fmt=fmt,
- parents=[parent],
- exists=True)
+ if vol_id in snapshot_ids:
+ device_class = BTRFSSnapShotDevice
+ else:
+ device_class = BTRFSSubVolumeDevice
+
+ subvol = device_class(vol_path,
+ vol_id=vol_id,
+ fmt=fmt,
+ parents=[parent],
+ exists=True)
self._addDevice(subvol)
def handleUdevDeviceFormat(self, info, device):
--
1.9.0
More information about the anaconda-patches
mailing list