[blivet] Allow specifying which swaps should appear in fstab
David Lehman
dlehman at redhat.com
Fri Oct 4 16:19:31 UTC 2013
On Thu, 2013-10-03 at 16:04 +0200, Vratislav Podzimek wrote:
> Not all swaps should be used by the system in some cases.
You didn't change the FSSet code to use the surrounding coding style.
>
> Related: rhbz#1011391
> Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
> ---
> blivet/__init__.py | 57 +++++++++++++++++++++++++++++++++++++++++++++++++-
> blivet/partitioning.py | 8 +++++++
> 2 files changed, 64 insertions(+), 1 deletion(-)
>
> diff --git a/blivet/__init__.py b/blivet/__init__.py
> index 8f6e82a..538c1a1 100644
> --- a/blivet/__init__.py
> +++ b/blivet/__init__.py
> @@ -2120,6 +2120,30 @@ class Blivet(object):
> parent = getattr(self.ksdata, list_attr)
> parent.dataList().append(data)
>
> + def addFstabSwap(self, device):
> + """
> + Add swap device to the list of swaps that should appear in the fstab.
> +
> + """
> +
> + self.fsset.add_fstab_swap(device)
> +
> + def removeFstabSwap(self, device):
> + """
> + Remove swap device from the list of swaps that should appear in the fstab.
> +
> + """
> +
> + self.fsset.remove_fstab_swap(device)
> +
> + def setFstabSwaps(self, devices):
> + """
> + Set swap devices that should appear in the fstab.
> +
> + """
> +
> + self.fsset.set_fstab_swaps(devices)
> +
> def mountExistingSystem(fsset, rootDevice,
> allowDirty=None, dirtyCB=None,
> readOnly=None):
> @@ -2328,6 +2352,7 @@ class FSSet(object):
> self._usb = None
> self._selinux = None
> self._run = None
> + self._fstab_swaps = set()
> self.preserveLines = [] # lines we just ignore and preserve
>
> @property
> @@ -2840,7 +2865,10 @@ class FSSet(object):
>
> devices = sorted(self.mountpoints.values(),
> key=lambda d: d.format.mountpoint)
> - devices += self.swapDevices
> +
> + # XXX: filter swaps only in installer mode?
> + devices += [dev for dev in self.swapDevices
> + if dev in self._fstab_swaps]
> netdevs = self.devicetree.getDevicesByInstance(NetworkStorageDevice)
> for device in devices:
> # why the hell do we put swap in the fstab, anyway?
> @@ -2890,6 +2918,33 @@ class FSSet(object):
>
> return fstab
>
> + def addFstabSwap(self, device):
> + """
> + Add swap device to the list of swaps that should appear in the fstab.
> +
> + """
> +
> + self._fstab_swaps.add(device)
> +
> + def removeFstabSwap(self, device):
> + """
> + Remove swap device from the list of swaps that should appear in the fstab.
> +
> + """
> +
> + try:
> + self._fstab_swaps.remove(device)
> + except KeyError:
> + pass
> +
> + def setFstabSwaps(self, devices):
> + """
> + Set swap devices that should appear in the fstab.
> +
> + """
> +
> + self._fstab_swaps = set(devices)
> +
> def getReleaseString():
> relName = None
> relVer = None
> diff --git a/blivet/partitioning.py b/blivet/partitioning.py
> index abaf1b3..2740848 100644
> --- a/blivet/partitioning.py
> +++ b/blivet/partitioning.py
> @@ -302,6 +302,9 @@ def doAutoPartition(storage, data):
> if not storage.doAutoPart:
> return
>
> + old_swaps = set(dev for dev in storage.devicetree.devices
> + if dev.format.type == "swap")
> +
> if not storage.partitioned:
> raise NoDisksError(_("No usable disks selected"))
>
> @@ -325,6 +328,11 @@ def doAutoPartition(storage, data):
>
> storage.setUpBootLoader()
>
> + new_swaps = (dev for dev in storage.devicetree.devices
> + if dev.format.type == "swap" and dev not in old_swaps)
> +
> + storage.setFstabSwaps(new_swaps)
> +
> # now do a full check of the requests
> (errors, warnings) = storage.sanityCheck()
> for error in errors:
More information about the anaconda-patches
mailing list