summaryrefslogtreecommitdiffstats
path: root/pyanaconda/storage/__init__.py
diff options
context:
space:
mode:
authorDavid Lehman <dlehman@redhat.com>2012-10-03 17:43:23 -0500
committerDavid Lehman <dlehman@redhat.com>2012-10-08 16:31:08 -0500
commit9b20ceadb432ef37774b68f5cb5772012b39f60e (patch)
treeff132ffca7d806f51265da8a81534226661f1584 /pyanaconda/storage/__init__.py
parent431d24f673d66bbfb0ab9fd140f8f6fd28d9a559 (diff)
downloadanaconda-9b20ceadb432ef37774b68f5cb5772012b39f60e.tar.gz
anaconda-9b20ceadb432ef37774b68f5cb5772012b39f60e.tar.xz
anaconda-9b20ceadb432ef37774b68f5cb5772012b39f60e.zip
Add encryption support to the device factory classes.
Diffstat (limited to 'pyanaconda/storage/__init__.py')
-rw-r--r--pyanaconda/storage/__init__.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/pyanaconda/storage/__init__.py b/pyanaconda/storage/__init__.py
index 8239e6f36..19d76e376 100644
--- a/pyanaconda/storage/__init__.py
+++ b/pyanaconda/storage/__init__.py
@@ -1866,7 +1866,7 @@ class Storage(object):
# set up new members as needed to accommodate the device
new_members = []
for disk in add_disks:
- if factory.encrypted:
+ if factory.encrypted and factory.encrypt_members:
luks_format = factory.member_format
member_format = "luks"
else:
@@ -1880,7 +1880,7 @@ class Storage(object):
continue
self.createDevice(member)
- if factory.encrypted:
+ if factory.encrypted and factory.encrypt_members:
fmt = getFormat(luks_format)
member = LUKSDevice("luks-%s" % member.name,
parents=[member], format=fmt)
@@ -2109,6 +2109,14 @@ class Storage(object):
raise(e)
elif factory.new_device_attr:
log.debug("creating new device")
+ if factory.encrypted and factory.encrypt_leaves:
+ luks_fmt_type = fstype
+ luks_fmt_args = fmt_args
+ luks_mountpoint = mountpoint
+ fstype = "luks"
+ mountpoint = None
+ fmt_args = {}
+
try:
device = factory.new_device(parents=parents,
size=size,
@@ -2159,6 +2167,14 @@ class Storage(object):
self.__cleanUpMemberDevices(members)
raise
+ if factory.encrypted and factory.encrypt_leaves:
+ fmt = getFormat(luks_fmt_type,
+ mountpoint=luks_mountpoint,
+ **luks_fmt_args)
+ luks_device = LUKSDevice("luks-" + device.name,
+ parents=[device], format=fmt)
+ self.createDevice(luks_device)
+
def copy(self):
new = copy.deepcopy(self)
# go through and re-get partedPartitions from the disks since they
@@ -3131,6 +3147,8 @@ class DeviceFactory(object):
new_container_attr = None # name of Storage method to create a container
new_device_attr = None # name of Storage method to create a device
container_list_attr = None # name of Storage attribute to list containers
+ encrypt_members = False
+ encrypt_leaves = True
def __init__(self, storage, size, disks, raid_level, encrypted):
self.storage = storage # the Storage instance
@@ -3224,6 +3242,8 @@ class BTRFSFactory(DeviceFactory):
new_container_attr = "newBTRFS"
new_device_attr = "newBTRFSSubVolume"
container_list_attr = "btrfsVolumes"
+ encrypt_members = True
+ encrypt_leaves = False
def __init__(self, storage, size, disks, raid_level, encrypted):
super(BTRFSFactory, self).__init__(storage, size, disks, raid_level,