[master 9/13] Add availability checking to non-FS formats.
mulkieran
installerbot-noreply at redhat.com
Wed Apr 22 13:32:17 UTC 2015
From: mulhern <amulhern at redhat.com>
Related: #12
Make use of the availability information in method formattable,
controllable, supported, destroyable.
Signed-off-by: mulhern <amulhern at redhat.com>
---
blivet/formats/__init__.py | 16 ++++++++++++++++
blivet/formats/luks.py | 18 ++++++++++++++++++
blivet/formats/lvmpv.py | 14 ++++++++++++++
blivet/formats/mdraid.py | 14 ++++++++++++++
blivet/formats/swap.py | 14 ++++++++++++++
5 files changed, 76 insertions(+)
diff --git a/blivet/formats/__init__.py b/blivet/formats/__init__.py
index ba15c62..4ec93c4 100644
--- a/blivet/formats/__init__.py
+++ b/blivet/formats/__init__.py
@@ -438,6 +438,12 @@ def _postDestroy(self, **kwargs):
self.exists = False
self.notifyKernel()
+ @property
+ def destroyable(self):
+ """ Do we have the facilities to destroy a format of this type. """
+ # assumes wipefs is always available
+ return True
+
def setup(self, **kwargs):
""" Activate the formatting.
@@ -459,6 +465,16 @@ def setup(self, **kwargs):
self._setup(**kwargs)
self._postSetup(**kwargs)
+ @property
+ def controllable(self):
+ """ Are external utilities available to allow this format to be both
+ setup and teared down.
+
+ :returns: True if this format can be set up, otherwise False
+ :rtype: bool
+ """
+ return True
+
def _preSetup(self, **kwargs):
""" Return True if setup should proceed. """
if not self.exists:
diff --git a/blivet/formats/luks.py b/blivet/formats/luks.py
index 2d1353f..5fd116c 100644
--- a/blivet/formats/luks.py
+++ b/blivet/formats/luks.py
@@ -29,6 +29,7 @@
from . import DeviceFormat, register_device_format
from ..flags import flags
from ..i18n import _, N_
+from ..tasks import availability
import logging
log = logging.getLogger("blivet")
@@ -44,6 +45,7 @@ class LUKS(DeviceFormat):
_linuxNative = True # for clearpart
_packages = ["cryptsetup"] # required packages
_minSize = crypto.LUKS_METADATA_SIZE
+ _plugin = availability.BLOCKDEV_CRYPTO_PLUGIN
def __init__(self, **kwargs):
"""
@@ -150,6 +152,18 @@ def hasKey(self):
(self._key_file and os.access(self._key_file, os.R_OK)))
@property
+ def formattable(self):
+ return super(LUKS, self).formattable and self._plugin.available
+
+ @property
+ def supported(self):
+ return super(LUKS, self).supported and self._plugin.available
+
+ @property
+ def controllable(self):
+ return super(LUKS, self).controllable and self._plugin.available
+
+ @property
def configured(self):
""" To be ready we need a key or passphrase and a map name. """
return self.hasKey and self.mapName
@@ -203,6 +217,10 @@ def _postCreate(self, **kwargs):
self.mapName = "luks-%s" % self.uuid
@property
+ def destroyable(self):
+ return self._plugin.available
+
+ @property
def keyFile(self):
""" Path to key file to be used in /etc/crypttab """
return self._key_file
diff --git a/blivet/formats/lvmpv.py b/blivet/formats/lvmpv.py
index 3c9e5c0..c834d03 100644
--- a/blivet/formats/lvmpv.py
+++ b/blivet/formats/lvmpv.py
@@ -27,6 +27,7 @@
from ..storage_log import log_method_call
from parted import PARTITION_LVM
from ..devicelibs import lvm
+from ..tasks import availability
from ..i18n import N_
from ..size import Size
from . import DeviceFormat, register_device_format
@@ -47,6 +48,7 @@ class LVMPhysicalVolume(DeviceFormat):
_minSize = lvm.LVM_PE_SIZE * 2 # one for metadata and one for data
_packages = ["lvm2"] # required packages
_ksMountpoint = "pv."
+ _plugin = availability.BLOCKDEV_LVM_PLUGIN
def __init__(self, **kwargs):
"""
@@ -95,6 +97,14 @@ def dict(self):
"peStart": self.peStart, "dataAlignment": self.dataAlignment})
return d
+ @property
+ def formattable(self):
+ return super(LVMPhysicalVolume, self).formattable and self._plugin.available
+
+ @property
+ def supported(self):
+ return super(LVMPhysicalVolume, self).supported and self._plugin.available
+
def _create(self, **kwargs):
log_method_call(self, device=self.device,
type=self.type, status=self.status)
@@ -122,6 +132,10 @@ def _destroy(self, **kwargs):
blockdev.lvm_pvscan(self.device)
@property
+ def destroyable(self):
+ return self._plugin.available
+
+ @property
def status(self):
# XXX hack
return (self.exists and self.vgName and
diff --git a/blivet/formats/mdraid.py b/blivet/formats/mdraid.py
index 1c7a02a..4590393 100644
--- a/blivet/formats/mdraid.py
+++ b/blivet/formats/mdraid.py
@@ -27,6 +27,7 @@
from . import DeviceFormat, register_device_format
from ..flags import flags
from ..i18n import N_
+from ..tasks import availability
import logging
log = logging.getLogger("blivet")
@@ -43,6 +44,7 @@ class MDRaidMember(DeviceFormat):
_linuxNative = True # for clearpart
_packages = ["mdadm"] # required packages
_ksMountpoint = "raid."
+ _plugin = availability.BLOCKDEV_MDRAID_PLUGIN
def __init__(self, **kwargs):
"""
@@ -74,10 +76,22 @@ def dict(self):
d.update({"mdUUID": self.mdUuid, "biosraid": self.biosraid})
return d
+ @property
+ def formattable(self):
+ return super(MDRaidMember, self).formattable and self._plugin.available
+
+ @property
+ def supported(self):
+ return super(MDRaidMember, self).supported and self._plugin.available
+
def _destroy(self, **kwargs):
blockdev.md_destroy(self.device)
@property
+ def destroyable(self):
+ return self._plugin.available
+
+ @property
def status(self):
# XXX hack -- we don't have a nice way to see if the array is active
return False
diff --git a/blivet/formats/swap.py b/blivet/formats/swap.py
index 4eab044..4983073 100644
--- a/blivet/formats/swap.py
+++ b/blivet/formats/swap.py
@@ -22,6 +22,7 @@
from parted import PARTITION_SWAP, fileSystemType
from ..storage_log import log_method_call
+from ..tasks import availability
from . import DeviceFormat, register_device_format
from ..size import Size
from gi.repository import BlockDev as blockdev
@@ -40,6 +41,7 @@ class SwapSpace(DeviceFormat):
_formattable = True # can be formatted
_supported = True # is supported
_linuxNative = True # for clearpart
+ _plugin = availability.BLOCKDEV_SWAP_PLUGIN
#see rhbz#744129 for details
_maxSize = Size("128 GiB")
@@ -80,6 +82,18 @@ def dict(self):
d.update({"priority": self.priority, "label": self.label})
return d
+ @property
+ def formattable(self):
+ return super(SwapSpace, self).formattable and self._plugin.available
+
+ @property
+ def supported(self):
+ return super(SwapSpace, self).supported and self._plugin.available
+
+ @property
+ def controllable(self):
+ return super(SwapSpace, self).controllable and self._plugin.available
+
def labeling(self):
"""Returns True as mkswap can write a label to the swap space."""
return True
--
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/5ae0fd372f64dd438dd04f518f2bc4659750791e
More information about the anaconda-patches
mailing list