How to use the pulpcore.plugin.models.RemoteArtifact function in pulpcore

To help you get started, we’ve selected a few pulpcore examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pulp / pulp / plugin / pulpcore / plugin / changeset / model.py View on Github external
content=self.content.stored_model,
                    artifact=self._stored_model)
                content_artifact.save()
        except IntegrityError:
            content_artifact = ContentArtifact.objects.get(
                relative_path=self.relative_path,
                content=self.content.stored_model)
            if self._stored_model:
                content_artifact.artifact = self._stored_model
                content_artifact.save()

        digests = {f: getattr(self._model, f) for f in Artifact.DIGEST_FIELDS}

        try:
            with transaction.atomic():
                remote_artifact = RemoteArtifact(
                    url=self.url,
                    remote=self.remote,
                    content_artifact=content_artifact,
                    size=self._model.size,
                    **digests)
                remote_artifact.save()
        except IntegrityError:
            q_set = RemoteArtifact.objects.filter(
                remote=self.remote,
                content_artifact=content_artifact)
            q_set.update(
                url=self.url,
                size=self._model.size,
                **digests)
github pulp / pulp / plugin / pulpcore / plugin / stages.py View on Github external
remote_artifact_data = {
                                'url': declarative_artifact.url,
                                'size': declarative_artifact.artifact.size,
                                'md5': declarative_artifact.artifact.md5,
                                'sha1': declarative_artifact.artifact.sha1,
                                'sha224': declarative_artifact.artifact.sha224,
                                'sha256': declarative_artifact.artifact.sha256,
                                'sha384': declarative_artifact.artifact.sha384,
                                'sha512': declarative_artifact.artifact.sha512,
                                'remote': declarative_artifact.remote,
                            }
                            remote_artifact_map[content_artifact.relative_path] = remote_artifact_data

            for content_artifact in ContentArtifact.objects.bulk_create(content_artifact_bulk):
                remote_artifact_data = remote_artifact_map.pop(content_artifact.relative_path)
                new_remote_artifact = RemoteArtifact(
                    content_artifact=content_artifact, **remote_artifact_data
                )
                remote_artifact_bulk.append(new_remote_artifact)

            RemoteArtifact.objects.bulk_create(remote_artifact_bulk)

        for declarative_content in declarative_content_list:
            if declarative_content is None:
                continue
            await out_q.put(declarative_content)
        if shutdown:
            break
        declarative_content_list = []
    await out_q.put(None)
github pulp / pulpcore / pulpcore / plugin / stages / artifact_stages.py View on Github external
def _create_remote_artifact(d_artifact, content_artifact):
        return RemoteArtifact(
            url=d_artifact.url,
            size=d_artifact.artifact.size,
            md5=d_artifact.artifact.md5,
            sha1=d_artifact.artifact.sha1,
            sha224=d_artifact.artifact.sha224,
            sha256=d_artifact.artifact.sha256,
            sha384=d_artifact.artifact.sha384,
            sha512=d_artifact.artifact.sha512,
            content_artifact=content_artifact,
            remote=d_artifact.remote,
        )
github pulp / pulp / plugin / pulpcore / plugin / changeset / model.py View on Github external
content_artifact.artifact = self._stored_model
                content_artifact.save()

        digests = {f: getattr(self._model, f) for f in Artifact.DIGEST_FIELDS}

        try:
            with transaction.atomic():
                remote_artifact = RemoteArtifact(
                    url=self.url,
                    remote=self.remote,
                    content_artifact=content_artifact,
                    size=self._model.size,
                    **digests)
                remote_artifact.save()
        except IntegrityError:
            q_set = RemoteArtifact.objects.filter(
                remote=self.remote,
                content_artifact=content_artifact)
            q_set.update(
                url=self.url,
                size=self._model.size,
                **digests)
github pulp / pulpcore / plugin / pulpcore / plugin / changeset / model.py View on Github external
content=self.content.stored_model,
                    artifact=self._stored_model)
                content_artifact.save()
        except IntegrityError:
            content_artifact = ContentArtifact.objects.get(
                relative_path=self.relative_path,
                content=self.content.stored_model)
            if self._stored_model:
                content_artifact.artifact = self._stored_model
                content_artifact.save()

        digests = {f: getattr(self._model, f) for f in Artifact.DIGEST_FIELDS}

        try:
            with transaction.atomic():
                remote_artifact = RemoteArtifact(
                    url=self.url,
                    remote=self.remote,
                    content_artifact=content_artifact,
                    size=self._model.size,
                    **digests)
                remote_artifact.save()
        except IntegrityError:
            q_set = RemoteArtifact.objects.filter(
                remote=self.remote,
                content_artifact=content_artifact)
            q_set.update(
                url=self.url,
                size=self._model.size,
                **digests)
github pulp / pulp_docker / pulp_docker / app / tasks / dedupe_save.py View on Github external
artifact=da.artifact,
                    relative_path=da.relative_path
                )

            remote_artifact_data = {
                'url': da.url,
                'size': da.artifact.size,
                'md5': da.artifact.md5,
                'sha1': da.artifact.sha1,
                'sha224': da.artifact.sha224,
                'sha256': da.artifact.sha256,
                'sha384': da.artifact.sha384,
                'sha512': da.artifact.sha512,
                'remote': da.remote,
            }
            new_remote_artifact = RemoteArtifact(
                content_artifact=content_artifact, **remote_artifact_data
            )
            try:
                new_remote_artifact.save()
            except IntegrityError:
                pass
github pulp / pulp / plugin / pulpcore / plugin / stages / content_unit_stages.py View on Github external
'sha224': declarative_artifact.artifact.sha224,
                                    'sha256': declarative_artifact.artifact.sha256,
                                    'sha384': declarative_artifact.artifact.sha384,
                                    'sha512': declarative_artifact.artifact.sha512,
                                    'remote': declarative_artifact.remote,
                                }
                                rel_path = declarative_artifact.relative_path
                                content_key = str(content_artifact.content.pk) + rel_path
                                remote_artifact_map[content_key] = remote_artifact_data

                for content_artifact in ContentArtifact.objects.bulk_get_or_create(
                        content_artifact_bulk):
                    rel_path = content_artifact.relative_path
                    content_key = str(content_artifact.content.pk) + rel_path
                    remote_artifact_data = remote_artifact_map.pop(content_key)
                    new_remote_artifact = RemoteArtifact(
                        content_artifact=content_artifact, **remote_artifact_data
                    )
                    remote_artifact_bulk.append(new_remote_artifact)

                RemoteArtifact.objects.bulk_get_or_create(remote_artifact_bulk)
                await self._post_save(batch)

            for declarative_content in batch:
                await out_q.put(declarative_content)
        await out_q.put(None)
github pulp / pulp / plugin / pulpcore / plugin / stages.py View on Github external
'sha224': declarative_artifact.artifact.sha224,
                                'sha256': declarative_artifact.artifact.sha256,
                                'sha384': declarative_artifact.artifact.sha384,
                                'sha512': declarative_artifact.artifact.sha512,
                                'remote': declarative_artifact.remote,
                            }
                            remote_artifact_map[content_artifact.relative_path] = remote_artifact_data

            for content_artifact in ContentArtifact.objects.bulk_create(content_artifact_bulk):
                remote_artifact_data = remote_artifact_map.pop(content_artifact.relative_path)
                new_remote_artifact = RemoteArtifact(
                    content_artifact=content_artifact, **remote_artifact_data
                )
                remote_artifact_bulk.append(new_remote_artifact)

            RemoteArtifact.objects.bulk_create(remote_artifact_bulk)

        for declarative_content in declarative_content_list:
            if declarative_content is None:
                continue
            await out_q.put(declarative_content)
        if shutdown:
            break
        declarative_content_list = []
    await out_q.put(None)