How to use the pulpcore.plugin.models.Content 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 / pulpcore / pulpcore / plugin / stages / association_stages.py View on Github external
with ProgressReport(message="Associating Content", code="associating.content") as pb:
            to_delete = set(self.new_version.content.values_list("pk", flat=True))
            async for batch in self.batches():
                to_add = set()
                for d_content in batch:
                    try:
                        to_delete.remove(d_content.content.pk)
                    except KeyError:
                        to_add.add(d_content.content.pk)

                if to_add:
                    self.new_version.add_content(Content.objects.filter(pk__in=to_add))
                    pb.increase_by(len(to_add))

            if to_delete:
                await self.put(Content.objects.filter(pk__in=to_delete))
github pulp / pulp_docker / pulp_docker / app / viewsets.py View on Github external
def create(self, request):
        """
        Queues a task that creates a new RepositoryVersion by adding content units.
        """
        add_content_units = []
        serializer = serializers.RecursiveManageSerializer(data=request.data)
        serializer.is_valid(raise_exception=True)
        repository = serializer.validated_data['repository']

        if 'content_units' in request.data:
            for url in request.data['content_units']:
                content = NamedModelViewSet.get_resource(url, Content)
                add_content_units.append(content.pk)

        result = enqueue_with_reservation(
            tasks.recursive_add_content, [repository],
            kwargs={
                'repository_pk': repository.pk,
                'content_units': add_content_units,
            }
        )
        return OperationPostponedResponse(result, request)
github pulp / pulp_rpm / pulp_rpm / app / models.py View on Github external
version = models.CharField(max_length=255)
    context = models.CharField(max_length=255)
    arch = models.CharField(max_length=255)

    dependencies = JSONField(default=list)
    artifacts = JSONField(default=list)
    packages = models.ManyToManyField(Package)

    class Meta:
        default_related_name = "%(app_label)s_%(model_name)s"
        unique_together = (
            'name', 'stream', 'version', 'context', 'arch'
        )


class ModulemdDefaults(Content):
    """
    The "Modulemd Defaults" content type. Modularity support.

    Fields:
        module (Text):
            Modulemd name.
        stream (Text):
            Modulemd default stream.
        profiles (Text):
            Default profiles for modulemd streams.
        digest (Text):
            Modulemd digest
    """

    TYPE = "modulemd_defaults"
github pulp / pulp_rpm / pulp_rpm / app / models.py View on Github external
PULP_GROUP_ATTRS,
    PULP_LANGPACKS_ATTRS,
    PULP_PACKAGE_ATTRS,
    PULP_UPDATE_COLLECTION_ATTRS,
    PULP_UPDATE_COLLECTION_ATTRS_MODULE,
    PULP_UPDATE_COLLECTION_PACKAGE_ATTRS,
    PULP_UPDATE_RECORD_ATTRS,
    PULP_UPDATE_REFERENCE_ATTRS,
)

from pulp_rpm.app.comps import strdict_to_dict, list_to_idlist

log = getLogger(__name__)


class Package(Content):
    """
    The "Package" content type. Formerly "rpm" in Pulp 2.

    Maps directly to the fields provided by createrepo_c.
    https://github.com/rpm-software-management/createrepo_c/

    Fields:
        name (Text):
            Name of the package
        epoch (Text):
            The package's epoch
        version (Text):
            The version of the package. For example, '2.8.0'
        release (Text):
            The release of a particular version of the package. Although this field
            can technically be anything, packaging guidelines usually require it to
github pulp / pulp_ansible / pulp_ansible / app / galaxy / v3 / views.py View on Github external
def get_distro_content(path):
        """Returns distribution content."""
        distro = get_object_or_404(AnsibleDistribution, base_path=path)
        if distro.repository_version:
            return distro.repository_version.content
        else:
            repo_version = distro.repository.latest_version()
            if repo_version is None:
                return Content.objects.none()
            else:
                return repo_version.content
github pulp / pulp_rpm / pulp_rpm / app / models / distribution.py View on Github external
from logging import getLogger

from django.db import models

from pulpcore.plugin.models import (
    BaseModel,
    Content,
    ContentArtifact,
    Repository,
)

log = getLogger(__name__)


class DistributionTree(Content):
    """
    Model for an RPM distribution tree (also sometimes referenced as an installable tree).

    A distribution tree is described by a file in root of an RPM repository named either
    "treeinfo" or ".treeinfo". This INI file is used by system installers to boot from a URL.
    It describes the operating system or product contained in the distribution tree and
    where the bootable media is located for various platforms (where platform means
    'x86_64', 'xen', or similar).

    The description of the "treeinfo" format is included below, originally take from
    https://release-engineering.github.io/productmd/treeinfo-1.0.html

    Fields:
        header_version (Text):
            Metadata version
        release_name (Text):
github pulp / pulp_rpm / pulp_rpm / app / models.py View on Github external
repository = models.ForeignKey(
        Repository, on_delete=models.PROTECT, related_name='+'
    )

    class Meta:
        unique_together = (
            "variant_id",
            "uid",
            "name",
            "type",
            "packages",
            "distribution_tree",
        )


class RepoMetadataFile(Content):
    """
    Model for custom/unknown repository metadata.

    Fields:
        data_type (Text):
            Metadata type
        checksum_type (Text):
            Checksum type for the file
        checksum (Text):
            Checksum value for the file

    """

    TYPE = 'repo_metadata_file'

    data_type = models.CharField(max_length=20)
github pulp / pulp_rpm / pulp_rpm / app / models / comps.py View on Github external
LIBCOMPS_CATEGORY_ATTRS,
    LIBCOMPS_ENVIRONMENT_ATTRS,
    LIBCOMPS_GROUP_ATTRS,
    PULP_CATEGORY_ATTRS,
    PULP_ENVIRONMENT_ATTRS,
    PULP_GROUP_ATTRS,
    PULP_LANGPACKS_ATTRS,
)

from pulp_rpm.app.comps import strdict_to_dict, list_to_idlist
from pulp_rpm.app.models.package import Package

log = getLogger(__name__)


class PackageGroup(Content):
    """
    The "PackageGroup" content type.

    Maps directly to the fields provided by libcomps.
    https://github.com/rpm-software-management/libcomps

    Fields:

        id (Text):
            ID of the group
        default (Bool):
            Flag to identify whether the group is a default
        user_visible (Bool):
            Flag to identify if the group is visible to the user

        display_order (Int):
github pulp / pulp_deb / pulp_deb / app / models / content.py View on Github external
This model is meant to map to all files in the upstream repository, that
    are not handled by a more specific model.
    Those units are used for the verbatim publish method.
    """

    TYPE = "generic"

    relative_path = models.TextField(null=False)
    sha256 = models.CharField(max_length=255, null=False)

    class Meta:
        default_related_name = "%(app_label)s_%(model_name)s"
        unique_together = (("relative_path", "sha256"),)


class ReleaseFile(Content):
    """
    The "ReleaseFile" content.

    This model holds an artifact to the upstream Release file.
    """

    TYPE = "release_file"

    codename = models.CharField(max_length=255)
    suite = models.CharField(max_length=255)
    distribution = models.CharField(max_length=255)
    components = models.CharField(max_length=255, blank=True)
    architectures = models.CharField(max_length=255, blank=True)
    relative_path = models.TextField()
    sha256 = models.CharField(max_length=255)
github pulp / pulp_rpm / pulp_rpm / app / models.py View on Github external
class Meta:
        default_related_name = "%(app_label)s_%(model_name)s"


class RpmDistribution(PublicationDistribution):
    """
    Distribution for "rpm" content.
    """

    TYPE = 'rpm'

    class Meta:
        default_related_name = "%(app_label)s_%(model_name)s"


class Modulemd(Content):
    """
    The "Modulemd" content type. Modularity support.

    Fields:
        name (Text):
            Name of the modulemd
        stream (Text):
            The modulemd's stream
        version (Text):
            The version of the modulemd.
        context (Text):
            The context flag serves to distinguish module builds with the
            same name, stream and version and plays an important role in
            future automatic module stream name expansion.
        arch (Text):
            Module artifact architecture.