[blivet] Allow specifying which swaps should appear in fstab
Vratislav Podzimek
vpodzime at redhat.com
Wed Oct 2 13:21:23 UTC 2013
Not all swaps should be used by the system in some cases.
Related: rhbz#1011391
Signed-off-by: Vratislav Podzimek <vpodzime at 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:
--
1.7.11.7
More information about the anaconda-patches
mailing list