def _teardown_chroot_mounts(self): config = self._config.plugins[self.full_name] for mountdef in reversed(config.chroot_mounts): dev, fstype, mountpoint, options = mountdef mountspec = MountSpec( dev, fstype, os.path.join(self._mountpoint, mountpoint.lstrip('/')), options) log.debug('Attempting to unmount {0}'.format(mountspec)) if not mounted(mountspec.mountpoint): log.warn('{0} not mounted'.format(mountspec.mountpoint)) continue result = unmount(mountspec.mountpoint) if not result.success: log.error( 'Unable to unmount {0.mountpoint}: {1.stderr}'.format( mountspec, result)) return False log.debug('Checking for stray mounts') for mountpoint in lifo_mounts(self._mountpoint): log.debug('Stray mount found: {0}, attempting to unmount'.format( mountpoint)) result = unmount(mountpoint) if not result.success: log.error( 'Unable to unmount {0.mountpoint}: {1.stderr}'.format( mountspec, result)) return False log.debug('Teardown of chroot mounts succeeded!') return True
def _unmount(self): if mounted(self._mountpoint): if busy_mount(self._mountpoint).success: raise VolumeException('Unable to unmount {0} from {1}'.format(self._dev, self._mountpoint)) result = unmount(self._mountpoint) if not result.success: raise VolumeException('Unable to unmount {0} from {1}: {2}'.format(self._dev, self._mountpoint, result.result.std_err))
def _unmount(self, mountspec): recursive_unmount = self.plugin_config.get('recursive_unmount', False) if mounted(mountspec): result = unmount(mountspec, recursive=recursive_unmount) if not result.success: err = 'Failed to unmount {0}: {1}' err = err.format(mountspec.mountpoint, result.result.std_err) open_files = busy_mount(mountspec.mountpoint) if open_files.success: err = '{0}. Device has open files:\n{1}'.format(err, open_files.result.std_out) raise VolumeException(err) log.debug('Unmounted {0.mountpoint}'.format(mountspec))
def _teardown_chroot_mounts(self): config = self._config.plugins[self.full_name] for mountdef in reversed(config.chroot_mounts): dev, fstype, mountpoint, options = mountdef mountspec = MountSpec(dev, fstype, os.path.join(self._mountpoint, mountpoint.lstrip('/')), options) log.debug('Attempting to unmount {0}'.format(mountspec)) if not mounted(mountspec.mountpoint): log.warn('{0} not mounted'.format(mountspec.mountpoint)) continue result = unmount(mountspec.mountpoint) if not result.success: log.error('Unable to unmount {0.mountpoint}: {1.stderr}'.format(mountspec, result)) return False log.debug('Checking for stray mounts') for mountpoint in lifo_mounts(self._mountpoint): log.debug('Stray mount found: {0}, attempting to unmount'.format(mountpoint)) result = unmount(mountpoint) if not result.success: log.error('Unable to unmount {0.mountpoint}: {1.stderr}'.format(mountspec, result)) return False log.debug('Teardown of chroot mounts succeeded!') return True
def _unmount(self, mountspec): recursive_unmount = self.plugin_config.get('recursive_unmount', False) if mounted(mountspec): result = unmount(mountspec, recursive=recursive_unmount) if not result.success: err = 'Failed to unmount {0}: {1}' err = err.format(mountspec.mountpoint, result.result.std_err) open_files = busy_mount(mountspec.mountpoint) if open_files.success: err = '{0}. Device has open files:\n{1}'.format( err, open_files.result.std_out) raise VolumeException(err) log.debug('Unmounted {0.mountpoint}'.format(mountspec))