Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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:
"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
# 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))
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
# 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. """
)
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
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)
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
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))
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?")