'Kills the running processes for given instance.
This method is used to kill all running processes of the instance if
it is deleted in between.
:param instance: Object of instance'

def terminate_jobs(self, instance):

    pids_to_remove = list(self.jobs.get(instance.uuid, []))
    for pid in pids_to_remove:
        try:
            os.kill(pid, signal.SIGKILL)
        except OSError as exc:
            if (exc.errno != errno.ESRCH):
                LOG.error('Failed    to    kill    process    %(pid)s    due    to    %(reason)s,    while    deleting    the    instance.', {'pid': pid, 'reason': exc}, instance=instance)
        try:
            os.kill(pid, 0)
        except OSError as exc:
            if (exc.errno != errno.ESRCH):
                LOG.error('Unexpected    error    while    checking    process    %(pid)s.', {'pid': pid}, instance=instance)
        else:
            LOG.warning('Failed    to    kill    a    long    running    process    %(pid)s    related    to    the    instance    when    deleting    it.', {'pid': pid}, instance=instance)
        self.remove_job(instance, pid)
