dmcrypt_map is idempotent, it does not matter that it is called multiple
times when activating or preparing a device. It is however important to
not cryptsetup remove the device after preparing it because partprobe
may not re-send another add udev event to luksOpen / create it again.
On Ubuntu 14.04, no extra add udev event is sent after the partition was
acknowledged by the kernel. On CentOS 7.2 an extra udev event is sent
for each existing partition, regardless of what the kernel already
knows.
The format() function is just a call to map() to limit the extent of the
refactor. The dmcrypt_map/unmap functions should be refactored into a
device class and the format() function can then be made more specific.
Signed-off-by: Loic Dachary <loic@dachary.org>
def format(self):
self.setup_crypt()
self.map()
- self.unmap()
class DevicePartitionCryptPlain(DevicePartitionCrypt):
if isinstance(partition, DevicePartitionCrypt):
partition.format()
+ partition.map()
command_check_call(
[