Esempio n. 1
0
    def _setup_install_tree(self, device, install_tree_path, device_mount_dir):
        self._setup_device(device, mountpoint=device_mount_dir)
        path = os.path.normpath("%s/%s" % (device_mount_dir, install_tree_path))

        if not verify_valid_installtree(path):
            payload_utils.teardown_device(device)
            raise PayloadSetupError("failed to find valid installation tree")
Esempio n. 2
0
    def run(self):
        """Set up the installation source."""
        log.debug("Setting up NFS source: %s", self._url)

        for mount_point in [self._device_mount, self._iso_mount]:
            if os.path.ismount(mount_point):
                raise SourceSetupError(
                    "The mount point {} is already in use.".format(
                        mount_point))

        try:
            self._mount_nfs()
        except PayloadSetupError:
            raise SourceSetupError("Could not mount NFS url '{}'".format(
                self._url))

        iso_name = find_and_mount_iso_image(self._device_mount,
                                            self._iso_mount)

        if iso_name:
            log.debug("Using the ISO '%s' mounted at '%s'.", iso_name,
                      self._iso_mount)
            return self._iso_mount

        if verify_valid_installtree(self._device_mount):
            log.debug("Using the directory at '%s'.", self._device_mount)
            return self._device_mount

        # nothing found unmount the existing device
        unmount(self._device_mount)
        raise SourceSetupError(
            "Nothing useful found for NFS source at {}".format(self._url))
Esempio n. 3
0
    def run(self):
        """Run Hard drive installation source setup.

        Always sets up two mount points: First for the device, and second for the ISO image or a
        bind for unpacked ISO. These depend on each other, and must be destroyed in the correct
        order again.

        :raise: SourceSetupError
        :return: named tuple with path to the install tree and name of ISO if set or empty string
        :rtype: SetupHardDriveResult instance
        """
        log.debug("Setting up Hard drive source")

        for mount_point in [self._device_mount, self._iso_mount]:
            if os.path.ismount(mount_point):
                raise SourceSetupError(
                    "The mount point {} is already in use.".format(
                        mount_point))

        if not find_and_mount_device(self._partition, self._device_mount):
            raise SourceSetupError(
                "Could not mount device specified as {}".format(
                    self._partition))

        full_path_on_mounted_device = os.path.normpath("{}/{}".format(
            self._device_mount, self._directory))

        iso_name = find_first_iso_image(full_path_on_mounted_device)

        if iso_name:
            full_path_to_iso = self._create_iso_path(
                full_path_on_mounted_device, iso_name)

            if mount_iso_image(full_path_to_iso, self._iso_mount):
                log.debug("Using the ISO '%s' mounted at '%s'.", iso_name,
                          self._iso_mount)
                return SetupHardDriveResult(self._iso_mount, iso_name)

        if verify_valid_installtree(full_path_on_mounted_device):
            log.debug("Using the directory at '%s'.",
                      full_path_on_mounted_device)
            return SetupHardDriveResult(full_path_on_mounted_device, "")

        raise SourceSetupError(
            "Nothing useful found for Hard drive ISO source at partition={} directory={}"
            .format(self._partition, self._directory))
Esempio n. 4
0
    def run(self):
        """Run Hard drive installation source setup.

        Always sets up two mount points: First for the device, and second for the ISO image or a
        bind for unpacked ISO. These depend on each other, and must be destroyed in the correct
        order again.

        :raise: SourceSetupError
        :return: path to the install tree
        :rtype: str
        """
        log.debug("Setting up Hard drive source")

        for mount_point in [self._device_mount, self._iso_mount]:
            if os.path.ismount(mount_point):
                raise SourceSetupError(
                    "The mount point {} is already in use.".format(
                        mount_point))

        if not find_and_mount_device(self._partition, self._device_mount):
            raise SourceSetupError(
                "Could not mount device specified as {}".format(
                    self._partition))

        full_path_on_mounted_device = os.path.normpath("{}/{}".format(
            self._device_mount, self._directory))

        if find_and_mount_iso_image(full_path_on_mounted_device,
                                    self._iso_mount):
            return self._iso_mount, True
        elif verify_valid_installtree(full_path_on_mounted_device):
            return full_path_on_mounted_device, False

        raise SourceSetupError(
            "Nothing useful found for Hard drive ISO source at partition={} directory={}"
            .format(self._partition, self._directory))