On Wed, 2013-10-02 at 15:21 +0200, Vratislav Podzimek wrote:
Not all swaps should be used by the system in some cases.
I'd rather if you specified the swaps as devices instead of formats. Also, it would be nice if you could conform the new methods to the (admittedly ugly) style of the surrounding code.
David
Related: rhbz#1011391
Signed-off-by: Vratislav Podzimek vpodzime@redhat.com
blivet/__init__.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ blivet/partitioning.py | 4 ++++ 2 files changed, 60 insertions(+)
diff --git a/blivet/__init__.py b/blivet/__init__.py index 8f6e82a..2c39552 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 add_fstab_swap(self, fmt):
"""Add swap format to the list of swaps that should appear in the fstab."""self.fsset.add_fstab_swap(fmt)- def remove_fstab_swap(self, fmt):
"""Remove swap format from the list of swaps that should appear in the fstab."""self.fsset.remove_fstab_swap(fmt)- def set_fstab_swaps(self, fmts):
"""Set swap formats that should appear in the fstab."""self.fsset.set_fstab_swaps(fmts)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_lines = set() self.preserveLines = [] # lines we just ignore and preserve@property
@@ -2855,6 +2880,10 @@ class FSSet(object): if fstype == "swap": mountpoint = "swap" options = device.format.options
if device.format not in self._fstab_swaps:# swap that shouldn't appear in fstab# XXX: do this only in the installer mode?continue else: mountpoint = device.format.mountpoint options = device.format.options@@ -2890,6 +2919,33 @@ class FSSet(object):
return fstab
- def add_fstab_swap(self, fmt):
"""Add swap format to the list of swaps that should appear in the fstab."""self._fstab_swaps.add(fmt)- def remove_fstab_swap(self, fmt):
"""Remove swap format from the list of swaps that should appear in the fstab."""try:self._fstab_swaps.remove(fmt)except KeyError:pass- def set_fstab_swaps(self, fmts):
"""Set swap formats that should appear in the fstab."""self._fstab_swaps = set(fmts)def getReleaseString(): relName = None relVer = None diff --git a/blivet/partitioning.py b/blivet/partitioning.py index abaf1b3..338a31a 100644 --- a/blivet/partitioning.py +++ b/blivet/partitioning.py @@ -325,6 +325,10 @@ def doAutoPartition(storage, data):
storage.setUpBootLoader()
- new_swaps = (action.format for action in storage.devicetree.findActions(type="create")
if action.format.type == "swap")- storage.set_fstab_swaps(new_swaps)
- # now do a full check of the requests (errors, warnings) = storage.sanityCheck() for error in errors: