Example #1
0
def find_live_backing_device(devicetree):
    """Find the backing device for the live image.

    Note that this is a little bit of a hack since we're assuming
    that /run/initramfs/live will exist

    :param devicetree: a device tree
    :return: a device or None
    """
    for mnt in open("/proc/mounts").readlines():
        if " /run/initramfs/live " not in mnt:
            continue

        # Return the device mounted at /run/initramfs/live.
        device_path = mnt.split()[0]
        device_name = device_path.split("/")[-1]
        device = devicetree.get_device_by_name(device_name, hidden=True)

        if device:
            return device

        # Or return the disk of this device.
        info = udev.get_device(device_node=device_path)
        disk_name = udev.device_get_partition_disk(info) if info else ""
        disk = devicetree.get_device_by_name(disk_name, hidden=True)

        if disk:
            return disk

    return None
Example #2
0
def _getDeviceDict(device, createBrick=False):
    info = {'name': device.name,
            'devPath': device.path,
            'devUuid': device.uuid or '',
            'bus': device.bus or '',
            'model': '',
            'fsType': '',
            'mountPoint': '',
            'uuid': '',
            'createBrick': createBrick}
    if isinstance(device.size, blivet.size.Size):
        info['size'] = '%s' % device.size.convertTo(spec="MiB")
    else:
        info['size'] = '%s' % device.size
    if not info['bus'] and device.parents:
        info['bus'] = device.parents[0].bus
    if device.model:
        info['model'] = "%s (%s)" % (device.model, device.type)
    else:
        info['model'] = device.type
    if device.format:
        info['uuid'] = device.format.uuid or ''
        # lvm vg will not have sysfs path
        if hasattr(udev, 'get_device'):
            dev = udev.get_device(device.sysfsPath) or {}
        elif hasattr(udev, 'udev_get_device'):
            dev = udev.udev_get_device(device.sysfsPath) or {}
        else:
            dev = {}
        info['fsType'] = device.format.type or dev.get('ID_FS_TYPE', '')
    if hasattr(device.format, 'mountpoint'):
        info['mountPoint'] = device.format.mountpoint or ''
    return info
Example #3
0
def _getDeviceDict(device, createBrick=False):
    info = {
        'name': device.name,
        'devPath': device.path,
        'devUuid': device.uuid or '',
        'bus': device.bus or '',
        'model': '',
        'fsType': '',
        'mountPoint': '',
        'uuid': '',
        'createBrick': createBrick
    }
    if isinstance(device.size, blivet.size.Size):
        info['size'] = '%s' % _getDeviceSize(device)
    else:
        info['size'] = '%s' % device.size
    if not info['bus'] and device.parents:
        info['bus'] = device.parents[0].bus
    if device.model:
        info['model'] = "%s (%s)" % (device.model, device.type)
    else:
        info['model'] = device.type
    if device.format:
        info['uuid'] = device.format.uuid or ''
        # lvm vg will not have sysfs path
        if hasattr(udev, 'get_device'):
            dev = udev.get_device(device.sysfsPath) or {}
        elif hasattr(udev, 'udev_get_device'):
            dev = udev.udev_get_device(device.sysfsPath) or {}
        else:
            dev = {}
        info['fsType'] = device.format.type or dev.get('ID_FS_TYPE', '')
    if hasattr(device.format, 'mountpoint'):
        info['mountPoint'] = device.format.mountpoint or ''
    return info
Example #4
0
def _getDeviceDict(device, createBrick=False):
    info = {
        "name": device.name,
        "devPath": device.path,
        "devUuid": device.uuid or "",
        "bus": device.bus or "",
        "model": "",
        "fsType": "",
        "mountPoint": "",
        "uuid": "",
        "createBrick": createBrick,
    }
    if isinstance(device.size, blivet.size.Size):
        info["size"] = "%s" % _getDeviceSize(device)
    else:
        info["size"] = "%s" % device.size
    if not info["bus"] and device.parents:
        info["bus"] = device.parents[0].bus
    if device.model:
        info["model"] = "%s (%s)" % (device.model, device.type)
    else:
        info["model"] = device.type
    if device.format:
        info["uuid"] = device.format.uuid or ""
        # lvm vg will not have sysfs path
        if hasattr(udev, "get_device"):
            dev = udev.get_device(device.sysfsPath) or {}
        elif hasattr(udev, "udev_get_device"):
            dev = udev.udev_get_device(device.sysfsPath) or {}
        else:
            dev = {}
        info["fsType"] = device.format.type or dev.get("ID_FS_TYPE", "")
    if hasattr(device.format, "mountpoint"):
        info["mountPoint"] = device.format.mountpoint or ""
    return info
Example #5
0
    def get_devices_to_ignore(self):
        """Get devices to be ignored.

        By default nvdimm devices are ignored. To become available for
        installation, the device(s) must be specified by nvdimm kickstart
        command. Also, only devices in sector mode are allowed.

        Don't ignore devices that have an iso9660 file system. We might
        want to use them as an installation source.

        :return: a set of device names
        """
        namespaces_to_use = self.get_namespaces_to_use()
        devices_to_use = self.get_devices_to_use()
        devices_to_ignore = set()

        for ns_name, ns_info in nvdimm.namespaces.items():
            # this is happening when namespace is set to DEVDAX mode - block device is not present
            if ns_info.blockdev is None:
                log.debug(
                    "%s will be skipped - NVDIMM namespace block device information "
                    "can't be retrieved", ns_name)
                continue

            info = udev.get_device(device_node="/dev/" + ns_info.blockdev)

            if info and udev.device_get_format(info) == "iso9660":
                log.debug(
                    "%s / %s won't be ignored - NVDIMM device has "
                    "an iso9660 file system", ns_name, ns_info.blockdev)
                continue
            elif ns_info.mode != blockdev.NVDIMMNamespaceMode.SECTOR:
                log.debug(
                    "%s / %s will be ignored - NVDIMM device is not "
                    "in sector mode", ns_name, ns_info.blockdev)
            elif ns_name not in namespaces_to_use and ns_info.blockdev not in devices_to_use:
                log.debug(
                    "%s / %s will be ignored - NVDIMM device has not been "
                    "configured to be used", ns_name, ns_info.blockdev)
            else:
                continue

            devices_to_ignore.add(ns_info.blockdev)

        return devices_to_ignore
Example #6
0
def _getDeviceDict(device, createBrick=False):
    info = {
        'name': device.name,
        'devPath': device.path,
        'devUuid': device.uuid or '',
        'bus': device.bus or '',
        'model': '',
        'fsType': '',
        'mountPoint': '',
        'uuid': '',
        'createBrick': createBrick
    }
    if isinstance(device.size, blivet.size.Size):
        info['size'] = '%s' % _getDeviceSize(device)
    else:
        info['size'] = '%s' % device.size
    if not info['bus'] and device.parents:
        info['bus'] = device.parents[0].bus
    if device.model:
        info['model'] = "%s (%s)" % (device.model, device.type)
    else:
        info['model'] = device.type
    if device.format:
        info['uuid'] = device.format.uuid or ''
        # lvm vg will not have sysfs path
        if hasattr(udev, 'get_device'):
            dev = udev.get_device(device.sysfsPath) or {}
        elif hasattr(udev, 'udev_get_device'):
            # The code is valid, calling udev_get_devices only if the attribute
            # exists, but pylint is confused by this.
            # TODO: rewrite so pylint does not complain.
            # pylint: disable=no-member
            dev = udev.udev_get_device(device.sysfsPath) or {}
        else:
            dev = {}
        info['fsType'] = device.format.type or dev.get('ID_FS_TYPE', '')
    if hasattr(device.format, 'mountpoint'):
        info['mountPoint'] = device.format.mountpoint or ''
    return info
Example #7
0
def find_live_backing_device():
    """Find the backing device for the live image.

    Note that this is a little bit of a hack since we're assuming
    that /run/initramfs/live will exist

    :return: a device name or None
    """
    for mnt in open("/proc/mounts").readlines():
        if " /run/initramfs/live " not in mnt:
            continue

        live_device_path = mnt.split()[0]
        udev_device = udev.get_device(device_node=live_device_path)

        if udev_device and udev.device_is_partition(udev_device):
            live_device_name = udev.device_get_partition_disk(udev_device)
        else:
            live_device_name = live_device_path.split("/")[-1]

        return live_device_name or None

    return None
Example #8
0
def find_live_backing_device():
    """Find the backing device for the live image.

    Note that this is a little bit of a hack since we're assuming
    that /run/initramfs/live will exist

    :return: a device name or None
    """
    for mnt in open("/proc/mounts").readlines():
        if " /run/initramfs/live " not in mnt:
            continue

        live_device_path = mnt.split()[0]
        udev_device = udev.get_device(device_node=live_device_path)

        if udev_device and udev.device_is_partition(udev_device):
            live_device_name = udev.device_get_partition_disk(udev_device)
        else:
            live_device_name = live_device_path.split("/")[-1]

        return live_device_name or None

    return None
Example #9
0
def _getDeviceDict(device, createBrick=False):
    info = {'name': device.name,
            'devPath': device.path,
            'devUuid': device.uuid or '',
            'bus': device.bus or '',
            'model': '',
            'fsType': '',
            'mountPoint': '',
            'uuid': '',
            'createBrick': createBrick}
    if isinstance(device.size, blivet.size.Size):
        info['size'] = '%s' % _getDeviceSize(device)
    else:
        info['size'] = '%s' % device.size
    if not info['bus'] and device.parents:
        info['bus'] = device.parents[0].bus
    if device.model:
        info['model'] = "%s (%s)" % (device.model, device.type)
    else:
        info['model'] = device.type
    if device.format:
        info['uuid'] = device.format.uuid or ''
        # lvm vg will not have sysfs path
        if hasattr(udev, 'get_device'):
            dev = udev.get_device(device.sysfsPath) or {}
        elif hasattr(udev, 'udev_get_device'):
            # The code is valid, calling udev_get_devices only if the attribute
            # exists, but pylint is confused by this.
            # TODO: rewrite so pylint does not complain.
            # pylint: disable=no-member
            dev = udev.udev_get_device(device.sysfsPath) or {}
        else:
            dev = {}
        info['fsType'] = device.format.type or dev.get('ID_FS_TYPE', '')
    if hasattr(device.format, 'mountpoint'):
        info['mountPoint'] = device.format.mountpoint or ''
    return info