'Cleanup target volume on delete.
Extra logic if target is last in group.
:param volume: the volume object
:param volume_name: the volume name
:param device_id: the device id
:param extra_specs: extra specifications
:raises: VolumeBackendAPIException'

def cleanup_lun_replication(self, volume, volume_name, device_id, extra_specs):

    LOG.debug('Starting    cleanup    replication    from    volume:    %s.', volume_name)
    try:
        loc = volume.provider_location
        rep_data = volume.replication_driver_data
        if (isinstance(loc, six.string_types) and isinstance(rep_data, six.string_types)):
            name = ast.literal_eval(loc)
            try:
                array = name['array']
            except KeyError:
                array = name['keybindings']['SystemName'].split('+')[1].strip('-')
            rep_extra_specs = self._get_replication_extra_specs(extra_specs, self.rep_config)
            (target_device, remote_array, rdf_group_no, local_vol_state, pair_state) = self.get_remote_target_device(array, volume, device_id)
            if (target_device is not None):
                self.masking.remove_and_reset_members(remote_array, target_device, volume_name, rep_extra_specs, False)
                self._cleanup_remote_target(array, remote_array, device_id, target_device, rdf_group_no, volume_name, rep_extra_specs)
                LOG.info('Successfully    destroyed    replication    for    volume:    %(volume)s', {'volume': volume_name})
            else:
                LOG.warning('Replication    target    not    found    for    replication-enabled    volume:    %(volume)s', {'volume': volume_name})
    except Exception as e:
        exception_message = (_('Cannot    get    necessary    information    to    cleanup    replication    target    for    volume:    %(volume)s.    The    exception    received    was:    %(e)s.    Manual    clean-up    may    be    required.    Please    contact    your    administrator.') % {'volume': volume_name, 'e': six.text_type(e)})
        LOG.error(exception_message)
        raise exception.VolumeBackendAPIException(data=exception_message)
