pulp.app.models

class pulpcore.app.models.Artifact(*args, **kwargs)

A file associated with a piece of content.

When calling save() on an Artifact, if the file is not stored in Django’s storage backend, it is moved into place then.

Artifact is compatible with Django’s bulk_create() method.

Fields
  • file (models.FileField) – The stored file. This field should be set using an absolute path to a temporary file. It also accepts class:django.core.files.File.

  • size (models.IntegerField) – The size of the file in bytes.

  • md5 (models.CharField) – The MD5 checksum of the file.

  • sha1 (models.CharField) – The SHA-1 checksum of the file.

  • sha224 (models.CharField) – The SHA-224 checksum of the file.

  • sha256 (models.CharField) – The SHA-256 checksum of the file.

  • sha384 (models.CharField) – The SHA-384 checksum of the file.

  • sha512 (models.CharField) – The SHA-512 checksum of the file.

exception DoesNotExist
exception MultipleObjectsReturned
delete(*args, **kwargs)

Deletes Artifact model and the file associated with the Artifact

Parameters
  • args (list) – list of positional arguments for Model.delete()

  • kwargs (dict) – dictionary of keyword arguments to pass to Model.delete()

get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
static init_and_validate(file, expected_digests=None, expected_size=None)

Initialize an in-memory Artifact from a file, and validate digest and size info.

This accepts both a path to a file on-disk or a PulpTemporaryUploadedFile.

Parameters
  • file (PulpTemporaryUploadedFile or str) – The PulpTemporaryUploadedFile to create the Artifact from or a string with the full path to the file on disk.

  • expected_digests (dict) – Keyed on the algorithm name provided by hashlib and stores the value of the expected digest. e.g. {‘md5’: ‘912ec803b2ce49e4a541068d495ab570’}

  • expected_size (int) – The number of bytes the download is expected to have.

:raises DigestValidationError: When any of the expected_digest values don’t match the digest of the data :raises SizeValidationError: When the expected_size value doesn’t match the size of the data

Returns

An in-memory, unsaved Artifact

is_equal(other)

Is equal by matching digest.

Parameters

other (pulpcore.app.models.Artifact) – A artifact to match.

Returns

True when equal.

Return type

bool

q()
save(*args, **kwargs)

Saves Artifact model and closes the file associated with the Artifact

Parameters
  • args (list) – list of positional arguments for Model.save()

  • kwargs (dict) – dictionary of keyword arguments to pass to Model.save()

storage_path(name)

Callable used by FileField to determine where the uploaded file should be stored.

Parameters

name (str) – Original name of uploaded file. It is ignored by this method because the sha256 checksum is used to determine a file path instead.

DIGEST_FIELDS = ('sha512', 'sha384', 'sha256', 'sha224', 'sha1', 'md5')
RELIABLE_DIGEST_FIELDS = ('sha512', 'sha384', 'sha256')
content_set

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

contentartifact_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

file

The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:

>>> from myapp.models import MyModel
>>> instance = MyModel.objects.get(pk=1)
>>> instance.file.size

Assign a file object on assignment so you can do:

>>> with open('/path/to/hello.world', 'r') as f:
...     instance.file = File(f)
md5

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <pulpcore.app.models.content.BulkCreateManager object>
sha1

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

sha224

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

sha256

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

sha384

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

sha512

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

size

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class pulpcore.app.models.BaseDistribution(*args, **kwargs)

A distribution defines how a publication is distributed by the Content App.

This abstract model can be used by plugin writers to create concrete distributions that are stored in separate tables from the Distributions provided by pulpcore.

The name must be unique.

The base_path must have no overlapping components. So if a Distribution with base_path of a/path/foo existed, you could not make a second Distribution with a base_path of a/path or a because both are subpaths of a/path/foo.

Fields
  • name (models.CharField) – The name of the distribution. Examples: “rawhide” and “stable”.

  • base_path (models.CharField) – The base (relative) path component of the published url.

Relations
  • content_guard (models.ForeignKey) – An optional content-guard.

  • remote (models.ForeignKey) – A remote that the content app can use to find content not yet stored in Pulp.

exception DoesNotExist
exception MultipleObjectsReturned
get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
base_path

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

content_guard

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

content_guard_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
remote

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

remote_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class pulpcore.app.models.Content(*args, **kwargs)

A piece of managed content.

Relations

_artifacts (models.ManyToManyField) – Artifacts related to Content through ContentArtifact

exception DoesNotExist
exception MultipleObjectsReturned
get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
natural_key()

Get the model’s natural key based on natural_key_fields.

Returns

The natural key.

Return type

tuple

natural_key_dict()

Get the model’s natural key as a dictionary of keys and values.

classmethod natural_key_fields()

Returns a tuple of the natural key fields which usually equates to unique_together fields

TYPE = 'content'
contentartifact_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

objects = <pulpcore.app.models.content.BulkCreateManager object>
repositories

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

version_memberships

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class pulpcore.app.models.ContentAppStatus(*args, **kwargs)

Represents a Content App Status

Fields
  • name (models.CharField) – The name of the content app

  • last_heartbeat (models.DateTimeField) – A timestamp of this worker’s last heartbeat

exception DoesNotExist
exception MultipleObjectsReturned
get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_next_by_last_heartbeat(*, field=<django.db.models.fields.DateTimeField: last_heartbeat>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
get_previous_by_last_heartbeat(*, field=<django.db.models.fields.DateTimeField: last_heartbeat>, is_next=False, **kwargs)
save_heartbeat()

Update the last_heartbeat field to now and save it.

Only the last_heartbeat field will be saved. No other changes will be saved.

Raises

ValueError – When the model instance has never been saved before. This method can only update an existing database record.

last_heartbeat

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property missing

Whether a Content App can be considered ‘missing’

To be considered ‘missing’, a Content App must have a timestamp older than SETTINGS.CONTENT_APP_TTL.

Returns

True if the content app is considered missing, otherwise False

Return type

bool

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <pulpcore.app.models.status.ContentAppStatusManager object>
property online

Whether a content app can be considered ‘online’

To be considered ‘online’, a content app must have a heartbeat timestamp more recent than the CONTENT_APP_TTL setting.

Returns

True if the content app is considered online, otherwise False

Return type

bool

class pulpcore.app.models.ContentArtifact(*args, **kwargs)

A relationship between a Content and an Artifact.

Serves as a through model for the ‘_artifacts’ ManyToManyField in Content. Artifact is protected from deletion if it’s present in a ContentArtifact relationship.

exception DoesNotExist
exception MultipleObjectsReturned
get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
artifact

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

artifact_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

content

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

content_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <pulpcore.app.models.content.BulkCreateManager object>
published_artifact

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

relative_path

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

remoteartifact_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class pulpcore.app.models.ContentGuard(*args, **kwargs)

Defines a named content guard.

Fields
  • name (models.CharField) – Unique guard name.

  • description (models.TextField) – An optional description.

exception DoesNotExist
exception MultipleObjectsReturned
get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
basedistribution_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

description

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
class pulpcore.app.models.CreatedResource(*args, **kwargs)

Resources created by the task.

Relations

task (models.ForeignKey) – The task that created the resource.

exception DoesNotExist
exception MultipleObjectsReturned
get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
content_object

Provide a generic many-to-one relation through the content_type and object_id fields.

This class also doubles as an accessor to the related object (similar to ForwardManyToOneDescriptor) by adding itself as a model attribute.

content_type

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

objects = <django.db.models.manager.Manager object>
task

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

task_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class pulpcore.app.models.Exporter(*args, **kwargs)

A publication exporter.

Fields
  • name (models.CharField) – The exporter unique name.

  • last_export (models.DatetimeField) – When the last successful export occurred.

Relations:

exception DoesNotExist
exception MultipleObjectsReturned
get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
TYPE = 'exporter'
last_export

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
class pulpcore.app.models.GenericRelationModel(*args, **kwargs)

Base model class for implementing Generic Relations.

This class provides the required fields to implement generic relations. Instances of this class can only be related models with a primary key, such as those subclassing Pulp’s base Model class.

class Meta
abstract = False
get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
content_object

Provide a generic many-to-one relation through the content_type and object_id fields.

This class also doubles as an accessor to the related object (similar to ForwardManyToOneDescriptor) by adding itself as a model attribute.

content_type

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

content_type_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

object_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class pulpcore.app.models.MasterModel(*args, **kwargs)

Base model for the “Master” model in a “Master-Detail” relationship.

Provides methods for casting down to detail types, back up to the master type, as well as a model field for tracking the type.

Variables

TYPE (str) – Default constant value saved into the _type field of Model instances

Fields

_type – The user-facing string identifying the detail type of this model

Warning

Subclasses of this class rely on there being no other parent/child Model relationships than the Master/Detail relationship. All subclasses must use only abstract Model base classes for MasterModel to behave properly. Specifically, OneToOneField relationships must not be used in any MasterModel subclass.

class Meta
abstract = False
cast()

Return a “Detail” model instance of this master-detail pair.

If this model is already an instance of its detail type, it will return itself.

get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
save(*args, **kwargs)

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

TYPE = None
property master

The “Master” model instance of this master-detail pair

If this is already the master model instance, it will return itself.

class pulpcore.app.models.Model(*args, **kwargs)

Base model class for all Pulp models.

Fields
  • _created (models.DateTimeField) – Created timestamp UTC.

  • _last_updated (models.DateTimeField) – Last updated timestamp UTC.

References

class Meta
abstract = False
get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
class pulpcore.app.models.ProgressBar(*args, **kwargs)

Shows progress reporting when the count of items is known.

Plugin writers should create these objects to show progress reporting of a single step or aspect of work which has a name and state along with total and done counts. For example:

>>> ProgressBar(
>>>     message='Publishing files', code='publish', total=23
>>> )  # default: state='waiting' and done=0
>>> ProgressBar(
>>>     message='Publishing files', code='publish', total=23, state='running'
>>> )  # specify the state
>>> ProgressBar(
>>>     message='Publishing files', code='publish', total=23, done=16
>>> )  # already completed 16

Update the state to COMPLETED and save it:

>>> progress_bar = ProgressBar(
>>>     message='Publishing files', code='publish', total=23, state='running'
>>> )
>>> progress_bar.state = 'completed'
>>> progress_bar.save()

The ProgressBar() is a context manager that provides automatic state transitions and saving for the RUNNING CANCELED COMPLETED and FAILED states. The increment() method can be called in the loop as work is completed. When ProgressBar() is used as a context manager progress reporting is rate limited to every 500 milliseconds. Use it as follows:

>>> progress_bar = ProgressBar(
>>>     message='Publishing files', code='publish', total=len(files_iterator)
>>> )
>>> progress_bar.save()
>>> with progress_bar:
>>>     # progress_bar saved as 'running'
>>>     for file in files_iterator:
>>>         handle(file)
>>>         progress_bar.increment()  # increments and saves
>>> # progress_bar is saved as 'completed' if no exception or 'failed' otherwise

A convenience method called iter() allows you to avoid calling increment() directly:

>>> progress_bar = ProgressBar(
>>>     message='Publishing files', code='publish', total=len(files_iterator)
>>> )
>>> progress_bar.save()
>>> with progress_bar:
>>>     for file in progress_bar.iter(files_iterator):
>>>         handle(file)

You can also use this short form which handles all necessary save() calls:

>>> data = dict(message='Publishing files', code='publish', total=len(files_iterator))
>>> with ProgressBar(**data) as pb:
>>>     for file in pb.iter(files_iterator):
>>>         handle(file)

ProgressBar objects are associated with a Task and auto-discover and populate the task id when saved.

When using threads to update a ProgressBar in parallel, it is recommended that all threads share the same in-memory instance. Django does not synchronize in-memory model instances, so multiple instances of a specific ProgressBar will diverge as they are written to from separate threads.

exception DoesNotExist
exception MultipleObjectsReturned
increment()

Increment done count and save the progress bar.

This will increment and save the self.done attribute which is useful to put into a loop processing items.

iter(iter)

Iterate and automatically call increment().

>>> progress_bar = ProgressBar(message='Publishing files', code='publish', total=23)
>>> progress_bar.save()
>>> for file in progress_bar.iter(files_iterator):
>>>     handle(file)
Parameters

iter (iterator) – The iterator to loop through while incrementing

Returns

generator of iter argument items

class pulpcore.app.models.ProgressReport(*args, **kwargs)

A base model for all progress reporting.

All progress reports have a message, state, and are related to a Task.

Fields
  • message (models.TextField) – short message for the progress update, typically shown to the user. (required)

  • code (models.CharField) – identifies the type of progress report

  • state (models.TextField) – The state of the progress update. Defaults to WAITING. This field uses a limited set of choices of field states. See STATES for possible states.

  • total – (models.IntegerField) The total count of items to be handled by the ProgressBar (required)

  • done (models.IntegerField) – The count of items already processed. Defaults to 0.

  • suffix (models.TextField) – Customizable suffix rendered with the progress report See the docs. for more info.

Relations

task – The task associated with this progress report. If left unset when save() is called it will be set to the current task_id.

exception DoesNotExist
exception MultipleObjectsReturned
get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
get_state_display(*, field=<django.db.models.fields.TextField: state>)
save(*args, **kwargs)

Auto-set the task_id if running inside a task

If the task_id is already set it will not be updated. If it is unset and this is running inside of a task it will be auto-set prior to saving.

args (list): positional arguments to be passed on to the real save kwargs (dict): keyword arguments to be passed on to the real save

code

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

done

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

message

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
state

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

suffix

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

task

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

task_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

total

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class pulpcore.app.models.ProgressSpinner(*args, **kwargs)

Shows progress reporting when the count of items is not known.

Plugin writers should create these objects to show progress reporting of a single step or aspect of work which has a name and a state. For example:

>>> ProgressSpinner(message='Publishing Metadata')  # default state is 'waiting'
>>> ProgressSpinner(message='Publishing Metadata', state='running')  # specify 'running'

Update the state to COMPLETED and save it:

>>> metadata_progress = ProgressSpinner(message='Publishing Metadata', state='running')
>>> metadata_progress.state = 'completed'
>>> metadata_progress.save()

The ProgressSpinner() is a context manager that provides automatic state transitions and saving for the RUNNING CANCELED COMPLETED and FAILED states. When ProgressSpinner() is used as a context manager progress reporting is rate limited to every 500 milliseconds. Use it as follows:

>>> spinner = ProgressSpinner(message='Publishing Metadata')
>>> spinner.save() # spinner is saved as 'waiting'
>>> with spinner:
>>>     # spinner is saved as 'running'
>>>     publish_metadata()
>>> # spinner is saved as 'completed' if no exception is raised or 'failed' otherwise

You can also use this short form which handles all necessary save() calls:

>>> with ProgressSpinner(message='Publishing Metadata'):
>>>     publish_metadata()

ProgressSpinner objects are associated with a Task and auto-discover and populate the task id when saved.

exception DoesNotExist
exception MultipleObjectsReturned
class pulpcore.app.models.Publication(*args, **kwargs)

A publication contains metadata and artifacts associated with content contained within a RepositoryVersion.

Using as a context manager is highly encouraged. On context exit, the complete attribute is set True provided that an exception has not been raised. In the event and exception has been raised, the publication is deleted.

Fields
  • complete (models.BooleanField) – State tracking; for internal use. Indexed.

  • pass_through (models.BooleanField) – Indicates that the publication is a pass-through to the repository version. Enabling pass-through has the same effect as creating a PublishedArtifact for all of the content (artifacts) in the repository.

Relations
  • publisher (models.ForeignKey) – The publisher that created the publication.

  • repository_version (models.ForeignKey) – The RepositoryVersion used to create this Publication.

Examples

>>> publisher = ...
>>> repository_version = ...
>>>
>>> with Publication.create(repository_version, publisher) as publication:
>>>     for content in repository_version.content():
>>>         for content_artifact in content.contentartifact_set.all():
>>>             artifact = PublishedArtifact(...)
>>>             artifact.save()
>>>             metadata = PublishedMetadata(...)
>>>             metadata.save()
>>>             ...
>>>
exception DoesNotExist
exception MultipleObjectsReturned
classmethod create(repository_version, publisher=None, pass_through=False)

Create a publication.

This should be used to create a publication. Using Publication() directly is highly discouraged.

Parameters
  • repository_version (pulpcore.app.models.RepositoryVersion) – The repository version to be published.

  • publisher (pulpcore.app.models.Publisher) – The publisher used to create the publication.

  • pass_through (bool) – Indicates that the publication is a pass-through to the repository version. Enabling pass-through has the same effect as creating a PublishedArtifact for all of the content (artifacts) in the repository.

Returns

A created Publication in an incomplete state.

Return type

pulpcore.app.models.Publication

Notes

Adds a Task.created_resource for the publication.

delete(**kwargs)

Delete the publication.

Parameters

**kwargs (dict) – Delete options.

Notes

Deletes the Task.created_resource when complete is False.

get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
TYPE = 'publication'
complete

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
pass_through

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

published_artifact

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

published_metadata

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

publisher

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

publisher_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property repository

Return the associated repository

Returns

The repository associated to this publication

Return type

pulpcore.app.models.Repository

repository_version

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

repository_version_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class pulpcore.app.models.PublicationDistribution(*args, **kwargs)

Define how Pulp’s content app will serve a Publication.

Relations

publication (models.ForeignKey) – Publication to be served.

class Meta
abstract = False
basedistribution_ptr

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

basedistribution_ptr_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

publication

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

publication_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class pulpcore.app.models.PublishedArtifact(*args, **kwargs)

An artifact that is part of a publication.

Relations

content_artifact (models.ForeignKey) – The referenced content artifact.

exception DoesNotExist
exception MultipleObjectsReturned
get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
content_artifact

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

content_artifact_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
publication

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

class pulpcore.app.models.PublishedMetadata(*args, **kwargs)

Metadata file that is part of a publication.

Fields

file (models.FileField) – The stored file.

exception DoesNotExist
exception MultipleObjectsReturned
get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
file

The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:

>>> from myapp.models import MyModel
>>> instance = MyModel.objects.get(pk=1)
>>> instance.file.size

Assign a file object on assignment so you can do:

>>> with open('/path/to/hello.world', 'r') as f:
...     instance.file = File(f)
objects = <django.db.models.manager.Manager object>
publication

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

class pulpcore.app.models.Publisher(*args, **kwargs)

A content publisher.

Fields

name (models.CharField) – The publisher unique name.

Relations:

exception DoesNotExist
exception MultipleObjectsReturned
get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
TYPE = 'publisher'
name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
publication_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class pulpcore.app.models.Remote(*args, **kwargs)

A remote source for content.

Fields
  • name (models.CharField) – The remote name.

  • url (models.TextField) – The URL of an external content source.

  • ssl_ca_certificate (models.FileField) – A PEM encoded CA certificate used to validate the server certificate presented by the external source.

  • ssl_client_certificate (models.FileField) – A PEM encoded client certificate used for authentication.

  • ssl_client_key (models.FileField) – A PEM encoded private key used for authentication.

  • ssl_validation (models.BooleanField) – If True, SSL peer validation must be performed.

  • proxy_url (models.TextField) – The optional proxy URL. Format: scheme://user:password@host:port

  • username (models.TextField) – The username to be used for authentication when syncing.

  • password (models.TextField) – The password to be used for authentication when syncing.

  • download_concurrency (models.PositiveIntegerField) – Total number of simultaneous connections.

  • policy (models.TextField) – The policy to use when downloading content.

Relations

repository (models.ForeignKey) – The repository that owns this Remote

exception DoesNotExist
exception MultipleObjectsReturned
get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_policy_display(*, field=<django.db.models.fields.TextField: policy>)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
IMMEDIATE = 'immediate'
ON_DEMAND = 'on_demand'
POLICY_CHOICES = (('immediate', 'When syncing, download all metadata and content now.'), ('on_demand', 'When syncing, download metadata, but do not download content now. Instead, download content as clients request it, and save it in Pulp to be served for future client requests.'), ('streamed', 'When syncing, download metadata, but do not download content now. Instead,download content as clients request it, but never save it in Pulp. This causes future requests for that same content to have to be downloaded again.'))
STREAMED = 'streamed'
TYPE = 'remote'
basedistribution_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

download_concurrency

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
password

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

policy

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

proxy_url

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

remoteartifact_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

ssl_ca_certificate

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

ssl_client_certificate

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

ssl_client_key

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

ssl_validation

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

url

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

username

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class pulpcore.app.models.RemoteArtifact(*args, **kwargs)

Represents a content artifact that is provided by a remote (external) repository.

Remotes that want to support deferred download policies should use this model to store information required for downloading an Artifact at some point in the future. At a minimum this includes the URL, the ContentArtifact, and the Remote that created it. It can also store expected size and any expected checksums.

Fields
  • url (models.TextField) – The URL where the artifact can be retrieved.

  • size (models.IntegerField) – The expected size of the file in bytes.

  • md5 (models.CharField) – The expected MD5 checksum of the file.

  • sha1 (models.CharField) – The expected SHA-1 checksum of the file.

  • sha224 (models.CharField) – The expected SHA-224 checksum of the file.

  • sha256 (models.CharField) – The expected SHA-256 checksum of the file.

  • sha384 (models.CharField) – The expected SHA-384 checksum of the file.

  • sha512 (models.CharField) – The expected SHA-512 checksum of the file.

Relations
  • content_artifact (pulpcore.app.models.ForeignKey) – ContentArtifact associated with this RemoteArtifact.

  • remote (django.db.models.ForeignKey) – Remote that created the RemoteArtifact.

exception DoesNotExist
exception MultipleObjectsReturned
get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
content_artifact

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

content_artifact_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

md5

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <pulpcore.app.models.content.BulkCreateManager object>
remote

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

remote_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

sha1

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

sha224

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

sha256

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

sha384

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

sha512

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

size

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

url

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class pulpcore.app.models.Repository(*args, **kwargs)

Collection of content.

Fields
  • name (models.CharField) – The repository name.

  • description (models.TextField) – An optional description.

  • plugin_managed (models.BooleanField) – True if the plugin manages this repository and users typically do not interact with it.

  • last_version (models.PositiveIntegerField) – A record of the last created version number. Used when a repository version is deleted so as not to create a new vesrion with the same version number.

Relations

content (models.ManyToManyField) – Associated content.

exception DoesNotExist
exception MultipleObjectsReturned
get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
natural_key()

Get the model’s natural key.

Returns

The model’s natural key.

Return type

tuple

content

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

description

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

last_version

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
plugin_managed

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

repositorycontent_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

versions

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class pulpcore.app.models.RepositoryContent(*args, **kwargs)

Association between a repository and its contained content.

Fields

created (models.DatetimeField) – When the association was created.

Relations
  • content (models.ForeignKey) – The associated content.

  • repository (models.ForeignKey) – The associated repository.

  • version_added (models.ForeignKey) – The RepositoryVersion which added the referenced Content.

  • version_removed (models.ForeignKey) – The RepositoryVersion which removed the referenced Content.

exception DoesNotExist
exception MultipleObjectsReturned
get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
content

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

content_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
repository

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

repository_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

version_added

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

version_added_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

version_removed

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

version_removed_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class pulpcore.app.models.RepositoryVersion(*args, **kwargs)

A version of a repository’s content set.

Plugin Writers are strongly encouraged to use RepositoryVersion as a context manager to provide transactional safety, working directory set up, and cleaning up the database on failures.

Examples

>>>
>>> with RepositoryVersion.create(repository) as new_version:
>>>     new_version.add_content(content_q)
>>>     new_version.remove_content(content_q)
>>>
Fields
  • number (models.PositiveIntegerField) – A positive integer that uniquely identifies a version of a specific repository. Each new version for a repo should have this field set to 1 + the most recent version.

  • action (models.TextField) – The action that produced the version.

  • complete (models.BooleanField) – If true, the RepositoryVersion is visible. This field is set to true when the task that creates the RepositoryVersion is complete.

Relations

repository (models.ForeignKey) – The associated repository.

exception DoesNotExist
exception MultipleObjectsReturned
add_content(content)

Add a content unit to this version.

Parameters

content (django.db.models.QuerySet) – Set of Content to add

Raise:
pulpcore.exception.ResourceImmutableError: if add_content is called on a

complete RepositoryVersion

added()
Returns

The Content objects that were added by this version.

Return type

QuerySet

compute_counts()

Compute and save content unit counts by type.

Count records are stored as RepositoryVersionContentDetails. This method deletes existing RepositoryVersionContentDetails objects and makes new ones with each call.

contains(content)

Check whether a content exists in this repository version’s set of content

Returns

True if the repository version contains the content, False otherwise

Return type

bool

classmethod create(repository, base_version=None)

Create a new RepositoryVersion

Creation of a RepositoryVersion should be done in a RQ Job.

Parameters
Returns

The Created RepositoryVersion

Return type

pulpcore.app.models.RepositoryVersion

delete(**kwargs)

Deletes a RepositoryVersion

If RepositoryVersion is complete and has a successor, squash RepositoryContent changes into the successor. If version is incomplete, delete and and clean up RepositoryContent, CreatedResource, and Repository objects.

Deletion of a complete RepositoryVersion should be done in a RQ Job.

get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
static latest(repository)

Get the latest RepositoryVersion on a repository

Parameters

repository (pulpcore.app.models.Repository) – to get the latest version of

Returns

The latest RepositoryVersion

Return type

pulpcore.app.models.RepositoryVersion

next()
Returns

The next RepositoryVersion with the same

repository.

Return type

pulpcore.app.models.RepositoryVersion

Raises

RepositoryVersion.DoesNotExist – if there is not a RepositoryVersion for the same repository and with a higher “number”.

remove_content(content)

Remove content from the repository.

Parameters

content (django.db.models.QuerySet) – Set of Content to remove

Raise:
pulpcore.exception.ResourceImmutableError: if remove_content is called on a

complete RepositoryVersion

removed()
Returns

The Content objects that were removed by this version.

Return type

QuerySet

added_memberships

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

base_version

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

base_version_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

complete

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property content

Returns a set of content for a repository version

Returns

The content that is contained within this version.

Return type

django.db.models.QuerySet

Examples

>>> repository_version = ...
>>>
>>> for content in repository_version.content:
>>>     content = content.cast()  # optional downcast.
>>>     ...
>>>
>>> for content in FileContent.objects.filter(pk__in=repository_version.content):
>>>     ...
>>>
counts

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

number

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
publication_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

removed_memberships

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

repository

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

repository_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

versions

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class pulpcore.app.models.RepositoryVersionContentDetails(id, count_type, content_type, repository_version, count)
exception DoesNotExist
exception MultipleObjectsReturned
get_count_type_display(*, field=<django.db.models.fields.CharField: count_type>)
ADDED = 'A'
COUNT_TYPE_CHOICES = (('A', 'added'), ('P', 'present'), ('R', 'removed'))
PRESENT = 'P'
REMOVED = 'R'
property content_href

Generate URLs for the content types present in the RepositoryVersion.

For each content type present in the RepositoryVersion, create the URL of the viewset of that variety of content along with a query parameter which filters it by presence in this RepositoryVersion.

Parameters

obj (pulpcore.app.models.RepositoryVersion) – The RepositoryVersion being serialized.

Returns

{<_type>: <url>}

Return type

dict

content_type

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

count

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

count_type

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
repository_version

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

repository_version_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class pulpcore.app.models.RepositoryVersionDistribution(*args, **kwargs)

Define how Pulp’s content app will serve a RepositoryVersion or Repository.

The repository and repository_version fields cannot be used together.

Relations
  • repository (models.ForeignKey) – The latest RepositoryVersion for this Repository will be served.

  • repository_version (models.ForeignKey) – RepositoryVersion to be served.

class Meta
abstract = False
basedistribution_ptr

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

basedistribution_ptr_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

repository

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

repository_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

repository_version

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

repository_version_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class pulpcore.app.models.ReservedResource(*args, **kwargs)

Resources that have been reserved

Fields

resource (models.TextField) – The url of the resource reserved for the task.

Relations
  • task (models.ForeignKey) – The task associated with this reservation

  • worker (models.ForeignKey) – The worker associated with this reservation

exception DoesNotExist
exception MultipleObjectsReturned
get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
objects = <django.db.models.manager.Manager object>
resource

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

taskreservedresource_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

tasks

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

worker

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

worker_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class pulpcore.app.models.ReservedResourceRecord(*args, **kwargs)

Resources that have been reserved.

This model is a duplicate of ReservedResource. A worker is not included in the model because it will prevent the tasking system to release duplicated reserved resources automatically.

Fields

resource (models.TextField) – The url of the resource reserved for the task.

Relations

task (models.ForeignKey) – The task associated with this reservation

exception DoesNotExist
exception MultipleObjectsReturned
get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
objects = <django.db.models.manager.Manager object>
resource

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

taskreservedresourcerecord_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

tasks

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class pulpcore.app.models.Task(*args, **kwargs)

Represents a task

Fields
  • state (models.TextField) – The state of the task

  • name (models.CharField) – The name of the task

  • started_at (models.DateTimeField) – The time the task started executing

  • finished_at (models.DateTimeField) – The time the task finished executing

  • non_fatal_errors (pulpcore.app.fields.JSONField) – Dictionary of non-fatal errors that occurred while task was running.

  • error (pulpcore.app.fields.JSONField) – Fatal errors generated by the task

Relations
  • parent (models.ForeignKey) – Task that spawned this task (if any)

  • worker (models.ForeignKey) – The worker that this task is in

exception DoesNotExist
exception MultipleObjectsReturned
static current()
Returns

The current task.

Return type

pulpcore.app.models.Task

get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
get_state_display(*, field=<django.db.models.fields.TextField: state>)
release_resources()

Release the reserved resources that are reserved by this task. If a reserved resource no longer has any tasks reserving it, delete it.

set_completed()

Set this Task to the completed state, save it, and log output in warning cases.

This updates the finished_at and sets the state to COMPLETED.

set_failed(exc, tb)

Set this Task to the failed state and save it.

This updates the finished_at attribute, sets the state to FAILED, and sets the error attribute.

Parameters
  • exc (Exception) – The exception raised by the task.

  • tb (traceback) – Traceback instance for the current exception.

set_running()

Set this Task to the running state, save it, and log output in warning cases.

This updates the started_at and sets the state to RUNNING.

created_resources

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

error

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

finished_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

non_fatal_errors

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
parent

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

parent_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

progress_reports

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

reserved_resources

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

reserved_resources_record

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

spawned_tasks

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

started_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

state

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

taskreservedresource_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

taskreservedresourcerecord_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

worker

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

worker_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class pulpcore.app.models.TaskReservedResource(*args, **kwargs)

Association between a Task and its ReservedResources.

Prevents the task from being deleted if it has any ReservedResource(s).

Fields

created (models.DatetimeField) – When the association was created.

Relations
  • task (models.ForeignKey) – The associated task.

  • resource (models.ForeignKey) – The associated resource.

exception DoesNotExist
exception MultipleObjectsReturned
get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
objects = <django.db.models.manager.Manager object>
resource

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

resource_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

task

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

task_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class pulpcore.app.models.Upload(*args, **kwargs)

A chunked upload. Stores chunks until used to create an artifact, etc.

Fields
  • file (models.FileField) – The stored file.

  • size (models.BigIntegerField) – The size of the file in bytes.

exception DoesNotExist
exception MultipleObjectsReturned
append(chunk, offset, sha256=None)

Append a chunk to an upload.

Parameters
  • chunk (File) – Binary file to append to the upload file.

  • offset (int) – First byte position to write chunk to.

delete(*args, **kwargs)

Deletes Upload model and the file associated with the model

Parameters
  • args (list) – list of positional arguments for Model.delete()

  • kwargs (dict) – dictionary of keyword arguments to pass to Model.delete()

get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
chunks

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

file

The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:

>>> from myapp.models import MyModel
>>> instance = MyModel.objects.get(pk=1)
>>> instance.file.size

Assign a file object on assignment so you can do:

>>> with open('/path/to/hello.world', 'r') as f:
...     instance.file = File(f)
objects = <django.db.models.manager.Manager object>
size

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class pulpcore.app.models.UploadChunk(*args, **kwargs)

A chunk for an uploaded file.

Fields
  • upload (models.ForeignKey) – Upload this chunk belongs to.

  • offset (models.BigIntegerField) – Start of the chunk in bytes.

  • size (models.BigIntegerField) – Size of the chunk in bytes.

exception DoesNotExist
exception MultipleObjectsReturned
get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
objects = <django.db.models.manager.Manager object>
offset

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

size

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

upload

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

upload_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class pulpcore.app.models.Worker(*args, **kwargs)

Represents a worker

Fields
  • name (models.CharField) – The name of the worker, in the format “worker_type@hostname

  • last_heartbeat (models.DateTimeField) – A timestamp of this worker’s last heartbeat

  • gracefully_stopped (models.BooleanField) – True if the worker has gracefully stopped. Default is False.

  • cleaned_up (models.BooleanField) – True if the worker has been cleaned up. Default is False.

exception DoesNotExist
exception MultipleObjectsReturned
get_next_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=True, **kwargs)
get_next_by_last_heartbeat(*, field=<django.db.models.fields.DateTimeField: last_heartbeat>, is_next=True, **kwargs)
get_previous_by__created(*, field=<django.db.models.fields.DateTimeField: _created>, is_next=False, **kwargs)
get_previous_by_last_heartbeat(*, field=<django.db.models.fields.DateTimeField: last_heartbeat>, is_next=False, **kwargs)
lock_resources(task, resource_urls)

Attempt to lock all resources by their urls. Must be atomic to prevent deadlocks.

Parameters
  • task (pulpcore.app.models.Task) – task to lock the resource for

  • resource_urls (List) – a list of resource urls to be locked

Raises

django.db.IntegrityError – If the reservation already exists

save_heartbeat()

Update the last_heartbeat field to now and save it.

Only the last_heartbeat field will be saved. No other changes will be saved.

Raises

ValueError – When the model instance has never been saved before. This method can only update an existing database record.

cleaned_up

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

gracefully_stopped

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

last_heartbeat

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property missing

Whether a worker can be considered ‘missing’

To be considered ‘missing’, a worker must have a stale timestamp while also having gracefully_stopped=False, meaning that it was not shutdown ‘cleanly’ and may have died. Stale is defined here as “beyond the pulp process timeout interval”.

Returns

True if the worker is considered missing, otherwise False

Return type

bool

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <pulpcore.app.models.task.WorkerManager object>
property online

Whether a worker can be considered ‘online’

To be considered ‘online’, a worker must have a recent heartbeat timestamp and must not have the ‘gracefully_stopped’ flag set to True. “Recent” is defined here as “within the pulp process timeout interval”.

Returns

True if the worker is considered online, otherwise False

Return type

bool

reservations

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

tasks

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.