'Destroys the resource if it doesn\'t belong to given template.
The given template is suppose to be the current template being
provisioned.
Also, since this resource is visited as part of clean-up phase,
the needed_by should be updated. If this resource was
replaced by more recent resource, then delete this and update
the replacement resource\'s needed_by and replaces fields.'

def delete_convergence(self, template_id, input_data, engine_id, timeout, progress_callback=None):

    self._calling_engine_id = engine_id
    self.needed_by = list(set((v for v in input_data.values() if (v is not None))))
    if (self.current_template_id != template_id):
        if (self.action == self.INIT):
            try:
                resource_objects.Resource.delete(self.context, self.id)
            except exception.NotFound:
                pass
        else:
            runner = scheduler.TaskRunner(self.delete)
            runner(timeout=timeout, progress_callback=progress_callback)
            self._update_replacement_data(template_id)
