def _sort_source_vols(self, volumes, source_vols):
    if ((not volumes) or (not source_vols) or (len(volumes) != len(source_vols))):
        msg = _('Input volumes or source volumes are invalid.')
        LOG.error(msg)
        raise exception.InvalidInput(reason=msg)
    sorted_source_vols = []
    for vol in volumes:
        found_source_vols = [source_vol for source_vol in source_vols if (source_vol['id'] == vol['source_volid'])]
        if (not found_source_vols):
            LOG.error(_LE('Source volumes cannot be found for target volume %(volume_id)s.'), {'volume_id': vol['id']})
            raise exception.VolumeNotFound(volume_id=vol['source_volid'])
        sorted_source_vols.extend(found_source_vols)
    return sorted_source_vols
def _sort_source_vols(self, volumes, source_vols):
    if ((not volumes) or (not source_vols) or (len(volumes) != len(source_vols))):
        msg = _('Input volumes or source volumes are invalid.')
        LOG.error(msg)
        raise exception.InvalidInput(reason=msg)
    sorted_source_vols = []
    for vol in volumes:
        found_source_vols = [source_vol for source_vol in source_vols if (source_vol['id'] == vol['source_volid'])]
        if (not found_source_vols):
            LOG.error(_LE('Source volumes cannot be found for target volume %(volume_id)s.'), {'volume_id': vol['id']})
            raise exception.VolumeNotFound(volume_id=vol['source_volid'])
        sorted_source_vols.extend(found_source_vols)
    return sorted_source_vols