How to use the blivet.errors.StorageError function in blivet

To help you get started, we’ve selected a few blivet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github QubesOS / qubes-installer-qubes-os / anaconda / pyanaconda / image.py View on Github external
if method.method == "harddrive":
        if method.biospart:
            log.warning("biospart support is not implemented")
            devspec = method.biospart
        else:
            devspec = method.partition

        # FIXME: teach DeviceTree.resolveDevice about biospart
        device = storage.devicetree.resolveDevice(devspec)

        while True:
            try:
                device.setup()
                device.format.setup(mountpoint=ISO_DIR)
            except StorageError as e:
                log.error("couldn't mount ISO source directory: %s", e)
                exn = MediaMountError(str(e), device)
                if errorHandler.cb(exn) == ERROR_RAISE:
                    raise exn
    elif method.method.startswith("nfsiso:"):
        # XXX what if we mount it on ISO_DIR and then create a symlink
        #     if there are no isos instead of the remount?

        # mount the specified directory
        path = method.dir
        if method.dir.endswith(".iso"):
            path = os.path.dirname(method.dir)

        url = "%s:%s" % (method.server, path)

        while True:
github storaged-project / blivet / blivet / errors.py View on Github external
"state or remove it completely.\n"
                    "Hint: parted can restore it or wipefs can remove it.")

class DuplicateVGError(UnusableConfigurationError):
    suggestion = N_("Rename one of the volume groups so the names are "
                    "distinct.\n"
                    "Hint 1: vgrename accepts UUID in place of the old name.\n"
                    "Hint 2: You can get the VG UUIDs by running "
                    "'pvs -o +vg_uuid'.")

# DeviceAction
class DeviceActionError(StorageError):
    pass

# partitioning
class PartitioningError(StorageError):
    pass

class NotEnoughFreeSpaceError(StorageError):
    pass

# udev
class UdevError(StorageError):
    pass

# fstab
class UnrecognizedFSTabEntryError(StorageError):
    pass

class FSTabTypeMismatchError(StorageError):
    pass
github rhinstaller / anaconda / pyanaconda / modules / storage / partitioning / interactive / change_device.py View on Github external
# Nothing to do.
        if not container_spec or container_spec == container_name:
            return

        container = self._storage.devicetree.resolve_device(container_spec)

        # Container doesn't exist.
        if not container:
            return

        log.debug("Changing container name: %s", container_name)

        try:
            rename_container(self._storage, container, container_name)
        except StorageError as e:
            log.error("Invalid container name: %s", e)
            raise StorageError(str(e))
github storaged-project / blivet / blivet / errors.py View on Github external
pass

class DeviceResizeError(DeviceError):
    pass

class DeviceSetupError(DeviceError):
    pass

class DeviceTeardownError(DeviceError):
    pass

class DeviceUserDeniedFormatError(DeviceError):
    pass

# DeviceFormat
class DeviceFormatError(StorageError):
    pass

class FormatCreateError(DeviceFormatError):
    pass

class FormatDestroyError(DeviceFormatError):
    pass

class FormatSetupError(DeviceFormatError):
    pass

class FormatTeardownError(DeviceFormatError):
    pass

class DMRaidMemberError(DeviceFormatError):
    pass
github storaged-project / blivet / blivet / errors.py View on Github external
# partitioning
class PartitioningError(StorageError):
    pass

class NotEnoughFreeSpaceError(StorageError):
    pass

# udev
class UdevError(StorageError):
    pass

# fstab
class UnrecognizedFSTabEntryError(StorageError):
    pass

class FSTabTypeMismatchError(StorageError):
    pass

# size
class SizePlacesError(StorageError):
    pass

# probing
class UnknownSourceDeviceError(StorageError):
    pass

# factories
class DeviceFactoryError(StorageError):
    pass

class AvailabilityError(StorageError):
    """ Raised if problem determining availability of external resource. """
github rhinstaller / anaconda / pyanaconda / modules / storage / partitioning / interactive / utils.py View on Github external
)

        for action in reversed(actions):
            storage.devicetree.actions.remove(action)

        return bool(actions)
    else:
        # the size has changed
        log.debug("Scheduling resize of device %s to %s.", device.raw_device.name, use_size)

        try:
            storage.resize_device(device.raw_device, use_size)
        except (StorageError, ValueError) as e:
            log.exception("Failed to schedule device resize: %s", e)
            device.raw_device.size = use_old_size
            raise StorageError(str(e)) from None

        log.debug(
            "Device %s has size: %s (target %s)",
            device.raw_device.name,
            device.raw_device.size, device.raw_device.target_size
        )
        return True
github rhinstaller / anaconda / pyanaconda / modules / storage / partitioning / interactive / utils.py View on Github external
def get_container(storage, device_type, device=None):
    """Get a container of the given type.

    :param storage: an instance of Blivet
    :param device_type: a device type
    :param device: a defined factory device or None
    :return: a container device
    """
    if device_type not in CONTAINER_DEVICE_TYPES:
        raise StorageError("Invalid device type {}".format(device_type))

    if device and devicefactory.get_device_type(device) != device_type:
        device = None

    factory = devicefactory.get_device_factory(
        storage,
        device_type=device_type,
        size=Size(0),
    )

    return factory.get_container(device=device)
github QubesOS / qubes-installer-qubes-os / anaconda / pyanaconda / storage_utils.py View on Github external
def try_populate_devicetree(devicetree):
    """
    Try to populate the given devicetree while catching errors and dealing with
    some special ones in a nice way (giving user chance to do something about
    them).

    :param devicetree: devicetree to try to populate
    :type decicetree: :class:`blivet.devicetree.DeviceTree`

    """

    while True:
        try:
            devicetree.populate()
        except StorageError as e:
            if errorHandler.cb(e) == ERROR_RAISE:
                raise
            else:
                continue
        else:
            break

    return
github rhinstaller / anaconda / pyanaconda / modules / storage / partitioning / interactive / change_device.py View on Github external
def _change_device_name(self):
        """Change the device name."""
        name = self._request.device_name
        original_name = self._original_request.device_name

        if name == original_name:
            return

        log.debug("Changing device name: %s", name)

        try:
            self._device.raw_device.name = name
        except ValueError as e:
            log.error("Invalid device name: %s", e)
            raise StorageError(str(e))
github storaged-project / blivet / blivet / devicefactory.py View on Github external
self.device.format = None

        # this is setting the device size based on the factory size and the
        # current size of the container
        self._set_device_size()

        try:
            self._post_create()
        except (StorageError, blockdev.BlockDevError) as e:
            log.error("device post-create method failed: %s", e)
            raise
        else:
            if (self.device.size < self.device.format.minSize or
                (self.device.size == self.device.format.minSize and
                 self.size > self.device.format.minSize)):
                raise StorageError("failed to adjust device -- not enough free space in specified disks?")