예제 #1
0
    def create(self, *args, **kwargs):
        """ Create the format. """
        log_method_call(self, device=self.device,
                        type=self.type, status=self.status)
        if not self.hasKey:
            raise LUKSError("luks device has no key/passphrase")

        intf = kwargs.get("intf")
        w = None
        if intf:
            w = intf.waitWindow(_("Formatting"),
                                _("Encrypting %s") % kwargs.get("device",
                                                                self.device))

        try:
            DeviceFormat.create(self, *args, **kwargs)
            crypto.luks_format(self.device,
                             passphrase=self.__passphrase,
                             key_file=self._key_file,
                             cipher=self.cipher,
                             key_size=self.key_size)
        except Exception:
            raise
        else:
            self.uuid = crypto.luks_uuid(self.device)
            self.exists = True
            self.mapName = "luks-%s" % self.uuid
            self.notifyKernel()
        finally:
            if w:
                w.pop()
 def destroy(self, *args, **kwargs):
     log_method_call(self,
                     device=self.device,
                     type=self.type,
                     status=self.status)
     raise MultipathMemberError(
         "destruction of multipath members is non-sense")
    def create(self, *args, **kwargs):
        """ Create the format. """
        log_method_call(self, device=self.device,
                        type=self.type, status=self.status)
        intf = kwargs.get("intf")
        w = None
        if intf:
            w = intf.progressWindow(_("Formatting"),
                                    _("Creating %(type)s on %(device)s")
                                    % {"type": self.type, "device": self.device},
                                    100, pulse = True)

        try:
            DeviceFormat.create(self, *args, **kwargs)
            # Consider use of -Z|--zero
            # -f|--force or -y|--yes may be required

            # lvm has issues with persistence of metadata, so here comes the
            # hammer...
            DeviceFormat.destroy(self, *args, **kwargs)

            lvm.pvcreate(self.device, progress=w)
        except Exception:
            raise
        else:
            self.exists = True
            self.notifyKernel()
        finally:
            if w:
                w.pop()
예제 #4
0
    def create(self, *args, **kwargs):
        """ Create the device. """
        log_method_call(self, device=self.device,
                        type=self.type, status=self.status)
        intf = kwargs.get("intf")
        force = kwargs.get("force")
        if not force and self.exists:
            raise SwapSpaceError("format already exists")

        if force:
            self.teardown()
        elif self.status:
            raise SwapSpaceError("device exists and is active")

        w = None
        if intf:
            w = intf.progressWindow(_("Formatting"),
                                    _("Creating %(type)s on %(device)s")
                                    % {"type": self.type, "device": kwargs.get("device", self.device)},
                                    100, pulse = True)

        try:
            DeviceFormat.create(self, *args, **kwargs)
            swap.mkswap(self.device, label=self.label, progress=w)
        except Exception:
            raise
        else:
            self.exists = True
            self.notifyKernel()
        finally:
            if w:
                w.pop()
예제 #5
0
    def create(self, *args, **kwargs):
        """ Create the format. """
        log_method_call(self,
                        device=self.device,
                        type=self.type,
                        status=self.status)
        intf = kwargs.get("intf")
        w = None
        if intf:
            w = intf.progressWindow(_("Formatting"),
                                    _("Creating %(type)s on %(device)s") % {
                                        "type": self.type,
                                        "device": self.device
                                    },
                                    100,
                                    pulse=True)

        try:
            DeviceFormat.create(self, *args, **kwargs)
            # Consider use of -Z|--zero
            # -f|--force or -y|--yes may be required

            # lvm has issues with persistence of metadata, so here comes the
            # hammer...
            DeviceFormat.destroy(self, *args, **kwargs)

            lvm.pvcreate(self.device, progress=w)
        except Exception:
            raise
        else:
            self.exists = True
            self.notifyKernel()
        finally:
            if w:
                w.pop()
예제 #6
0
    def create(self, *args, **kwargs):
        """ Create the format. """
        log_method_call(self, device=self.device,
                        type=self.type, status=self.status)
        if not self.hasKey:
            raise LUKSError("luks device has no key/passphrase")

        intf = kwargs.get("intf")
        w = None
        if intf:
            w = intf.waitWindow(_("Formatting"),
                                _("Encrypting %s") % kwargs.get("device",
                                                                self.device))

        try:
            DeviceFormat.create(self, *args, **kwargs)
            crypto.luks_format(self.device,
                             passphrase=self.__passphrase,
                             key_file=self._key_file,
                             cipher=self.cipher,
                             key_size=self.key_size)
        except Exception:
            raise
        else:
            self.uuid = crypto.luks_uuid(self.device)
            self.exists = True
            self.mapName = "luks-%s" % self.uuid
            self.notifyKernel()
        finally:
            if w:
                w.pop()
 def teardown(self, *args, **kwargs):
     """ Close, or tear down, a device. """
     log_method_call(self,
                     device=self.device,
                     type=self.type,
                     status=self.status)
     if not self.exists:
         raise DeviceFormatError("format has not been created")
예제 #8
0
 def probe(self):
     """ Probe for any missing information about this device. """
     log_method_call(self,
                     device=self.device,
                     type=self.type,
                     status=self.status)
     if not self.exists:
         raise PhysicalVolumeError("format has not been created")
 def commitToDisk(self):
     """ Commit the current partition table to disk. """
     log_method_call(self, device=self.device,
                     numparts=len(self.partitions))
     try:
         self.partedDisk.commitToDevice()
     except parted.DiskException as msg:
         raise DiskLabelCommitError(msg)
예제 #10
0
    def teardown(self, *args, **kwargs):
        """ Close, or tear down, a device. """
        log_method_call(self, device=self.device,
                        type=self.type, status=self.status)
        if not self.exists:
            raise SwapSpaceError("format has not been created")

        if self.status:
            swap.swapoff(self.device)
예제 #11
0
    def setup(self, *args, **kwargs):
        log_method_call(self, type=self.mountType, device=self.device,
                        mountpoint=self.mountpoint)
        if not self.mountpoint and "mountpoint" not in kwargs:
            # Since btrfs vols have subvols the format setup is automatic.
            # Don't try to mount it if there's no mountpoint.
            return

        return self.mount(*args, **kwargs)
 def commitToDisk(self):
     """ Commit the current partition table to disk. """
     log_method_call(self,
                     device=self.device,
                     numparts=len(self.partitions))
     try:
         self.partedDisk.commitToDevice()
     except parted.DiskException as msg:
         raise DiskLabelCommitError(msg)
    def create(self, *args, **kwargs):
        log_method_call(self, device=self.device,
                        type=self.type, status=self.status)
        # allow late specification of device path
        device = kwargs.get("device")
        if device:
            self.device = device

        if not os.path.exists(self.device):
            raise FormatCreateError("invalid device specification", self.device)
예제 #14
0
    def teardown(self, *args, **kwargs):
        """ Close, or tear down, the format. """
        log_method_call(self, device=self.device,
                        type=self.type, status=self.status)
        if not self.exists:
            raise LUKSError("format has not been created")

        if self.status:
            log.debug("unmapping %s" % self.mapName)
            crypto.luks_close(self.mapName)
예제 #15
0
    def teardown(self, *args, **kwargs):
        """ Close, or tear down, the format. """
        log_method_call(self, device=self.device,
                        type=self.type, status=self.status)
        if not self.exists:
            raise LUKSError("format has not been created")

        if self.status:
            log.debug("unmapping %s" % self.mapName)
            crypto.luks_close(self.mapName)
 def commit(self):
     """ Commit the current partition table to disk and notify the OS. """
     log_method_call(self, device=self.device,
                     numparts=len(self.partitions))
     try:
         self.partedDisk.commit()
     except parted.DiskException as msg:
         raise DiskLabelCommitError(msg)
     else:
         udev_settle()
예제 #17
0
    def removePassphrase(self, passphrase):
        """ Remove the specified passphrase from the LUKS header. """
        log_method_call(self, device=self.device,
                        type=self.type, status=self.status)
        if not self.exists:
            raise LUKSError("format has not been created")

        crypto.luks_remove_key(self.device,
                             passphrase=self.__passphrase,
                             key_file=self._key_file,
                             del_passphrase=passphrase)
    def setup(self, *args, **kwargs):
        """ Open, or set up, a device. """
        log_method_call(self, device=self.device,
                        type=self.type, status=self.status)
        if not self.exists:
            raise DeviceFormatError("format has not been created")

        if self.status:
            return

        DeviceFormat.setup(self, *args, **kwargs)
예제 #19
0
    def removePassphrase(self, passphrase):
        """ Remove the specified passphrase from the LUKS header. """
        log_method_call(self, device=self.device,
                        type=self.type, status=self.status)
        if not self.exists:
            raise LUKSError("format has not been created")

        crypto.luks_remove_key(self.device,
                             passphrase=self.__passphrase,
                             key_file=self._key_file,
                             del_passphrase=passphrase)
 def commit(self):
     """ Commit the current partition table to disk and notify the OS. """
     log_method_call(self,
                     device=self.device,
                     numparts=len(self.partitions))
     try:
         self.partedDisk.commit()
     except parted.DiskException as msg:
         raise DiskLabelCommitError(msg)
     else:
         udev_settle()
    def notifyKernel(self):
        log_method_call(self, device=self.device, type=self.type)
        if not self.device:
            return

        if self.device.startswith("/dev/mapper/"):
            try:
                name = dm_node_from_name(os.path.basename(self.device))
            except Exception, e:
                log.warning("failed to get dm node for %s" % self.device)
                return
    def probe(self):
        """ Probe for any missing information about this format. """
        log_method_call(self, device=self.device,
                        type=self.type, status=self.status)
        if not self.exists:
            raise MDMemberError("format does not exist")

        info = mdraid.mdexamine(self.device)
        if self.uuid is None:
            self.uuid = info['uuid']
        if self.raidMinor is None:
            self.raidMinor = info['mdMinor']
    def destroy(self, *args, **kwargs):
        """ Wipe the disklabel from the device. """
        log_method_call(self, device=self.device,
                        type=self.type, status=self.status)
        if not self.exists:
            raise DeviceFormatError("format does not exist")

        if not os.access(self.device, os.W_OK):
            raise DeviceFormatError("device path does not exist")

        self.partedDevice.clobber()
        self.exists = False
    def notifyKernel(self):
        log_method_call(self, device=self.device,
                        type=self.type)
        if not self.device:
            return

        if self.device.startswith("/dev/mapper/"):
            try:
                name = dm_node_from_name(os.path.basename(self.device))
            except Exception, e:
                log.warning("failed to get dm node for %s" % self.device)
                return
    def create(self, *args, **kwargs):
        log_method_call(self,
                        device=self.device,
                        type=self.type,
                        status=self.status)
        # allow late specification of device path
        device = kwargs.get("device")
        if device:
            self.device = device

        if not os.path.exists(self.device):
            raise FormatCreateError("invalid device specification",
                                    self.device)
    def setup(self, *args, **kwargs):
        """ Open, or set up, a device. """
        log_method_call(self,
                        device=self.device,
                        type=self.type,
                        status=self.status)
        if not self.exists:
            raise DeviceFormatError("format has not been created")

        if self.status:
            return

        DeviceFormat.setup(self, *args, **kwargs)
예제 #27
0
    def setup(self, *args, **kwargs):
        """ Open, or set up, the format. """
        log_method_call(self, device=self.device, mapName=self.mapName,
                        type=self.type, status=self.status)
        if not self.configured:
            raise LUKSError("luks device not configured")

        if self.status:
            return

        DeviceFormat.setup(self, *args, **kwargs)
        crypto.luks_open(self.device, self.mapName,
                       passphrase=self.__passphrase,
                       key_file=self._key_file)
    def destroy(self, *args, **kwargs):
        """ Wipe the disklabel from the device. """
        log_method_call(self,
                        device=self.device,
                        type=self.type,
                        status=self.status)
        if not self.exists:
            raise DeviceFormatError("format does not exist")

        if not os.access(self.device, os.W_OK):
            raise DeviceFormatError("device path does not exist")

        self.partedDevice.clobber()
        self.exists = False
예제 #29
0
    def setup(self, *args, **kwargs):
        """ Open, or set up, the format. """
        log_method_call(self, device=self.device, mapName=self.mapName,
                        type=self.type, status=self.status)
        if not self.configured:
            raise LUKSError("luks device not configured")

        if self.status:
            return

        DeviceFormat.setup(self, *args, **kwargs)
        crypto.luks_open(self.device, self.mapName,
                       passphrase=self.__passphrase,
                       key_file=self._key_file)
예제 #30
0
    def addPassphrase(self, passphrase):
        """ Add a new passphrase.

            Add the specified passphrase to an available key slot in the
            LUKS header.
        """
        log_method_call(self, device=self.device,
                        type=self.type, status=self.status)
        if not self.exists:
            raise LUKSError("format has not been created")

        crypto.luks_add_key(self.device,
                          passphrase=self.__passphrase,
                          key_file=self._key_file,
                          new_passphrase=passphrase)
예제 #31
0
    def removeKeyFromFile(self, keyfile):
        """ Remove a key contained in a file.

            Remove key contained in the specified key file from the LUKS
            header.
        """
        log_method_call(self, device=self.device,
                        type=self.type, status=self.status, file=keyfile)
        if not self.exists:
            raise LUKSError("format has not been created")

        crypto.luks_remove_key(self.device,
                             passphrase=self.__passphrase,
                             key_file=self._key_file,
                             del_key_file=keyfile)
예제 #32
0
    def addKeyFromFile(self, keyfile):
        """ Add a new key from a file.

            Add the contents of the specified key file to an available key
            slot in the LUKS header.
        """
        log_method_call(self, device=self.device,
                        type=self.type, status=self.status, file=keyfile)
        if not self.exists:
            raise LUKSError("format has not been created")

        crypto.luks_add_key(self.device,
                          passphrase=self.__passphrase,
                          key_file=self._key_file,
                          new_key_file=keyfile)
예제 #33
0
    def addPassphrase(self, passphrase):
        """ Add a new passphrase.

            Add the specified passphrase to an available key slot in the
            LUKS header.
        """
        log_method_call(self, device=self.device,
                        type=self.type, status=self.status)
        if not self.exists:
            raise LUKSError("format has not been created")

        crypto.luks_add_key(self.device,
                          passphrase=self.__passphrase,
                          key_file=self._key_file,
                          new_passphrase=passphrase)
예제 #34
0
    def removeKeyFromFile(self, keyfile):
        """ Remove a key contained in a file.

            Remove key contained in the specified key file from the LUKS
            header.
        """
        log_method_call(self, device=self.device,
                        type=self.type, status=self.status, file=keyfile)
        if not self.exists:
            raise LUKSError("format has not been created")

        crypto.luks_remove_key(self.device,
                             passphrase=self.__passphrase,
                             key_file=self._key_file,
                             del_key_file=keyfile)
예제 #35
0
    def addKeyFromFile(self, keyfile):
        """ Add a new key from a file.

            Add the contents of the specified key file to an available key
            slot in the LUKS header.
        """
        log_method_call(self, device=self.device,
                        type=self.type, status=self.status, file=keyfile)
        if not self.exists:
            raise LUKSError("format has not been created")

        crypto.luks_add_key(self.device,
                          passphrase=self.__passphrase,
                          key_file=self._key_file,
                          new_key_file=keyfile)
예제 #36
0
    def __init__(self, *args, **kwargs):
        """ Create a SwapSpace instance.

            Keyword Arguments:

                device -- path to the underlying device
                uuid -- this swap space's uuid
                label -- this swap space's label
                priority -- this swap space's priority
                exists -- indicates whether this is an existing format

        """
        log_method_call(self, *args, **kwargs)
        DeviceFormat.__init__(self, *args, **kwargs)

        self.priority = kwargs.get("priority")
        self.label = kwargs.get("label")
예제 #37
0
    def __init__(self, *args, **kwargs):
        """ Create a SwapSpace instance.

            Keyword Arguments:

                device -- path to the underlying device
                uuid -- this swap space's uuid
                label -- this swap space's label
                priority -- this swap space's priority
                exists -- indicates whether this is an existing format

        """
        log_method_call(self, *args, **kwargs)
        DeviceFormat.__init__(self, *args, **kwargs)

        self.priority = kwargs.get("priority")
        self.label = kwargs.get("label")
    def __init__(self, *args, **kwargs):
        """ Create a DeviceFormat instance.

            Keyword Arguments:

                device -- path to the underlying device
                uuid -- this format's UUID
                exists -- indicates whether this is an existing format

            On initialization this format is like DeviceFormat

        """
        log_method_call(self, *args, **kwargs)
        DeviceFormat.__init__(self, *args, **kwargs)

        # Initialize the attribute that will hold the block object.
        self._member = None
    def setup(self, *args, **kwargs):
        log_method_call(self, device=self.device,
                        type=self.type, status=self.status)

        if not self.exists:
            raise FormatSetupError("format has not been created")

        if self.status:
            return

        # allow late specification of device path
        device = kwargs.get("device")
        if device:
            self.device = device

        if not self.device or not os.path.exists(self.device):
            raise FormatSetupError("invalid device specification")
예제 #40
0
    def __init__(self, *args, **kwargs):
        """ Create a DeviceFormat instance.

            Keyword Arguments:

                device -- path to the underlying device
                uuid -- this format's UUID
                exists -- indicates whether this is an existing format

            On initialization this format is like DeviceFormat

        """
        log_method_call(self, *args, **kwargs)
        DeviceFormat.__init__(self, *args, **kwargs)

        # Initialize the attribute that will hold the block object.
        self._member = None
    def __init__(self, *args, **kwargs):
        """ Create a MDRaidMember instance.

            Keyword Arguments:

                device -- path to underlying device
                uuid -- this member device's uuid
                mdUuid -- the uuid of the array this device belongs to
                exists -- indicates whether this is an existing format

        """
        log_method_call(self, *args, **kwargs)
        DeviceFormat.__init__(self, *args, **kwargs)
        self.mdUuid = kwargs.get("mdUuid")
        self.raidMinor = None

        #self.probe()
        self.biosraid = kwargs.get("biosraid")
    def create(self, *args, **kwargs):
        """ Create the device. """
        log_method_call(self, device=self.device,
                        type=self.type, status=self.status)
        if self.exists:
            raise DeviceFormatError("format already exists")

        if self.status:
            raise DeviceFormatError("device exists and is active")

        DeviceFormat.create(self, *args, **kwargs)

        # We're relying on someone having called resetPartedDisk -- we
        # could ensure a fresh disklabel by setting self._partedDisk to
        # None right before calling self.commit(), but that might hide
        # other problems.
        self.commit()
        self.exists = True
예제 #43
0
    def destroy(self, *args, **kwargs):
        """ Destroy the format. """
        log_method_call(self, device=self.device,
                        type=self.type, status=self.status)
        if not self.exists:
            raise PhysicalVolumeError("format has not been created")

        if self.status:
            raise PhysicalVolumeError("device is active")

        # FIXME: verify path exists?
        try:
            lvm.pvremove(self.device)
        except LVMError:
            DeviceFormat.destroy(self, *args, **kwargs)

        self.exists = False
        self.notifyKernel()
    def setup(self, *args, **kwargs):
        log_method_call(self,
                        device=self.device,
                        type=self.type,
                        status=self.status)

        if not self.exists:
            raise FormatSetupError("format has not been created")

        if self.status:
            return

        # allow late specification of device path
        device = kwargs.get("device")
        if device:
            self.device = device

        if not self.device or not os.path.exists(self.device):
            raise FormatSetupError("invalid device specification")
    def destroy(self, *args, **kwargs):
        log_method_call(self, device=self.device,
                        type=self.type, status=self.status)
        try:
            rc = execWithRedirect("wipefs", ["-a", self.device],
                                  stderr="/dev/tty5",
                                  stdout="/dev/tty5")
        except Exception as e:
            err = str(e)
        else:
            err = ""
            if rc:
                err = str(rc)

        if err:
            msg = "error wiping old signatures from %s: %s" % (self.device, err)
            raise FormatDestroyError(msg)

        self.exists = False
예제 #46
0
    def __init__(self, *args, **kwargs):
        """ Create an LVMPhysicalVolume instance.

            Keyword Arguments:

                device -- path to the underlying device
                uuid -- this PV's uuid (not the VG uuid)
                vgName -- the name of the VG this PV belongs to
                vgUuid -- the UUID of the VG this PV belongs to
                peStart -- offset of first physical extent
                exists -- indicates whether this is an existing format

        """
        log_method_call(self, *args, **kwargs)
        DeviceFormat.__init__(self, *args, **kwargs)
        self.vgName = kwargs.get("vgName")
        self.vgUuid = kwargs.get("vgUuid")
        # liblvm may be able to tell us this at some point, even
        # for not-yet-created devices
        self.peStart = kwargs.get("peStart", 1.0)    # in MB
예제 #47
0
    def __init__(self, *args, **kwargs):
        """ Create an LVMPhysicalVolume instance.

            Keyword Arguments:

                device -- path to the underlying device
                uuid -- this PV's uuid (not the VG uuid)
                vgName -- the name of the VG this PV belongs to
                vgUuid -- the UUID of the VG this PV belongs to
                peStart -- offset of first physical extent
                exists -- indicates whether this is an existing format

        """
        log_method_call(self, *args, **kwargs)
        DeviceFormat.__init__(self, *args, **kwargs)
        self.vgName = kwargs.get("vgName")
        self.vgUuid = kwargs.get("vgUuid")
        # liblvm may be able to tell us this at some point, even
        # for not-yet-created devices
        self.peStart = kwargs.get("peStart", 1.0)  # in MB
예제 #48
0
    def destroy(self, *args, **kwargs):
        """ Destroy the format. """
        log_method_call(self,
                        device=self.device,
                        type=self.type,
                        status=self.status)
        if not self.exists:
            raise PhysicalVolumeError("format has not been created")

        if self.status:
            raise PhysicalVolumeError("device is active")

        # FIXME: verify path exists?
        try:
            lvm.pvremove(self.device)
        except LVMError:
            DeviceFormat.destroy(self, *args, **kwargs)

        self.exists = False
        self.notifyKernel()
    def create(self, *args, **kwargs):
        """ Create the device. """
        log_method_call(self,
                        device=self.device,
                        type=self.type,
                        status=self.status)
        if self.exists:
            raise DeviceFormatError("format already exists")

        if self.status:
            raise DeviceFormatError("device exists and is active")

        DeviceFormat.create(self, *args, **kwargs)

        # We're relying on someone having called resetPartedDisk -- we
        # could ensure a fresh disklabel by setting self._partedDisk to
        # None right before calling self.commit(), but that might hide
        # other problems.
        self.commit()
        self.exists = True
예제 #50
0
    def notifyKernel(self):
        log_method_call(self, device=self.device,
                        type=self.type)
        if not self.device:
            return

        if self.device.startswith("/dev/mapper/"):
            try:
                name = dm_node_from_name(os.path.basename(self.device))
            except DMError:
                log.warning("failed to get dm node for %s" % self.device)
                return
        else:
            name = self.device

        path = get_sysfs_path_by_name(name)
        try:
            notify_kernel(path, action="change")
        except (ValueError, IOError) as e:
            log.warning("failed to notify kernel of change: %s" % e)
    def destroy(self, *args, **kwargs):
        log_method_call(self,
                        device=self.device,
                        type=self.type,
                        status=self.status)
        try:
            rc = execWithRedirect("wipefs", ["-a", self.device],
                                  stderr="/dev/tty5",
                                  stdout="/dev/tty5")
        except Exception as e:
            err = str(e)
        else:
            err = ""
            if rc:
                err = str(rc)

        if err:
            msg = "error wiping old signatures from %s: %s" % (self.device,
                                                               err)
            raise FormatDestroyError(msg)

        self.exists = False
예제 #52
0
    def _build_topology(self):
        log_method_call(self)
        self._build_devmap()
        self._build_mpath_topology()

        for dev in self._devices:
            name = dev['name']
            if not udev_device_is_disk(dev):
                self._nondisks.append(name)
                log.info("MultipathTopology: found non-disk device: %s" % name)
                continue
            mpath_name = self.multipath_name(name)
            if mpath_name:
                dev["ID_FS_TYPE"] = "multipath_member"
                dev["ID_MPATH_NAME"] = mpath_name
                log.info("MultipathTopology: found a multipath member of %s: %s " %
                         (mpath_name, name))
                continue
            # it's a disk and not a multipath member (can be a coalesced
            # multipath)
            self._singlepaths.append(name)
            log.info("MultipathTopology: found singlepath device: %s" % name)
예제 #53
0
    def __init__(self, *args, **kwargs):
        """ Create a LUKS instance.

            Keyword Arguments:

                device -- the path to the underlying device
                name -- the name of the mapped device
                uuid -- this device's UUID
                passphrase -- device passphrase (string)
                key_file -- path to a file containing a key (string)
                cipher -- cipher mode string
                key_size -- key size in bits
                exists -- indicates whether this is an existing format
                escrow_cert -- certificate to use for key escrow
                add_backup_passphrase -- generate a backup passphrase?
        """
        log_method_call(self, *args, **kwargs)
        DeviceFormat.__init__(self, *args, **kwargs)
        self.cipher = kwargs.get("cipher")
        self.key_size = kwargs.get("key_size")
        self.mapName = kwargs.get("name")

        if not self.exists and not self.cipher:
            self.cipher = "aes-xts-plain64"
            if not self.key_size:
                # default to the max (512 bits) for aes-xts
                self.key_size = 512

        # FIXME: these should both be lists, but managing them will be a pain
        self.__passphrase = kwargs.get("passphrase")
        self._key_file = kwargs.get("key_file")
        self.escrow_cert = kwargs.get("escrow_cert")
        self.add_backup_passphrase = kwargs.get("add_backup_passphrase", False)

        if not self.mapName and self.exists and self.uuid:
            self.mapName = "luks-%s" % self.uuid
        elif not self.mapName and self.device:
            self.mapName = "luks-%s" % os.path.basename(self.device)
예제 #54
0
    def __init__(self, *args, **kwargs):
        """ Create a LUKS instance.

            Keyword Arguments:

                device -- the path to the underlying device
                name -- the name of the mapped device
                uuid -- this device's UUID
                passphrase -- device passphrase (string)
                key_file -- path to a file containing a key (string)
                cipher -- cipher mode string
                key_size -- key size in bits
                exists -- indicates whether this is an existing format
                escrow_cert -- certificate to use for key escrow
                add_backup_passphrase -- generate a backup passphrase?
        """
        log_method_call(self, *args, **kwargs)
        DeviceFormat.__init__(self, *args, **kwargs)
        self.cipher = kwargs.get("cipher")
        self.key_size = kwargs.get("key_size")
        self.mapName = kwargs.get("name")

        if not self.exists and not self.cipher:
            self.cipher = "aes-xts-plain64"
            if not self.key_size:
                # default to the max (512 bits) for aes-xts
                self.key_size = 512

        # FIXME: these should both be lists, but managing them will be a pain
        self.__passphrase = kwargs.get("passphrase")
        self._key_file = kwargs.get("key_file")
        self.escrow_cert = kwargs.get("escrow_cert")
        self.add_backup_passphrase = kwargs.get("add_backup_passphrase", False)

        if not self.mapName and self.exists and self.uuid:
            self.mapName = "luks-%s" % self.uuid
        elif not self.mapName and self.device:
            self.mapName = "luks-%s" % os.path.basename(self.device)
    def __init__(self, *args, **kwargs):
        """ Create a DiskLabel instance.

            Keyword Arguments:

                device -- path to the underlying device
                exists -- indicates whether this is an existing format

        """
        log_method_call(self, *args, **kwargs)
        DeviceFormat.__init__(self, *args, **kwargs)

        self._size = None

        self._partedDevice = None
        self._partedDisk = None
        self._origPartedDisk = None
        self._alignment = None
        self._endAlignment = None

        if self.partedDevice:
            # set up the parted objects and raise exception on failure
            self._origPartedDisk = self.partedDisk.duplicate()
    def __init__(self, *args, **kwargs):
        """ Create a DiskLabel instance.

            Keyword Arguments:

                device -- path to the underlying device
                exists -- indicates whether this is an existing format

        """
        log_method_call(self, *args, **kwargs)
        DeviceFormat.__init__(self, *args, **kwargs)

        self._size = None

        self._partedDevice = None
        self._partedDisk = None
        self._origPartedDisk = None
        self._alignment = None
        self._endAlignment = None

        if self.partedDevice:
            # set up the parted objects and raise exception on failure
            self._origPartedDisk = self.partedDisk.duplicate()
예제 #57
0
    def create(self, *args, **kwargs):
        """ Create the device. """
        log_method_call(self,
                        device=self.device,
                        type=self.type,
                        status=self.status)
        intf = kwargs.get("intf")
        force = kwargs.get("force")
        if not force and self.exists:
            raise SwapSpaceError("format already exists")

        if force:
            self.teardown()
        elif self.status:
            raise SwapSpaceError("device exists and is active")

        w = None
        if intf:
            w = intf.progressWindow(
                _("Formatting"),
                _("Creating %(type)s on %(device)s") % {
                    "type": self.type,
                    "device": kwargs.get("device", self.device)
                },
                100,
                pulse=True)

        try:
            DeviceFormat.create(self, *args, **kwargs)
            swap.mkswap(self.device, label=self.label, progress=w)
        except Exception:
            raise
        else:
            self.exists = True
        finally:
            if w:
                w.pop()