Пример #1
0
    def test_verify_valid_repository_installtree_success(self):
        """Test verify_valid_repository functionality for installation tree success."""
        with TemporaryDirectory() as tmp:
            treeinfo_path = Path(tmp, ".treeinfo")
            treeinfo_path.write_text("This is a cool .treeinfo file!")

            self.assertTrue(verify_valid_repository(tmp))

        with TemporaryDirectory() as tmp:
            treeinfo_path = Path(tmp, "treeinfo")
            treeinfo_path.write_text("This is a cool treeinfo file!")

            self.assertTrue(verify_valid_repository(tmp))
Пример #2
0
    def verify_valid_repository_failed_test(self):
        """Test verify_valid_repository functionality failed."""
        with TemporaryDirectory() as tmp:
            repodir_path = Path(tmp, "repodata")
            repodir_path.mkdir()

            self.assertFalse(verify_valid_repository(tmp))
Пример #3
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
                ))

        options, host, path = parse_nfs_url(self._url)
        path, image = self._split_iso_from_path(path)
        try:
            self._mount_nfs(host, options, path)
        except PayloadSetupError:
            raise SourceSetupError("Could not mount NFS url '{}'".format(self._url))

        iso_source_path = join_paths(self._device_mount, image) if image else self._device_mount

        iso_name = find_and_mount_iso_image(iso_source_path, 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_repository(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))
Пример #4
0
    def verify_valid_repository_success_test(self):
        """Test verify_valid_repository functionality success."""
        with TemporaryDirectory() as tmp:
            repodir_path = Path(tmp, "repodata")
            repodir_path.mkdir()
            repomd_path = Path(repodir_path, "repomd.xml")
            repomd_path.write_text("This is a cool repomd file!")

            self.assertTrue(verify_valid_repository(tmp))
Пример #5
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_and_mount_iso_image(full_path_on_mounted_device,
                                            self._iso_mount)

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

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

        # nothing found unmount the existing device
        unmount(self._device_mount)
        raise SourceSetupError(
            "Nothing useful found for Hard drive ISO source at partition={} directory={}"
            .format(self._partition, self._directory))