Esempio n. 1
0
    def pipeline_stages(self, new_version):
        """
        Build a list of stages feeding into the ContentUnitAssociation stage.

        This defines the "architecture" of the entire sync.

        Args:
            new_version (:class:`~pulpcore.plugin.models.RepositoryVersion`): The
                new repository version that is going to be built.

        Returns:
            list: List of :class:`~pulpcore.plugin.stages.Stage` instances

        """
        pipeline = [
            self.first_stage,
            QueryExistingArtifacts(),
            ArtifactDownloader(),
            ArtifactSaver(),
            QueryExistingContents(),
            ContentSaver(),
            RemoteArtifactSaver(),
            ResolveContentFutures(),
            InterrelateContent(),
        ]

        return pipeline
Esempio n. 2
0
    def pipeline_stages(self, new_version):
        """
        Build the list of pipeline stages feeding into the ContentAssociation stage.

        Args:
            new_version (:class:`~pulpcore.plugin.models.RepositoryVersion`): The
                new repository version that is going to be built.

        Returns:
            list: List of :class:`~pulpcore.plugin.stages.Stage` instances

        """
        pipeline = [
            self.first_stage,
            QueryExistingArtifacts(),
            ArtifactDownloader(),
            DebDropEmptyContent(),
            ArtifactSaver(),
            # This is dependent on
            # https://salsa.debian.org/python-debian-team/python-debian/merge_requests/11
            # DebUpdatePackageAttributes(),
            DebUpdateReleaseAttributes(self.first_stage.components,
                                       self.first_stage.architectures),
            DebUpdatePackageIndexAttributes(),
            QueryExistingContents(),
            ContentSaver(),
            RemoteArtifactSaver(),
            ResolveContentFutures(),
        ]
        return pipeline
Esempio n. 3
0
    def pipeline_stages(self, new_version):
        """
        Build the list of pipeline stages feeding into the ContentAssociation stage.

        Args:
            new_version (:class:`~pulpcore.plugin.models.RepositoryVersion`): The
                new repository version that is going to be built.

        Returns:
            list: List of :class:`~pulpcore.plugin.stages.Stage` instances

        """
        pipeline = [
            self.first_stage,
            QueryExistingArtifacts(),
            ArtifactDownloader(),
            DebDropFailedArtifacts(),
            ArtifactSaver(),
            DebUpdateReleaseFileAttributes(remote=self.first_stage.remote),
            DebUpdatePackageIndexAttributes(),
            QueryExistingContents(),
            ContentSaver(),
            RemoteArtifactSaver(),
            ResolveContentFutures(),
        ]
        return pipeline
Esempio n. 4
0
    def pipeline_stages(self, new_version):
        """
        Build a list of stages feeding into the ContentUnitAssociation stage.

        This defines the "architecture" of the entire sync.

        Args:
            new_version (:class:`~pulpcore.plugin.models.RepositoryVersion`): The
                new repository version that is going to be built.

        Returns:
            list: List of :class:`~pulpcore.plugin.stages.Stage` instances

        """
        pipeline = [
            self.first_stage,
            QueryExistingArtifacts(),
            ArtifactDownloader(),
            ArtifactSaver(),
            QueryExistingContents(),
            RpmContentSaver(),
            RemoteArtifactSaver(),
        ]
        for dupe_query_dict in self.remove_duplicates:
            pipeline.append(RemoveDuplicates(new_version, **dupe_query_dict))

        return pipeline
Esempio n. 5
0
def synchronize(remote_pk, repository_pk):
    """
    Sync content from the remote repository.

    Create a new version of the repository that is synchronized with the remote.

    Args:
        remote_pk (str): The remote PK.
        repository_pk (str): The repository PK.

    Raises:
        ValueError: If the remote does not specify a url to sync.

    """
    remote = RpmRemote.objects.get(pk=remote_pk)
    repository = Repository.objects.get(pk=repository_pk)

    dupe_criteria = {'model': Package,
                     'field_names': ['name', 'epoch', 'version', 'release', 'arch']}

    if not remote.url:
        raise ValueError(_('A remote must have a url specified to synchronize.'))

    log.info(_('Synchronizing: repository={r} remote={p}').format(
        r=repository.name, p=remote.name))

    download_artifacts = (remote.policy == Remote.IMMEDIATE)
    first_stage = RpmFirstStage(remote)
    with WorkingDirectory():
        with RepositoryVersion.create(repository) as new_version:
            loop = asyncio.get_event_loop()
            remove_duplicates_stage = RemoveDuplicates(new_version, **dupe_criteria)
            stages = [first_stage]

            if download_artifacts:
                stages.extend([QueryExistingArtifacts(), ArtifactDownloader(), ArtifactSaver()])

            stages.extend([
                QueryExistingContents(), ErratumContentSaver(), remove_duplicates_stage,
                ContentAssociation(new_version), EndStage()
            ])
            pipeline = create_pipeline(stages)
            loop.run_until_complete(pipeline)
Esempio n. 6
0
    def pipeline_stages(self):
        """
        Build a list of stages.

        This defines the "architecture" of the content migration to Pulp 3.

        Returns:
            list: List of :class:`~pulpcore.plugin.stages.Stage` instances

        """
        pipeline = [
            self.first_stage,
            QueryExistingArtifacts(),
            ArtifactSaver(),
            QueryExistingContents(),
            ContentSaver(),
            RelatePulp2to3Content()
        ]

        return pipeline
Esempio n. 7
0
def synchronize(remote_pk, repository_pk):
    """
    Sync content from the remote repository.

    Create a new version of the repository that is synchronized with the remote.

    Args:
        remote_pk (str): The remote PK.
        repository_pk (str): The repository PK.

    Raises:
        ValueError: If the remote does not specify a url to sync.

    """
    remote = RpmRemote.objects.get(pk=remote_pk)
    repository = Repository.objects.get(pk=repository_pk)

    if not remote.url:
        raise ValueError(
            _('A remote must have a url specified to synchronize.'))

    log.info(
        _('Synchronizing: repository={r} remote={p}').format(r=repository.name,
                                                             p=remote.name))

    first_stage = RpmFirstStage(remote)
    with WorkingDirectory():
        with RepositoryVersion.create(repository) as new_version:
            loop = asyncio.get_event_loop()
            stages = [
                first_stage,
                QueryExistingArtifacts(),
                ArtifactDownloader(),
                ArtifactSaver(),
                QueryExistingContentUnits(),
                ErratumContentUnitSaver(),
                ContentUnitAssociation(new_version),
                EndStage()
            ]
            pipeline = create_pipeline(stages)
            loop.run_until_complete(pipeline)