def reset_install_device(self): """Unmount the previous base repo and reset the install_device.""" # cdrom: install_device.teardown (INSTALL_TREE) # hd: umount INSTALL_TREE, install_device.teardown (ISO_DIR) # nfs: umount INSTALL_TREE # nfsiso: umount INSTALL_TREE, umount ISO_DIR if os.path.ismount(INSTALL_TREE): if self.install_device and \ payload_utils.get_mount_device_path(INSTALL_TREE) == self.install_device.path: payload_utils.teardown_device(self.install_device) else: payload_utils.unmount(INSTALL_TREE, raise_exc=True) if os.path.ismount(ISO_DIR): if self.install_device and \ payload_utils.get_mount_device_path(ISO_DIR) == self.install_device.path: payload_utils.teardown_device(self.install_device) # The below code will fail when nfsiso is the stage2 source # But if we don't do this we may not be able to switch from # one nfsiso repo to another nfsiso repo. We need to have a # way to detect the stage2 state and work around it. # Commenting out the below is a hack for F18. FIXME # else: # # NFS # blivet.util.umount(ISO_DIR) self.install_device = None
def _setup_install_device(self, checkmount): # XXX FIXME: does this need to handle whatever was set up by dracut? method = self.data.method url = None mirrorlist = None metalink = None # See if we already have stuff mounted due to dracut iso_device_path = payload_utils.get_mount_device_path(DRACUT_ISODIR) repo_device_path = payload_utils.get_mount_device_path(DRACUT_REPODIR) if method.method == "harddrive": log.debug("Setting up harddrive install device") url = self._setup_harddrive_device(method, iso_device_path, repo_device_path) elif method.method == "nfs": log.debug("Setting up nfs install device") url = self._setup_nfs_device(method, iso_device_path, repo_device_path) elif method.method == "url": url = method.url mirrorlist = method.mirrorlist metalink = method.metalink elif method.method == "hmc": log.debug("Setting up hmc install device") url = self._setup_hmc_device(method, iso_device_path, repo_device_path) elif method.method == "cdrom" or (checkmount and not method.method): log.debug("Setting up cdrom install device") url = self._setup_cdrom_device(method, iso_device_path, repo_device_path) return url, mirrorlist, metalink
def _setup_NFS(mountpoint, server, path, options): """Prepare an NFS directory for use as an install source.""" log.info("mounting %s:%s:%s on %s", server, path, options, mountpoint) device_path = payload_utils.get_mount_device_path(mountpoint) # test if the mountpoint is occupied already if device_path: _server, colon, _path = device_path.partition(":") if colon == ":" and server == _server and path == _path: log.debug("%s:%s already mounted on %s", server, path, mountpoint) return else: log.debug("%s already has something mounted on it", mountpoint) payload_utils.unmount(mountpoint) # mount the specified directory url = "%s:%s" % (server, path) if not options: options = "nolock" elif "nolock" not in options: options += ",nolock" payload_utils.mount(url, mountpoint, fstype="nfs", options=options)
def _setup_device(device, mountpoint): """Prepare an install CD/DVD for use as a package source.""" log.info("setting up device %s and mounting on %s", device.name, mountpoint) # Is there a symlink involved? If so, let's get the actual path. # This is to catch /run/install/isodir vs. /mnt/install/isodir, for # instance. real_mountpoint = os.path.realpath(mountpoint) mount_device_path = payload_utils.get_mount_device_path( real_mountpoint) if mount_device_path: log.warning("%s is already mounted on %s", mount_device_path, mountpoint) if mount_device_path == device.path: return else: payload_utils.unmount(real_mountpoint) try: payload_utils.setup_device(device) payload_utils.mount_device(device, mountpoint) except StorageError as e: log.error("mount failed: %s", e) payload_utils.teardown_device(device) raise PayloadSetupError(str(e))
def ISO_image(self): """The location of a mounted ISO repo, or None.""" if not self.data.method.method == "harddrive": return None # This could either be mounted to INSTALL_TREE or on # DRACUT_ISODIR if dracut did the mount. device_path = payload_utils.get_mount_device_path(INSTALL_TREE) if device_path: return device_path[len(ISO_DIR) + 1:] device_path = payload_utils.get_mount_device_path(DRACUT_ISODIR) if device_path: return device_path[len(DRACUT_ISODIR) + 1:] return None
def _unmount_source_directory(self, mount_point): if os.path.ismount(mount_point): device_path = payload_utils.get_mount_device_path(mount_point) device = payload_utils.resolve_device(self.storage, device_path) if device: payload_utils.teardown_device(device) else: payload_utils.unmount(mount_point, raise_exc=True)
def refresh(self, args=None): NormalTUISpoke.refresh(self, args) threadMgr.wait(THREAD_PAYLOAD) self._container = ListColumnContainer(1, columns_width=78, spacing=1) if self.data.method.method == "harddrive" and \ payload_utils.get_mount_device_path(DRACUT_ISODIR) == \ payload_utils.get_mount_device_path(DRACUT_REPODIR): message = _( "The installation source is in use by the installer and " "cannot be changed.") self.window.add_with_separator(TextWidget(message)) return if args == self.SET_NETWORK_INSTALL_MODE: if self.payload.mirrors_available: self._container.add(TextWidget(_("Closest mirror")), self._set_network_close_mirror) self._container.add(TextWidget("http://"), self._set_network_url, SpecifyRepoSpoke.HTTP) self._container.add(TextWidget("https://"), self._set_network_url, SpecifyRepoSpoke.HTTPS) self._container.add(TextWidget("ftp://"), self._set_network_url, SpecifyRepoSpoke.FTP) self._container.add(TextWidget("nfs"), self._set_network_nfs) else: self.window.add( TextWidget(_("Choose an installation source type."))) self._container.add(TextWidget(_("CD/DVD")), self._set_cd_install_source) self._container.add(TextWidget(_("local ISO file")), self._set_iso_install_source) self._container.add(TextWidget(_("Network")), self._set_network_install_source) if self._hmc: self._container.add(TextWidget(_("SE/HMC")), self._set_hmc_install_source) self.window.add_with_separator(self._container)