Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add modelling for "Errata" content #1109

Merged
merged 1 commit into from Aug 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis/script.sh
Expand Up @@ -22,6 +22,7 @@ if [ $? -ne 0 ]; then
fi
popd

export DJANGO_SETTINGS_MODULE=pulpcore.app.settings
pulp-manager reset-admin-password --password admin
pulp-manager runserver >> ~/django_runserver.log 2>&1 &
rq worker -n 'resource_manager@%h' -w 'pulpcore.tasking.worker.PulpWorker' >> ~/resource_manager.log 2>&1 &
Expand Down
165 changes: 162 additions & 3 deletions pulp_rpm/app/models.py
@@ -1,7 +1,6 @@
from logging import getLogger

from django.db import models

from pulpcore.plugin.models import Content, Remote, Publisher

from pulp_rpm.app.constants import CHECKSUM_CHOICES
Expand All @@ -12,8 +11,9 @@

class RpmContent(Content):
"""
The "rpm" content type. Maps directly to the fields provided by createrepo_c.
The "rpm" content type.

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

Fields:
Expand Down Expand Up @@ -112,7 +112,7 @@ class RpmContent(Content):
release = models.TextField()
arch = models.TextField()

pkgId = models.TextField(unique=True) # formerly "checksum"
pkgId = models.TextField(unique=True) # formerly "checksum" in Pulp 2
checksum_type = models.TextField(choices=CHECKSUM_CHOICES)

# Optional metadata
Expand Down Expand Up @@ -205,6 +205,165 @@ class SrpmContent(RpmContent):
TYPE = 'srpm'


class UpdateRecord(Content):
"""
The "UpdateRecord" content type, formerly "Errata" model in Pulp 2.

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

Fields:
id (Text):
Update id (short update name, e.g. RHEA-2013:1777)
updated_date (Text):
Date when the update was updated (e.g. "2013-12-02 00:00:00")

description (Text):
Update description
issued_date (Text):
Date when the update was issued (e.g. "2013-12-02 00:00:00")
fromstr (Text):
Source of the update (e.g. security@redhat.com)
status (Text):
Update status ("final", ...)
title (Text):
Update name
summary (Text):
Short summary
version (Text):
Update version (probably always an integer number)

type (Text):
Update type ("enhancement", "bugfix", ...)
severity (Text):
Severity
solution (Text):
Solution
release (Text):
Update release
rights (Text):
Copyrights

pushcount (Text):
Push count

references (Text):
List of UpdateReferences - see comments below

"""

# Required metadata
errata_id = models.TextField() # TODO: change field name?
updated_date = models.TextField()

# Optional metadata
description = models.TextField(blank=True)
issued_date = models.TextField(blank=True)
fromstr = models.TextField(blank=True) # formerly "errata_from"
status = models.TextField(blank=True)
title = models.TextField(blank=True)
summary = models.TextField(blank=True)
version = models.TextField(blank=True)

update_type = models.TextField(blank=True) # TODO: change field name?
severity = models.TextField(blank=True)
solution = models.TextField(blank=True)
release = models.TextField(blank=True)
rights = models.TextField(blank=True)

pushcount = models.TextField(blank=True)

# A string containing a JSON-encoded list of dictionaries, each of which represents an
# UpdateReference. Each UpdateReference dict contains the following fields:
#
# href (str): URL (e.g. to related bugzilla, errata, ...)
# id (str): Id (e.g. 1035288, NULL for errata, ...)
# title (str): Name of errata, name of bug, etc.
# type (str): Reference type ("self" for errata, "bugzilla", ...)
references = models.TextField(default='[]', blank=True)

class Meta:
unique_together = ()
# TODO: Find some way to enforce uniqueness per-repository
# make a hash of the natural key, store the hash?


class UpdateCollection(models.Model):
"""
A collection of UpdateCollectionPackages with an associated nametag.

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

Fields:

name (Text):
Name of the collection e.g. RHN Tools for RHEL AUS (v. 6.5 for 64-bit x86_64)
shortname (Text):
Short name e.g. rhn-tools-rhel-x86_64-server-6.5.aus

Relations:

update_record (models.ForeignKey): The associated UpdateRecord
"""

name = models.TextField(blank=True)
shortname = models.TextField(blank=True)

update_record = models.ForeignKey(UpdateRecord, related_name="collections",
on_delete=models.CASCADE)


class UpdateCollectionPackage(models.Model):
"""
Part of an UpdateCollection, representing a package.

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

Fields:

arch (Text):
Arch
epoch (Text):
Epoch
filename (Text):
Filename
name (Text):
Name
reboot_suggested (Boolean):
Whether a reboot is suggested after package installation
release (Text):
Release
src (Text):
Source filename
sum (Text):
Checksum
sum_type (Text):
Checksum type
version (Text):
Version

Relations:

update_collection (models.ForeignKey): The associated UpdateCollection
"""

arch = models.TextField(blank=True)
epoch = models.TextField(blank=True)
filename = models.TextField(blank=True)
name = models.TextField(blank=True)
reboot_suggested = models.BooleanField(blank=True)
release = models.TextField(blank=True)
src = models.TextField(blank=True)
sum = models.TextField(blank=True)
sum_type = models.TextField(blank=True)
version = models.TextField(blank=True)

update_collection = models.ForeignKey(UpdateCollection, related_name='packages',
on_delete=models.CASCADE)


class RpmRemote(Remote):
"""
Remote for "rpm" content.
Expand Down