Exemple #1
0
    def _setup_install_device(self, storage, 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
        isodev = payload_utils.get_mount_device(DRACUT_ISODIR)
        device = payload_utils.get_mount_device(DRACUT_REPODIR)

        if method.method == "harddrive":
            log.debug("Setting up harddrive install device")
            url = self._setup_harddrive_device(storage, method, isodev, device)
        elif method.method == "nfs":
            log.debug("Setting up nfs install device")
            url = self._setup_nfs_device(storage, method, isodev, device)
        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(storage, method, isodev, device)
        elif method.method == "cdrom" or (checkmount and not method.method):
            log.debug("Setting up cdrom install device")
            url = self._setup_cdrom_device(storage, method, isodev, device)

        return url, mirrorlist, metalink
Exemple #2
0
    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(INSTALL_TREE) == self.install_device.path:
                self.install_device.teardown(recursive=True)
            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(ISO_DIR) == self.install_device.path:
                self.install_device.teardown(recursive=True)
            # 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
Exemple #3
0
    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(INSTALL_TREE) == self.install_device.path:
                self.install_device.teardown(recursive=True)
            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(ISO_DIR) == self.install_device.path:
                self.install_device.teardown(recursive=True)
            # 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
Exemple #4
0
    def _setup_install_device(self, storage, 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
        isodev = payload_utils.get_mount_device(DRACUT_ISODIR)
        device = payload_utils.get_mount_device(DRACUT_REPODIR)

        if method.method == "harddrive":
            log.debug("Setting up harddrive install device")
            url = self._setup_harddrive_device(storage, method, isodev, device)
        elif method.method == "nfs":
            log.debug("Setting up nfs install device")
            url = self._setup_nfs_device(storage, method, isodev, device)
        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(storage, method, isodev, device)
        elif method.method == "cdrom" or (checkmount and not method.method):
            log.debug("Setting up cdrom install device")
            url = self._setup_cdrom_device(storage, method, isodev, device)

        return url, mirrorlist, metalink
Exemple #5
0
 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.
     dev = payload_utils.get_mount_device(INSTALL_TREE)
     if dev:
         return dev[len(ISO_DIR) + 1:]
     dev = payload_utils.get_mount_device(DRACUT_ISODIR)
     if dev:
         return dev[len(DRACUT_ISODIR) + 1:]
     return None
Exemple #6
0
 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.
     dev = payload_utils.get_mount_device(INSTALL_TREE)
     if dev:
         return dev[len(ISO_DIR) + 1:]
     dev = payload_utils.get_mount_device(DRACUT_ISODIR)
     if dev:
         return dev[len(DRACUT_ISODIR) + 1:]
     return None
Exemple #7
0
    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)

        mdev = payload_utils.get_mount_device(real_mountpoint)
        if mdev:
            if mdev:
                log.warning("%s is already mounted on %s", mdev, mountpoint)

            if mdev == device.path:
                return
            else:
                payload_utils.unmount(real_mountpoint)

        try:
            device.setup()
            device.format.setup(mountpoint=mountpoint)
        except StorageError as e:
            log.error("mount failed: %s", e)
            device.teardown(recursive=True)
            raise PayloadSetupError(str(e))
Exemple #8
0
    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)
        dev = payload_utils.get_mount_device(mountpoint)

        # test if the mountpoint is occupied already
        if dev:
            _server, colon, _path = dev.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)
Exemple #9
0
    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)

        mdev = payload_utils.get_mount_device(real_mountpoint)
        if mdev:
            if mdev:
                log.warning("%s is already mounted on %s", mdev, mountpoint)

            if mdev == device.path:
                return
            else:
                payload_utils.unmount(real_mountpoint)

        try:
            device.setup()
            device.format.setup(mountpoint=mountpoint)
        except StorageError as e:
            log.error("mount failed: %s", e)
            device.teardown(recursive=True)
            raise PayloadSetupError(str(e))
Exemple #10
0
 def _unmount_source_directory(self, mount_point):
     if os.path.ismount(mount_point):
         device_path = payload_utils.get_mount_device(mount_point)
         device = self.storage.devicetree.get_device_by_path(device_path)
         if device:
             device.teardown(recursive=True)
         else:
             payload_utils.unmount(mount_point, raise_exc=True)
Exemple #11
0
 def _unmount_source_directory(self, mount_point):
     if os.path.ismount(mount_point):
         device_path = payload_utils.get_mount_device(mount_point)
         device = self.storage.devicetree.get_device_by_path(device_path)
         if device:
             device.teardown(recursive=True)
         else:
             payload_utils.unmount(mount_point, raise_exc=True)
Exemple #12
0
    def _setup_cdrom_device(self, storage, method, isodev, device):
        url = None

        # FIXME: We really should not talk about NFS here - regression from re-factorization?
        # Did dracut leave the DVD or NFS mounted for us?
        device = payload_utils.get_mount_device(DRACUT_REPODIR)

        # Check for valid optical media if we didn't boot from one
        if not verifyMedia(DRACUT_REPODIR):
            self.install_device = opticalInstallMedia(storage.devicetree)

        # Only look at the dracut mount if we don't already have a cdrom
        if device and not self.install_device:
            self.install_device = storage.devicetree.get_device_by_path(device)
            url = "file://" + DRACUT_REPODIR
            if not method.method:
                # See if this is a nfs mount
                if ':' in device:
                    # prepend nfs: to the url as that's what the parser
                    # wants.  Note we don't get options from this, but
                    # that's OK for the UI at least.
                    _options, host, path = util.parseNfsUrl("nfs:%s" % device)
                    method.method = "nfs"
                    method.server = host
                    method.dir = path
                else:
                    method.method = "cdrom"
        else:
            if self.install_device:
                if not method.method:
                    method.method = "cdrom"
                self._setup_media(self.install_device)
                url = "file://" + INSTALL_TREE
            elif method.method == "cdrom":
                raise PayloadSetupError("no usable optical media found")

        return url
Exemple #13
0
    def _setup_cdrom_device(self, storage, method, isodev, device):
        url = None

        # FIXME: We really should not talk about NFS here - regression from re-factorization?
        # Did dracut leave the DVD or NFS mounted for us?
        device = payload_utils.get_mount_device(DRACUT_REPODIR)

        # Check for valid optical media if we didn't boot from one
        if not verifyMedia(DRACUT_REPODIR):
            self.install_device = opticalInstallMedia(storage.devicetree)

        # Only look at the dracut mount if we don't already have a cdrom
        if device and not self.install_device:
            self.install_device = storage.devicetree.get_device_by_path(device)
            url = "file://" + DRACUT_REPODIR
            if not method.method:
                # See if this is a nfs mount
                if ':' in device:
                    # prepend nfs: to the url as that's what the parser
                    # wants.  Note we don't get options from this, but
                    # that's OK for the UI at least.
                    _options, host, path = util.parseNfsUrl("nfs:%s" % device)
                    method.method = "nfs"
                    method.server = host
                    method.dir = path
                else:
                    method.method = "cdrom"
        else:
            if self.install_device:
                if not method.method:
                    method.method = "cdrom"
                self._setup_media(self.install_device)
                url = "file://" + INSTALL_TREE
            elif method.method == "cdrom":
                raise PayloadSetupError("no usable optical media found")

        return url
Exemple #14
0
    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)
        dev = payload_utils.get_mount_device(mountpoint)

        # test if the mountpoint is occupied already
        if dev:
            _server, colon, _path = dev.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)