def CleanupInstance(self, instance_name):
    root_dir = self._InstanceDir(instance_name)

    if not os.path.exists(root_dir):
      return

    if self._IsDirLive(root_dir):
      raise HypervisorError("Processes are still using the chroot")

    for mpath in self._GetMountSubdirs(root_dir):
      utils.RunCmd(["umount", mpath])

    result = utils.RunCmd(["umount", root_dir])
    if result.failed:
      msg = ("Processes still alive in the chroot: %s" %
             utils.RunCmd("fuser -vm %s" % root_dir).output)
      logging.error(msg)
      raise HypervisorError("Can't umount the chroot dir: %s (%s)" %
                            (result.output, msg))
Cleanup after a stopped instance
dataset/ETHPy150Open ganeti/ganeti/lib/hypervisor/hv_chroot.py/ChrootManager.CleanupInstance