

def match_device(uspec1, uspec2):
    'Tries to find out if uspec1 and uspec2 are uspecs from the same device\n\n    It compares only some fields in uspecs (not all of them) which, we believe,\n    is enough to say exactly whether uspecs belong to the same device or not.\n\n    :param uspec1: A dict of properties which we get from udevadm.\n    :param uspec1: A dict of properties which we get from udevadm.\n\n    :returns: True if uspecs match each other else False.\n    '
    if (('ID_WWN' in uspec1) and ('ID_WWN' in uspec2) and (uspec1['ID_WWN'] != uspec2['ID_WWN'])):
        return False
    if (('ID_SERIAL_SHORT' in uspec1) and ('ID_SERIAL_SHORT' in uspec2) and (uspec1['ID_SERIAL_SHORT'] != uspec2['ID_SERIAL_SHORT'])):
        return False
    if (('DEVLINKS' in uspec1) and ('DEVLINKS' in uspec2) and any((x.startswith('/dev/disk/by-id') for x in (set(uspec1['DEVLINKS']) & set(uspec2['DEVLINKS']))))):
        return True
    if ((uspec1.get('ID_WWN') == uspec2.get('ID_WWN') is not None) and (uspec2.get('DEVTYPE') == uspec2.get('DEVTYPE') == 'disk')):
        return True
    if ((uspec1.get('ID_WWN') == uspec2.get('ID_WWN') is not None) and (uspec1.get('DEVTYPE') == uspec2.get('DEVTYPE') == 'partition') and (uspec1.get('MINOR') == uspec2.get('MINOR') is not None)):
        return True
    if ((uspec1.get('ID_SERIAL_SHORT') == uspec2.get('ID_SERIAL_SHORT') is not None) and (uspec1.get('DEVTYPE') == uspec2.get('DEVTYPE') == 'disk')):
        return True
    if (uspec1.get('DEVPATH') == uspec2.get('DEVPATH') is not None):
        return True
    return False

dataset/ETHPy150Open openstack/bareon/bareon/utils/hardware.py match_device/VarMisuse@155/472 `uspec1`->`uspec2`