Exemple #1
0
    def setUpClass(cls):
        """Create class-wide variables."""
        cls.cfg = config.get_config()
        cls.cli_client = cli.Client(cls.cfg)
        allowed_imports = get_pulp_setting(cls.cli_client,
                                           "ALLOWED_IMPORT_PATHS")
        if not allowed_imports or "/tmp" not in allowed_imports:
            raise unittest.SkipTest(
                "Cannot run import-tests unless /tmp is in ALLOWED_IMPORT_PATHS ({})."
                .format(allowed_imports), )

        cls.client = api.Client(cls.cfg, api.json_handler)
        cls.core_client = CoreApiClient(
            configuration=cls.cfg.get_bindings_config())
        cls.file_client = gen_file_client()

        cls.repo_api = RepositoriesFileApi(cls.file_client)
        cls.remote_api = RemotesFileApi(cls.file_client)
        cls.versions_api = RepositoriesFileVersionsApi(cls.file_client)
        cls.content_api = ContentFilesApi(cls.file_client)
        cls.exporter_api = ExportersPulpApi(cls.core_client)
        cls.exports_api = ExportersCoreExportsApi(cls.core_client)
        cls.importer_api = ImportersPulpApi(cls.core_client)
        cls.imports_api = ImportersCoreImportsApi(cls.core_client)

        cls.import_check_api = ImportersCoreImportCheckApi(cls.core_client)

        (cls.import_repos, cls.export_repos,
         cls.remotes) = cls._setup_repositories()
        cls.exporter = cls._create_exporter()
        cls.export = cls._create_export()
        cls.chunked_export = cls._create_chunked_export()
        cls._setup_import_check_directories()
Exemple #2
0
    def setUpClass(cls):
        """Create class-wide variables."""
        cls.cfg = config.get_config()
        cls.client = api.Client(cls.cfg, api.json_handler)
        cls.core_client = CoreApiClient(configuration=cls.cfg.get_bindings_config())
        cls.file_client = gen_file_client()

        cls.repo_api = RepositoriesFileApi(cls.file_client)
        cls.remote_api = RemotesFileApi(cls.file_client)
        cls.exporter_api = ExportersPulpApi(cls.core_client)
        cls.exports_api = ExportersCoreExportsApi(cls.core_client)

        (cls.repos, cls.remotes) = cls._setup_repositories()
Exemple #3
0
 def setUpClass(cls):
     """Sets up apis."""
     super().setUpClass()
     cls.export_repos = []
     cls.export_content_count = {}
     cls.remotes = []
     cls.cfg = config.get_config()
     cls.api_client = api.Client(cls.cfg, api.json_handler)
     cls.core_client = CoreApiClient(configuration=cls.cfg.get_bindings_config())
     cls.exporter_api = ExportersPulpApi(cls.core_client)
     cls.exports_api = ExportersCoreExportsApi(cls.core_client)
     cls.repo_ver_api = RepositoriesAnsibleVersionsApi(cls.client)
     cls._setup_content()
Exemple #4
0
def delete_exporter(exporter):
    """
    Utility routine to delete an exporter and any exported files
    :param exporter : PulpExporter to delete
    """
    cfg = config.get_config()
    cli_client = cli.Client(cfg)
    core_client = CoreApiClient(configuration=cfg.get_bindings_config())
    exporter_api = ExportersPulpApi(core_client)
    cmd = ("rm", "-rf", exporter.path)

    cli_client.run(cmd, sudo=True)
    result = exporter_api.delete(exporter.pulp_href)
    monitor_task(result.task)
Exemple #5
0
    def setUpClass(cls):
        """Create class-wide variables."""
        cls.cfg = config.get_config()
        cls.client = api.Client(cls.cfg, api.json_handler)
        cls.core_client = CoreApiClient(configuration=cls.cfg.get_bindings_config())
        cls.rpm_client = gen_rpm_client()

        cls.repo_api = RepositoriesRpmApi(cls.rpm_client)
        cls.remote_api = RemotesRpmApi(cls.rpm_client)
        cls.exporter_api = ExportersPulpApi(cls.core_client)
        cls.exports_api = ExportersPulpExportsApi(cls.core_client)
        cls.importer_api = ImportersPulpApi(cls.core_client)
        cls.imports_api = ImportersPulpImportsApi(cls.core_client)

        cls.import_repos, cls.export_repos, cls.remotes = cls._setup_repositories()
        cls.exporter = cls._create_exporter()
        cls.export = cls._create_export()
        cls.chunked_export = cls._create_chunked_export()
Exemple #6
0
    def setUpClass(cls):
        """Create class-wide variables."""
        cls.cfg = config.get_config()
        cls.client = api.Client(cls.cfg, api.json_handler)
        cls.core_client = CoreApiClient(configuration=cls.cfg.get_bindings_config())
        cls.rpm_client = gen_rpm_client()

        cls.repo_api = RepositoriesRpmApi(cls.rpm_client)
        cls.remote_api = RemotesRpmApi(cls.rpm_client)
        cls.exporter_api = ExportersPulpApi(cls.core_client)
        cls.exports_api = ExportersPulpExportsApi(cls.core_client)
        cls.importer_api = ImportersPulpApi(cls.core_client)
        cls.imports_api = ImportersPulpImportsApi(cls.core_client)
        cls.dist_tree_api = ContentDistributionTreesApi(cls.rpm_client)

        cls.import_repos, cls.export_repos, cls.remotes = cls._setup_repositories(
            RPM_UNSIGNED_FIXTURE_URL
        )
        cls.exporter = cls._create_exporter()
        cls.export = cls._create_export()
    def test_import_export(self):
        """
        Test exporting and importing of a container repository.
        """
        core_client = CoreApiClient(configuration)
        container_client = ContainerApiClient(configuration)
        remotes_api = RemotesContainerApi(container_client)
        repositories_api = RepositoriesContainerApi(container_client)
        repository_versions_api = RepositoriesContainerVersionsApi(
            container_client)
        manifests_api = ContentManifestsApi(container_client)
        exporters_api = ExportersPulpApi(core_client)
        exports_api = ExportersPulpExportsApi(core_client)
        importers_api = ImportersPulpApi(core_client)
        imports_api = ImportersPulpImportsApi(core_client)

        # Setup
        remote = remotes_api.create(gen_container_remote())
        self.addCleanup(remotes_api.delete, remote.pulp_href)
        sync_data = ContainerRepositorySyncURL(remote=remote.pulp_href)
        repository = repositories_api.create(gen_repo())
        self.addCleanup(repositories_api.delete, repository.pulp_href)
        sync_response = repositories_api.sync(repository.pulp_href, sync_data)
        monitor_task(sync_response.task).created_resources

        # Export the repository
        body = {
            "name": uuid4(),
            "path": "/tmp/{}/".format(uuid4()),
            "repositories": [repository.pulp_href],
        }
        exporter = exporters_api.create(body)
        self.addCleanup(exporters_api.delete, exporter.pulp_href)

        export_response = exports_api.create(exporter.pulp_href, {})
        export_href = monitor_task(export_response.task).created_resources[0]
        export = exports_api.read(export_href)

        # Clean the old repository out
        monitor_task(
            repository_versions_api.delete(
                repository.latest_version_href).task)
        delete_orphans()

        # Import the repository
        import_repository = repositories_api.create(gen_repo())
        self.addCleanup(repositories_api.delete, import_repository.pulp_href)

        body = {
            "name": uuid4(),
            "repo_mapping": {
                repository.name: import_repository.name
            },
        }
        importer = importers_api.create(body)
        self.addCleanup(importers_api.delete, importer.pulp_href)

        filenames = [
            f for f in list(export.output_file_info.keys())
            if f.endswith("tar.gz")
        ]
        import_response = imports_api.create(importer.pulp_href,
                                             {"path": filenames[0]})
        if hasattr(import_response, "task_group"):
            task_group_href = import_response.task_group
        else:
            task_group_href = monitor_task(
                import_response.task).created_resources[1]
        monitor_task_group(task_group_href)

        # Verify that the imported repository contains the right associations
        import_repository = repositories_api.read(import_repository.pulp_href)
        manifests = manifests_api.list(
            repository_version=import_repository.latest_version_href).results

        for manifest in manifests:
            if "manifest.list" in manifest.media_type:
                self.assertNotEqual(manifest.listed_manifests, [])
            else:
                self.assertNotEqual(manifest.blobs, [])
                self.assertIsNotNone(manifest.config_blob)