Exemple #1
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
Exemple #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
Exemple #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
Exemple #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'):
            # 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
Exemple #5
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