

def _is_valid_dev_type(device_info, vg):
    "Returns bool value if we should use device based on different rules:\n\n    1. Should have approved MAJOR number\n    2. Shouldn't be nbd/ram/loop device\n    3. Should contain DEVNAME itself\n    4. Should be compared with vg value\n\n    :param device_info: A dict of properties which we get from udevadm.\n    :param vg: determine if we need LVM devices or not.\n    :returns: bool if we should use this device.\n    "
    if (('E: MAJOR' in device_info) and (int(device_info['E: MAJOR']) not in VALID_MAJORS)):
        return False
    if any((os.path.basename(device_info['E: DEVNAME']).startswith(n) for n in ('nbd', 'ram', 'loop'))):
        return False
    if ('E: DEVNAME' not in device_info):
        return False
    if ((vg and ('E: DM_VG_NAME' in device_info)) or ((not vg) and ('E: DM_VG_NAME' not in device_info))):
        return True
    else:
        return False

dataset/ETHPy150Open openstack/bareon/bareon/utils/hardware.py _is_valid_dev_type/original