bodhi.server.models¶
Bodhi’s database models.
Classes
Base class for the SQLAlchemy model base class. |
|
|
Represents a Bugzilla bug. |
|
Karma for a bug associated with a comment. |
|
This model represents a specific build of a package. |
|
This model represents a Koji buildroot override. |
|
An update comment. |
|
Express the status of an in-progress compose job. |
Define the various states that a |
|
|
Represents a Container build. |
|
Represents a Container package. |
Used to differentiate between different kinds of content in various models. |
|
|
Declarative enumeration. |
|
A database column type for an enum. |
|
Generate new DeclEnum classes. |
|
Define a fixed symbol tied to a parent class. |
|
Represents a Flatpak build. |
|
Represents a Flatpak package. |
|
A group of users. |
|
Represents a Module build. |
|
Represents a Module package. |
|
This model represents a package. |
An enum used to specify what package manager is used by a specific Release. |
|
|
Represent a distribution release, such as Fedora 27. |
An enum that describes the state of a |
|
|
Represents an RPM build. |
|
Represents a RPM package. |
|
Represents test cases from the wiki. |
|
Karma for a TestCase associated with a comment. |
This class lists the different status the |
|
|
This model represents an update. |
An enum used to specify an update requesting to change states. |
|
An enum used to specify the severity of the update. |
|
An enum used to describe the current state of an update. |
|
An enum used to tell the user whether they need to reboot or logout after applying an update. |
|
An enum used to classify the type of the update. |
|
|
A Bodhi user. |
- class bodhi.server.models.BodhiBase[source]¶
Bases:
object
Base class for the SQLAlchemy model base class.
- __exclude_columns__¶
A list of columns to exclude from JSON
- Type:
tuple
- __include_extras__¶
A list of methods or attrs to include in JSON
- Type:
tuple
- id¶
An integer id that serves as the default primary key.
- Type:
int
- query¶
a class property which produces a Query object against the class and the current Session when called.
- Type:
sqlalchemy.orm.query.Query
- __getitem__(key)[source]¶
Define a dictionary like interface for the models.
- Parameters:
key (string) – The name of an attribute you wish to retrieve from the model.
- Returns:
The value of the attribute represented by key.
- Return type:
object
- __json__(request=None, exclude=None, include=None)[source]¶
Return a JSON representation of this model.
- Parameters:
request (pyramid.request.Request or None) – The current web request, or None.
exclude (iterable or None) – An iterable of strings naming the attributes to exclude from the JSON representation of the model. If None (the default), the class’s __exclude_columns__ attribute will be used.
include (iterable or None) – An iterable of strings naming the extra attributes to include in the JSON representation of the model. If None (the default), the class’s __include_extras__ attribute will be used.
- Returns:
A dict representation of the model suitable for serialization as JSON.
- Return type:
dict
- __repr__()[source]¶
Return a string representation of this model.
- Returns:
A string representation of this model.
- Return type:
str
- __weakref__¶
list of weak references to the object (if defined)
- classmethod find_polymorphic_child(identity)[source]¶
Find a child of a polymorphic base class.
For example, given the base Package class and the ‘rpm’ identity, this class method should return the RpmPackage class.
This is accomplished by iterating over all classes in scope. Limiting that to only those which are an extension of the given base class. Among those, return the one whose polymorphic_identity matches the value given. If none are found, then raise a NameError.
- Parameters:
identity (EnumSymbol) – An instance of EnumSymbol used to identify the child.
- Returns:
The type-specific child class.
- Return type:
- Raises:
KeyError – If this class is not polymorphic.
NameError – If no child class is found for the given identity.
TypeError – If identity is not an EnumSymbol.
- class bodhi.server.models.Bug(**kwargs)[source]¶
Bases:
Base
Represents a Bugzilla bug.
- bug_id¶
The bug’s id.
- Type:
int
- title¶
The description of the bug.
- Type:
str
- security¶
True if the bug is marked as a security issue.
- Type:
bool
- parent¶
True if this is a parent tracker bug for release-specific bugs.
- Type:
bool
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- add_comment(update: Update, comment: str | None = None) None [source]¶
Add a comment to the bug, pertaining to the given update.
- Parameters:
update – The update that is related to the bug.
comment – The comment to add to the bug. If None, a default message is added to the bug. Defaults to None.
- close_bug(update: Update) None [source]¶
Close the bug.
- Parameters:
update – The update associated with the bug.
- default_message(update: Update) str [source]¶
Return a default comment to add to a bug with add_comment().
- Parameters:
update – The update that is related to the bug.
- Returns:
The default comment to add to the bug related to the given update.
- id¶
- modified(update: Update, comment: str) None [source]¶
Change the status of this bug to MODIFIED unless it is a parent security bug.
Also, comment on the bug stating that an update has been submitted.
- Parameters:
update – The update that is associated with this bug.
comment – A comment to leave on the bug when modifying it.
- testing(update: Update) None [source]¶
Change the status of this bug to ON_QA.
Also, comment on the bug with some details on how to test and provide feedback for the given update.
- Parameters:
update – The update associated with the bug.
- update_details(bug: bugzilla.bug.Bug | None = None) None [source]¶
Grab details from rhbz to populate our bug fields.
This is typically called “offline” in the UpdatesHandler task.
- Parameters:
bug – The Bug to retrieve details from Bugzilla about. If None, self.bug_id will be used to retrieve the bug. Defaults to None.
- property url: str¶
Return a URL to the bug.
- Returns:
The URL to this bug.
- class bodhi.server.models.BugKarma(**kwargs)[source]¶
Bases:
Base
Karma for a bug associated with a comment.
- karma¶
The karma associated with this bug and comment.
- Type:
int
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- id¶
- class bodhi.server.models.Build(**kwargs)[source]¶
Bases:
Base
This model represents a specific build of a package.
This model uses single-table inheritance to allow for different build types.
- nvr¶
The nvr field is really a mapping to the Koji build_target.name field, and is used to reference builds in Koji. It is named nvr in reference to the dash-separated name-version-release Koji name for RPMs, but it is used by other types as well. At the time of this writing, it was not practical to rename nvr since it is used in the REST API to reference builds. Thus, it should be thought of as a Koji build identifier rather than strictly as an RPM’s name, version, and release.
- Type:
str
- package_id¶
A foreign key to the Package that this Build is part of.
- Type:
int
- release_id¶
A foreign key to the Release that this Build is part of.
- Type:
int
- signed¶
If True, this package has been signed by robosignatory. If False, it has not been signed yet.
- Type:
bool
- update_id¶
A foreign key to the Update that this Build is part of.
- Type:
int
- release¶
A relationship to the Release that this build is part of.
- Type:
sqlalchemy.orm.relationship
- type¶
The polymorphic identify of the row. This is used by sqlalchemy to identify which subclass of Build to use.
- Type:
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- get_build_id()[source]¶
Return the koji build id of the build.
- Returns:
The task/build if of the build.
- Return type:
id
- get_changelog(timelimit=0, lastupdate=False)[source]¶
Will be overridden from child classes, when appropriate.
- get_n_v_r()[source]¶
Return the (name, version, release) of this build.
Note: This does not directly return the Build’s nvr attribute, which is a str.
- Returns:
A 3-tuple representing the name, version and release from the build.
- Return type:
tuple
- get_owner_name()[source]¶
Return the koji username of the user who built the build.
- Returns:
The username of the user.
- Return type:
str
- get_tags(koji=None)[source]¶
Return a list of koji tags for this build.
- Parameters:
koji (bodhi.server.buildsys.Buildsysem or koji.ClientSession) – A koji client. Defaults to calling bodhi.server.buildsys.get_session().
- Returns:
A list of strings of the Koji tags on this Build.
- Return type:
list
- get_task_id() int [source]¶
Return the koji task id of the build.
- Returns:
The task if of the build or None
- Return type:
id
- id¶
- property nvr_name¶
Return the RPM name.
- Returns:
The name of the Build.
- Return type:
str
- property nvr_release¶
Return the RPM release.
- Returns:
The release of the Build.
- Return type:
str
- property nvr_version¶
Return the RPM version.
- Returns:
The version of the Build.
- Return type:
str
- class bodhi.server.models.BuildrootOverride(**kwargs)[source]¶
Bases:
Base
This model represents a Koji buildroot override.
A buildroot override is a way to add a build to the Koji buildroot (the set of packages used to build a package) manually. Normally, builds are only available after they are pushed to “stable”, but this allows a build to be added to the buildroot immediately. This is useful for updates that depend on each other to be built.
- notes¶
A text field that holds arbitrary notes about the buildroot override.
- Type:
str
- submission_date¶
The date that the buildroot override was submitted.
- Type:
DateTime
- expiration_date¶
The date that the buildroot override expires.
- Type:
DateTime
- expired_date¶
The date that the buildroot override expired.
- Type:
DateTime
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- classmethod edit(request: pyramid.request, **data) BuildrootOverride [source]¶
Edit an existing buildroot override.
- Parameters:
request – The current web request.
data – The changed being made to the BuildrootOverride.
- Returns:
The new updated override.
- id¶
- classmethod new(request: pyramid.request, **data) BuildrootOverride [source]¶
Create a new buildroot override.
- Parameters:
request – The current web request.
data – A dictionary of all the attributes to be used on the new override.
- Returns:
The newly created BuildrootOverride instance.
- class bodhi.server.models.Comment(**kwargs)[source]¶
Bases:
Base
An update comment.
- karma¶
The karma associated with this comment. Defaults to 0.
- Type:
int
- karma_critpath¶
The critpath karma associated with this comment. Defaults to 0. DEPRECATED no longer used in the UI
- Type:
int
- text¶
The text of the comment.
- Type:
str
- timestamp¶
The time the comment was created. Defaults to the return value of datetime.utcnow().
- Type:
datetime.datetime
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- __json__(*args, **kwargs) dict [source]¶
Return a JSON string representation of this comment.
- Parameters:
args – A list of extra args to pass on to
BodhiBase.__json__()
.kwargs – Extra kwargs to pass on to
BodhiBase.__json__()
.
- Returns:
A JSON-serializable dict representation of this comment.
- __str__() str [source]¶
Return a str representation of this comment.
- Returns:
A str representation of this comment.
- id¶
- property rss_title: str¶
Return a formatted title for the comment using update alias and comment id.
- Returns:
A string representation of the comment for RSS feed.
- property unique_testcase_feedback: List[TestCaseKarma]¶
Return a list of unique
TestCaseKarma
objects found in the testcase_feedback.This will filter out duplicates for
TestCases
. It will return the correct number of TestCases in testcase_feedback as a list.- Returns:
A list of unique
TestCaseKarma
objects associated with this comment.
- class bodhi.server.models.Compose(**kwargs)[source]¶
Bases:
Base
Express the status of an in-progress compose job.
This object is used in a few ways:
It ensures that only one compose process runs per repo, serving as a compose “lock”.
It marks which updates are part of a compose, serving as an update “lock”.
It gives the compose process a place to log which step it is in, which will allow us to provide compose monitoring tools.
- __exclude_columns__¶
A tuple of columns to exclude when __json__() is called.
- Type:
tuple
- __include_extras__¶
A tuple of attributes to add when __json__() is called.
- Type:
tuple
- __tablename__¶
The name of the table in the database.
- Type:
str
- checkpoints¶
A JSON serialized object describing the checkpoints the composer has reached.
- Type:
str
- date_created¶
The time this Compose was created.
- Type:
datetime.datetime
- error_message¶
An error message indicating what happened if the Compose failed.
- Type:
str
- release_id¶
The primary key of the
Release
that is being composed. Forms half of the primary key, with the other half being therequest
.- Type:
int
- request¶
The request of the release that is being composed. Forms half of the primary key, with the other half being the
release_id
.- Type:
- state_date¶
The time of the most recent change to the state attribute.
- Type:
datetime.datetime
- state¶
The state of the compose.
- Type:
- updates¶
An iterable of updates included in this compose.
- Type:
sqlalchemy.orm.collections.InstrumentedList
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- __json__(request=None, exclude=None, include=None, composer=False)[source]¶
Serialize this compose in JSON format.
- Parameters:
request (pyramid.request.Request or None) – The current web request, or None.
exclude (iterable or None) – See superclass docblock.
include (iterable or None) – See superclass docblock.
composer (bool) – If True, increase the number of excluded attributes so that only the attributes required by the Composer to identify Composes are included. Defaults to False. If used, overrides exclude and include.
- Returns:
A JSON representation of the Compose.
- Return type:
str
- __lt__(other)[source]¶
Return
True
if this compose has a higher priority than the other.- Parameters:
other (Compose) – Another compose we are comparing this compose to for sorting.
- Returns:
True
if this compose has a higher priority than the other, elseFalse
.- Return type:
bool
- __str__()[source]¶
Return a human-readable representation of this compose.
- Returns:
A string to be displayed to users describing this compose.
- Return type:
str
- property content_type¶
Return the content_type of this compose.
- Returns:
- The content type of this compose, or None if there are no
associated
Updates
.
- Return type:
(ContentType or None)
- classmethod from_dict(db, compose)[source]¶
Return a
Compose
instance from the given dict representation of it.- Parameters:
db (sqlalchemy.orm.session.Session) – A database session to use to query for the compose.
compose (dict) – A dictionary representing the compose, in the format returned by
Compose.__json__()
.
- Returns:
The requested compose instance.
- Return type:
- classmethod from_updates(updates)[source]¶
Return a list of Compose objects to compose the given updates.
The updates will be collated by release, request, and content type, and will be added to new Compose objects that match those groupings.
Note that calling this will cause each of the updates to become locked once the transaction is committed.
- Parameters:
updates (list) – A list of
Updates
that you wish to Compose.- Returns:
A list of new compose objects for the given updates.
- Return type:
list
- id = None¶
- property security¶
Return whether this compose is a security related compose or not.
- Returns:
True
if any of theUpdates
in this compose are marked assecurity updates.
- Return type:
bool
- static update_state_date(target, value, old, initiator)[source]¶
Update the
state_date
when the state changes.- Parameters:
target (Compose) – The compose that has had a change to its state attribute.
value (EnumSymbol) – The new value of the state.
old (EnumSymbol) – The old value of the state
initiator (sqlalchemy.orm.attributes.Event) – The event object that is initiating this transition.
- property update_summary¶
Return a summary of the updates attribute, suitable for transmitting via the API.
- Returns:
- A list of dictionaries with keys ‘alias’ and ‘title’, indexing each update alias
and title associated with this Compose.
- Return type:
list
- class bodhi.server.models.ComposeState[source]¶
Bases:
DeclEnum
Define the various states that a
Compose
can be in.- requested¶
A compose has been requested, but it has not started yet.
- Type:
- pending¶
The request for the compose has been received by the backend worker, but the compose has not started yet.
- Type:
- initializing¶
The compose is initializing.
- Type:
- updateinfo¶
The updateinfo.xml is being generated.
- Type:
- punging¶
A Pungi soldier has been deployed to deal with the situation.
- Type:
- syncing_repo¶
The repo is being synced to the master mirror.
- Type:
- notifying¶
Pungi has finished successfully, and we are now sending out various forms of notifications, such as e-mail, bus messages, and bugzilla.
- Type:
- success¶
The Compose has completed successfully.
- Type:
- failed¶
The compose has failed, abandon hope.
- Type:
- signing_repo¶
Waiting for the repo to be signed.
- Type:
- cleaning¶
Cleaning old Composes after successful completion.
- Type:
- class bodhi.server.models.ContainerBuild(**kwargs)[source]¶
Bases:
Build
Represents a Container build.
Note that this model uses single-table inheritance with its Build superclass.
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- id¶
- class bodhi.server.models.ContainerPackage(**kwargs)[source]¶
Bases:
Package
Represents a Container package.
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- id¶
- class bodhi.server.models.ContentType[source]¶
Bases:
DeclEnum
Used to differentiate between different kinds of content in various models.
This enum is used to mark objects as pertaining to particular kinds of content type, such as RPMs or Modules.
- base¶
This is used to represent base classes that are shared between specific content types.
- Type:
- rpm¶
Used to represent RPM related objects.
- Type:
- module¶
Used to represent Module related objects.
- Type:
- container¶
Used to represent Container related objects.
- Type:
- flatpak¶
Used to represent Flatpak related objects.
- Type:
- classmethod infer_content_class(base, build)[source]¶
Identify and return the child class associated with the appropriate ContentType.
For example, given the Package base class and a normal koji build, return the RpmPackage model class. Or, given the Build base class and a container build, return the ContainerBuild model class.
- class bodhi.server.models.DeclEnum[source]¶
Bases:
object
Declarative enumeration.
- __weakref__¶
list of weak references to the object (if defined)
- classmethod db_type()[source]¶
Return a database column type to be used for this enum.
- Returns:
A DeclEnumType to be used for this enum.
- Return type:
- class bodhi.server.models.DeclEnumType(enum)[source]¶
Bases:
SchemaType
,TypeDecorator
A database column type for an enum.
- __init__(enum)[source]¶
Initialize with the given enum.
- Parameters:
enum (bodhi.server.models.EnumMeta) – The enum metaclass.
- cache_ok = True¶
See
sqlalchemy.types.TypeDecorator.cache_ok
- process_bind_param(value, dialect)[source]¶
Return the value of the enum.
- Parameters:
value (bodhi.server.models.enum.EnumSymbol) – The enum symbol we are resolving the value of.
dialect (sqlalchemy.engine.default.DefaultDialect) – Unused.
- Returns:
The EnumSymbol’s value.
- Return type:
str
- process_result_value(value, dialect)[source]¶
Return the enum that matches the given string.
- Parameters:
value (str) – The name of an enum.
dialect (sqlalchemy.engine.default.DefaultDialect) – Unused.
- Returns:
The enum that matches value, or
None
ifvalue
isNone
.- Return type:
EnumSymbol or None
- class bodhi.server.models.EnumMeta(classname, bases, dict_)[source]¶
Bases:
type
Generate new DeclEnum classes.
- class bodhi.server.models.EnumSymbol(cls_, name, value, description)[source]¶
Bases:
object
Define a fixed symbol tied to a parent class.
- __init__(cls_, name, value, description)[source]¶
Initialize the EnumSymbol.
- Parameters:
cls (EnumMeta) – The metaclass this symbol is tied to.
name (str) – The name of this symbol.
value (str) – The value used in the database to represent this symbol.
description (str) – A human readable description of this symbol.
- __iter__()[source]¶
Iterate over this EnumSymbol’s value and description.
- Returns:
An iterator over the value and description.
- Return type:
iterator
- __json__(request=None)[source]¶
Return a JSON representation of this EnumSymbol.
- Parameters:
request (pyramid.request.Request) – The current request.
- Returns:
A string representation of this EnumSymbol’s value.
- Return type:
str
- __lt__(other)[source]¶
Return True if self.value is less than other.value.
- Parameters:
other (EnumSymbol) – The other EnumSymbol we are being compared to.
- Returns:
True if self.value is less than other.value, False otherwise.
- Return type:
bool
- __reduce__()[source]¶
Allow unpickling to return the symbol linked to the DeclEnum class.
- Returns:
A 2-tuple of the
getattr
function, and a 2-tuple of the EnumSymbol’s member class and name.- Return type:
tuple
- __repr__()[source]¶
Return a string representation of this EnumSymbol.
- Returns:
A string representation of this EnumSymbol’s value.
- Return type:
str
- __str__() str [source]¶
Return a string representation of this EnumSymbol.
- Returns:
A string representation of this EnumSymbol’s value.
- __weakref__¶
list of weak references to the object (if defined)
- class bodhi.server.models.FlatpakBuild(**kwargs)[source]¶
Bases:
Build
Represents a Flatpak build.
Note that this model uses single-table inheritance with its Build superclass.
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- id¶
- class bodhi.server.models.FlatpakPackage(**kwargs)[source]¶
Bases:
Package
Represents a Flatpak package.
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- id¶
- class bodhi.server.models.Group(**kwargs)[source]¶
Bases:
Base
A group of users.
- name¶
The name of the Group.
- Type:
str
- users¶
An iterable of the
Users
who are in the group.- Type:
sqlalchemy.orm.collections.InstrumentedList
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- id¶
- class bodhi.server.models.ModuleBuild(**kwargs)[source]¶
Bases:
Build
Represents a Module build.
Note that this model uses single-table inheritance with its Build superclass.
- nvr¶
A unique Koji identifier for the module build.
- Type:
str
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- id¶
- property nvr_name¶
Return the ModuleBuild’s name.
- Returns:
The name of the module.
- Return type:
str
- property nvr_release¶
Return the ModuleBuild’s version and context.
- Returns:
The version of the ModuleBuild.
- Return type:
str
- property nvr_version¶
Return the the ModuleBuild’s stream.
- Returns:
The stream of the ModuleBuild.
- Return type:
str
- class bodhi.server.models.ModulePackage(**kwargs)[source]¶
Bases:
Package
Represents a Module package.
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- property external_name¶
Return the package name as it’s known to external services.
For modules, this splits the :stream portion back off.
- Returns:
The name of this module package without :stream.
- Return type:
str
- id¶
- class bodhi.server.models.Package(**kwargs)[source]¶
Bases:
Base
This model represents a package.
This model uses single-table inheritance to allow for different package types.
- name¶
A text string that uniquely identifies the package.
- Type:
str
- requirements¶
A text string that lists space-separated taskotron test results that must pass for this package
- Type:
str
- type¶
The polymorphic identity column. This is used to identify what Python class to create when loading rows from the database.
- Type:
int
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- __str__()[source]¶
Return a string representation of the package.
- Returns:
A string representing this package.
- Return type:
str
- static check_existence(build)[source]¶
Check if the Package instance associated with the build is already in database.
- Parameters:
build (dict) – Information about the build from the build system (koji).
- Returns:
True if the type-specific instance of Package is alreadi in database.
- Return type:
bool
- property external_name¶
Return the package name as it’s known to external services.
For most Packages, this is self.name.
- Returns:
The name of this package.
- Return type:
str
- static get_or_create(session, build)[source]¶
Identify and return the Package instance associated with the build.
For example, given a normal koji build, return a RpmPackage instance. Or, given a container, return a ContainerBuild instance.
- Parameters:
session (sqlalchemy.orm.session.Session) – A database session.
build (dict) – Information about the build from the build system (koji).
- Returns:
A type-specific instance of Package for the specific build requested.
- Return type:
- get_pkg_committers_from_pagure()[source]¶
Pull users and groups who can commit on a package in Pagure.
Returns a tuple with two lists: * The first list contains usernames that have commit access. * The second list contains FAS group names that have commit access.
- Raises:
RuntimeError – If Pagure did not give us a 200 code.
- hascommitaccess(username: str, branchname: str) bool [source]¶
Check on Pagure if a user has commit access on the package/branch.
- Raises:
RuntimeError – If Pagure did not give us a 200 code.
- id¶
- validate_builds(key, build)[source]¶
Validate builds being appended to ensure they are all the same type as the Package.
This method checks to make sure that all the builds on self.builds have their type attribute equal to self.type. The goal is to make sure that Builds of a specific type are only ever associated with Packages of the same type and vice-versa. For example, RpmBuilds should only ever associate with RpmPackages and never with ModulePackages.
- Parameters:
key (str) – The field’s key, which is un-used in this validator.
build (Build) – The build object which was appended to the list of builds.
- Raises:
ValueError – If the build being appended is not the same type as the package.
- class bodhi.server.models.PackageManager[source]¶
Bases:
DeclEnum
An enum used to specify what package manager is used by a specific Release.
- unspecified¶
for releases where the package manager is not specified.
- Type:
- dnf¶
DNF package manager.
- Type:
- yum¶
YUM package manager.
- Type:
- class bodhi.server.models.Release(**kwargs)[source]¶
Bases:
Base
Represent a distribution release, such as Fedora 27.
- name¶
The name of the release, such as ‘F27’.
- Type:
str
- long_name¶
A human readable name for the release, such as ‘Fedora 27’.
- Type:
str
- version¶
The version of the release, such as ‘27’.
- Type:
str
- id_prefix¶
The prefix to use when forming update aliases for this release, such as ‘FEDORA’.
- Type:
str
- branch¶
The dist-git branch associated with this release, such as ‘f27’.
- Type:
str
- dist_tag¶
The koji dist_tag associated with this release, such as ‘f27’.
- Type:
str
- stable_tag¶
The koji tag to be used for stable builds in this release, such as ‘f27-updates’.
- Type:
str
- testing_tag¶
The koji tag to be used for testing builds in this release, such as ‘f27-updates-testing’.
- Type:
str
- candidate_tag¶
The koji tag used for builds that are candidates to be updates, such as ‘f27-updates-candidate’.
- Type:
str
- pending_signing_tag¶
The koji tag that specifies that a build is waiting to be signed, such as ‘f27-signing-pending’.
- Type:
str
- pending_testing_tag¶
The koji tag that indicates that a build is waiting to be composed into the testing repository, such as ‘f27-updates-testing-pending’.
- Type:
str
- pending_stable_tag¶
The koji tag that indicates that a build is waiting to be composed into the stable repository, such as ‘f27-updates-pending’.
- Type:
str
- override_tag¶
The koji tag that is used when a build is added as a buildroot override, such as ‘f27-override’.
- Type:
str
- mail_template¶
The notification mail template.
- Type:
str
- state¶
The current state of the release. Defaults to
ReleaseState.disabled
.- Type:
- builds¶
An iterable of
Builds
associated with this release.- Type:
sqlalchemy.orm.collections.InstrumentedList
- composed_by_bodhi¶
The flag that indicates whether the release is composed by Bodhi or not. Defaults to True.
- Type:
bool
- create_automatic_updates¶
A flag indicating that updates should be created automatically for Koji builds tagged into the
candidate_tag
. Defaults to False.- Type:
bool
- package_manager¶
The package manager this release uses. This must be one of the values defined in
PackageManager
.- Type:
- testing_repository¶
The name of repository where updates are placed for testing before being pushed to the main repository.
- Type:
str
- eol¶
End-of-life of the release in a datetime.date() format ‘2020-05-17’.
- Type:
str
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- classmethod all_releases()[source]¶
Return a mapping of release states to a list of dictionaries describing the releases.
- Returns:
Mapping strings of
ReleaseState
names to lists of dictionaries that describe the releases in those states.- Return type:
defaultdict
- property collection_name¶
Fedora EPEL).
- Returns:
The collection name of this release.
- Return type:
str
- Type:
Return the collection name of this release (eg
- property critpath_mandatory_days_in_testing¶
Return the number of days that critpath updates in this release must spend in testing.
- Returns:
The number of days in testing that critpath updates in this release must spend in testing. If the release isn’t configured to have critpath mandatory testing time, 0 is returned.
- Return type:
int
- property critpath_min_karma: int¶
Return the min_karma for critpath updates for this release.
If the release doesn’t specify a min_karma, the default critpath.min_karma setting is used instead.
- Returns:
The minimum karma required for critical path updates for this release.
- classmethod from_tags(tags, session)[source]¶
Find a release associated with one of the given koji tags.
- Parameters:
tags (list) – A list of koji tags for which an associated release is desired.
session (sqlalchemy.orm.session.Session) – A database session.
- Returns:
- The first release found that matches the first tag. If no release is
found,
None
is returned.
- Return type:
Release or None
- get_pending_signing_side_tag(from_tag: str) str [source]¶
Return the signing-pending side tag for this
Release
.- Parameters:
from_tag – Name of side tag from which
Update
was created.- Returns:
Signing-pending side tag used in koji.
- get_pending_testing_side_tag(from_tag: str) str [source]¶
Return the testing-pending side tag for this
Release
.- Parameters:
from_tag – Name of side tag from which
Update
was created.- Returns:
Testing-pending side tag used in koji.
- classmethod get_tags(session)[source]¶
Return a 2-tuple mapping tags to releases.
- Parameters:
session (sqlalchemy.orm.session.Session) – A database session.
- Returns:
A 2-tuple. The first element maps the keys ‘candidate’, ‘testing’, ‘stable’, ‘override’, ‘pending_testing’, and ‘pending_stable’ each to a list of tags for various releases that correspond to those tag semantics. The second element maps each koji tag to the release’s name that uses it.
- Return type:
tuple
- id¶
- property mandatory_days_in_testing¶
Return the number of days that updates in this release must spend in testing.
- Returns:
The number of days in testing that updates in this release must spend in testing. If the release isn’t configured to have mandatory testing time, 0 is returned.
- Return type:
int
- property setting_prefix: str¶
Return the prefix for settings that pertain to this Release.
- Returns:
The Release’s setting prefix.
- property setting_status: str | None¶
Return the status of the Release from settings.
Return the Release’s status setting from the config. For example, if the release is f30, this will return the value of f30.status from the config file.
Note: This is not the same as Release.state.
- Returns:
The status of the release.
- property version_int¶
Return an integer representation of the version of this release.
- Returns:
The version of the release.
- Return type:
int
- class bodhi.server.models.ReleaseState[source]¶
Bases:
DeclEnum
An enum that describes the state of a
Release
.- disabled¶
Indicates that the release is disabled.
- Type:
- pending¶
Indicates that the release is pending.
- Type:
- frozen¶
Indicates that the release is frozen.
- Type:
- current¶
Indicates that the release is current.
- Type:
- archived¶
Indicates that the release is archived.
- Type:
- class bodhi.server.models.RpmBuild(**kwargs)[source]¶
Bases:
Build
Represents an RPM build.
Note that this model uses single-table inheritance with its Build superclass.
- nvr¶
A dash (-) separated string of an RPM’s name, version, and release (e.g. ‘bodhi-2.5.0-1.fc26’)
- Type:
str
- epoch¶
The RPM’s epoch.
- Type:
int
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- property evr¶
Return the RpmBuild’s epoch, version, release, all strings in a 3-tuple.
- Returns:
(epoch, version, release)
- Return type:
tuple
- get_changelog(timelimit=0, lastupdate=False)[source]¶
Retrieve the RPM changelog of this package since it’s last update, or since timelimit.
- Parameters:
timelimit (int) – Timestamp, specified as the number of seconds since 1970-01-01 00:00:00 UTC.
lastupdate (bool) – Only returns changelog since last update.
- Returns:
The RpmBuild’s changelog.
- Return type:
str
- get_latest()[source]¶
Return the nvr string of the most recent evr that is less than this RpmBuild’s nvr.
If there is no other Build, this returns
None
.- Returns:
- An nvr string, formatted like RpmBuild.nvr. If there is no other
Build, returns
None
.
- Return type:
str or None
- id¶
- class bodhi.server.models.RpmPackage(**kwargs)[source]¶
Bases:
Package
Represents a RPM package.
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- id¶
- class bodhi.server.models.TestCase(**kwargs)[source]¶
Bases:
Base
Represents test cases from the wiki.
- name¶
The name of the test case.
- Type:
str
- package_name¶
The name of the package associated with this test case.
- Type:
str
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- id¶
- class bodhi.server.models.TestCaseKarma(**kwargs)[source]¶
Bases:
Base
Karma for a TestCase associated with a comment.
- karma¶
The karma associated with this TestCase comment.
- Type:
int
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- id¶
- class bodhi.server.models.TestGatingStatus[source]¶
Bases:
DeclEnum
This class lists the different status the
Update.test_gating_status
flag can have.- waiting¶
Bodhi is waiting to hear about the test gating status of the update.
- Type:
- ignored¶
Greenwave said that the update does not require any tests.
- Type:
- queued¶
Greenwave said that the required tests for this update have been queued.
- Type:
- running¶
Greenwave said that the required tests for this update are running.
- Type:
- passed¶
Greenwave said that the required tests for this update have passed.
- Type:
- failed¶
Greenwave said that the required tests for this update have failed.
- Type:
- class bodhi.server.models.Update(*args, **kwargs)[source]¶
Bases:
Base
This model represents an update.
The update contains not just one package, but a collection of packages. Each package can be referenced only once in one Update. Packages are referenced through their Build objects using field
builds
below.- autokarma¶
A boolean that indicates whether or not the update will be automatically pushed when the stable_karma threshold is reached.
- Type:
bool
- autotime¶
A boolean that indicates whether or not the update will be automatically pushed when the time threshold is reached.
- Type:
bool
- stable_karma¶
A positive integer that indicates the amount of “good” karma the update must receive before being automatically marked as stable.
- Type:
int
- stable_days¶
A positive integer that indicates the number of days an update needs to spend in testing before being automatically marked as stable.
- Type:
int
- unstable_karma¶
A positive integer that indicates the amount of “bad” karma the update must receive before being automatically marked as unstable.
- Type:
int
- requirements¶
A list of taskotron tests that must pass for this update to be considered stable.
- Type:
str
- require_bugs¶
Indicates whether or not positive feedback needs to be provided for the associated bugs before the update can be considered stable.
- Type:
bool
- require_testcases¶
Indicates whether or not the update requires that positive feedback be given on all associated wiki test cases before the update can pass to stable. If the update has no associated wiki test cases, this option has no effect.
- Type:
bool
- display_name¶
Allows the user to customize the name of the update.
- Type:
str
- notes¶
Notes about the update. This is a human-readable field that describes what the update is for (e.g. the bugs it fixes).
- Type:
str
- type¶
The type of the update (e.g. enhancement, bugfix, etc). It must be one of the values defined in
UpdateType
.- Type:
- status¶
The current status of the update. Possible values include ‘pending’ to indicate it is not yet in a repository, ‘testing’ to indicate it is in the testing repository, etc. It must be one of the values defined in
UpdateStatus
.- Type:
- request¶
The requested status of the update. This must be one of the values defined in
UpdateRequest
orNone
.- Type:
- severity¶
The update’s severity. This must be one of the values defined in
UpdateSeverity
.- Type:
- suggest¶
Suggested action a user should take after applying the update. This must be one of the values defined in
UpdateSuggestion
.- Type:
- locked¶
Indicates whether or not the update is locked and un-editable. This is usually set by the composer because the update is going through a state transition.
- Type:
bool
- pushed¶
Indicates whether or not the update has been pushed to its requested repository.
- Type:
bool
- critpath¶
Indicates whether or not the update is for a “critical path”
Package
. Critical path packages are packages that are required for basic functionality. For example, the kernelRpmPackage
is a critical path package.- Type:
bool
- critpath_groups¶
Space-separated list of critical path groups the package(s) in this update are members of. More detailed version of critpath. Empty string means “no groups” (same as critpath=False); None/null means “feature not supported” (i.e. the configured critpath.type doesn’t give grouped critpath info).
- Type:
str
- close_bugs¶
Indicates whether the Bugzilla bugs that this update is related to should be closed automatically when the update is pushed to stable.
- Type:
bool
- date_submitted¶
The date that the update was created.
- Type:
DateTime
- date_modified¶
The date the update was last modified or
None
.- Type:
DateTime
- date_approved¶
The date the update was approved or
None
.- Type:
DateTime
- date_testing¶
The date the update was placed into the testing repository or
None
.- Type:
DateTime
- date_stable¶
The date the update was placed into the stable repository or
None
.- Type:
DateTime
- alias¶
The update alias (e.g. FEDORA-EPEL-2009-12345).
- Type:
str
- release_id¶
A foreign key to the releases
id
.- Type:
int
- comments¶
A list of the
Comment
objects for this update.- Type:
sqlalchemy.orm.collections.InstrumentedList
- builds¶
A list of
Build
objects contained in this update.- Type:
sqlalchemy.orm.collections.InstrumentedList
- bugs¶
A list of
Bug
objects associated with this update.- Type:
sqlalchemy.orm.collections.InstrumentedList
- test_gating_status¶
The test gating status of the update. This must be one of the values defined in
TestGatingStatus
orNone
. None indicates that Greenwave integration was not enabled when the update was created.- Type:
- compose¶
The
Compose
that this update is currently being composed in. The update is locked if this is defined.- Type:
- from_tag¶
The koji tag from which the list of builds was originally populated (if any).
- Type:
str
- __init__(*args, **kwargs)¶
Initialize the Update.
We use this as a way to inject an alias into the Update, since it is a required field and we don’t want callers to have to generate the alias themselves.
- __json__(request=None)[source]¶
Return a JSON representation of this update.
- Parameters:
request (pyramid.request.Request or None) – The current web request, or None. Passed on to
BodhiBase.__json__()
.- Returns:
A JSON representation of this update.
- Return type:
str
- __str__()[source]¶
Return a string representation of this update.
- Returns:
A string representation of the update.
- Return type:
str
- abs_url(request=None)[source]¶
Return the absolute URL to this update.
- Parameters:
request (pyramid.request.Request or None) – The current web request. Unused.
- add_tag(tag)[source]¶
Add the given koji tag to all
Builds
in this update.- Parameters:
tag (str) – The tag to be added to the builds.
- property builds_json¶
Return a JSON representation of this update’s associated builds.
- Returns:
A JSON list of the
Builds
associated with this update.- Return type:
str
- check_karma_thresholds(db, agent)[source]¶
Check if we have reached either karma threshold, and adjust state as necessary.
This method will call
set_request()
if necessary. If the update is locked, it will ignore karma thresholds and raise an Exception.- Parameters:
db (sqlalchemy.orm.session.Session) – A database session.
agent (str) – The username of the user who has provided karma.
- Raises:
LockedUpdateException – If the update is locked.
- check_requirements(session, settings)[source]¶
Check that an update meets its self-prescribed policy to be pushed.
- Parameters:
session (sqlalchemy.orm.session.Session) – A database session. Unused.
settings (bodhi.server.config.BodhiConfig) – Bodhi’s settings.
- Returns:
- A tuple containing (result, reason) where result is a bool
and reason is a str.
- Return type:
tuple
- comment(session, text, karma=0, author=None, karma_critpath=0, bug_feedback=None, testcase_feedback=None, check_karma=True, email_notification=True)[source]¶
Add a comment to this update.
If the karma reaches the ‘stable_karma’ value, then request that this update be marked as stable. If it reaches the ‘unstable_karma’, it is unpushed.
- static comment_on_test_gating_status_change(target, value, old, initiator)[source]¶
Place comment on the update when
test_gating_status
changes.Only notify the users by email if the new status is in
failed
.- Parameters:
target (InstanceState) – The state of the instance that has had a change to its test_gating_status attribute.
value (EnumSymbol) – The new value of the test_gating_status.
old (EnumSymbol) – The old value of the test_gating_status
initiator (sqlalchemy.orm.attributes.Event) – The event object that is initiating this transition.
- property comments_since_karma_reset¶
Generate the comments since the most recent karma reset event.
Karma is reset when
Builds
are added or removed from an update.- Returns:
class:Comments <Comment> since the karma reset.
- Return type:
list
- static contains_critpath_component(builds, release_branch)[source]¶
Determine if there is a critpath component in the builds passed in.
- Parameters:
builds (list) –
Builds
to be considered.release_branch (str) – The name of the git branch associated to the release, such as “f25” or “master”.
- Returns:
True
if the update contains a critical path package,False
otherwise.- Return type:
bool
- Raises:
RuntimeError – If the PDC did not give us a 200 code.
- property content_type¶
Return the ContentType associated with this update.
If the update has no
Builds
, this evaluates toNone
.- Returns:
The content type of this update or
None
.- Return type:
ContentType or None
- property critpath_approved¶
Return whether or not this critpath update has been approved.
- Returns:
True if this update meets critpath testing requirements, False otherwise.
- Return type:
bool
- property date_locked¶
Return the time that this update became locked.
- Returns:
- The time this update became locked, or None if it is not
locked.
- Return type:
datetime.datetime or None
- date_pushed¶
Return the time that this update was pushed in repository.
- Returns:
- The most recent between date_testing and date_stable, or
None if the update was never pushed in any repo.
- Return type:
datetime.datetime or None
- property days_in_testing¶
Return the number of days that this update has been in testing.
- Returns:
The number of days since this update’s date_testing if it is set, else 0.
- Return type:
int
- property days_to_stable¶
Return the number of days until an update can be pushed to stable.
This method will return the number of days until an update can be pushed to stable, or 0. 0 is returned if the update meets testing requirements already, if it doesn’t have a “truthy” date_testing attribute, or if it’s been in testing for the release’s mandatory_days_in_testing or longer.
- Returns:
- The number of dates until this update can be pushed to stable, or 0 if it cannot be
determined.
- Return type:
int
- classmethod edit(request, data)[source]¶
Edit the update.
- Parameters:
request (pyramid.request.Request) – The current web request.
data (dict) – A key-value mapping of what should be altered in this update.
- Returns:
A 2-tuple of the edited update and a list of dictionaries that describe caveats.
- Return type:
tuple
- Raises:
LockedUpdateException – If the update is locked.
RuntimeError – If the PDC did not give us a 200 code.
- find_conflicting_builds() list [source]¶
Find if there are any builds conflicting with the stable tag in the update.
Returns a list of conflicting builds, empty is none found.
- property full_test_cases¶
Return a list of all TestCases associated with all packages in this update.
- Returns:
A list of
TestCases
.- Return type:
list
- get_bug_karma(bug)[source]¶
Return the karma for this update for the given bug.
- Parameters:
bug (Bug) – The bug we want the karma about.
- Returns:
A 2-tuple of integers. The first represents negative karma, the second represents positive karma.
- Return type:
tuple
- get_bugstring(show_titles=False)[source]¶
Return a space-delimited string of bug numbers for this update.
- Parameters:
show_titles (bool) – If True, include the bug titles in the output. If False, include only bug ids.
- Returns:
A space separated list of bugs associated with this update.
- Return type:
str
- static get_critpath_groups(builds, release_branch)[source]¶
Determine which (if any) critpath groups the builds passed in are part of.
- Parameters:
builds (list) –
Builds
to be considered.release_branch (str) – The name of the git branch associated to the release, such as “f25” or “master”.
- Returns:
A space-separated list of the critpath groups. Will be empty if none.
- Return type:
str
- Raises:
ValueError – If the configured critpath.type does not list by group.
- get_maintainers()[source]¶
Return a list of maintainers who have commit access on the packages in this update.
- Returns:
- A list of
Users
who have commit access to all of the packages that are contained within this update.
- A list of
- Return type:
list
- get_tags()[source]¶
Return all koji tags for all builds on this update.
- Returns:
strings of the koji tags used in this update.
- Return type:
list
- get_test_gating_info()[source]¶
Query Greenwave about this update and return the information retrieved.
- Returns:
A list of response dicts from Greenwave for this update.
- Return type:
list
- Raises:
BodhiException – When the
greenwave_api_url
is undefined in configuration.RuntimeError – If Greenwave did not give us a 200 code.
- get_testcase_karma(testcase)[source]¶
Return the karma for this update for the given TestCase.
- Parameters:
testcase (TestCase) – The TestCase we want the karma about.
- Returns:
A 2-tuple of integers. The first represents negative karma, the second represents positive karma.
- Return type:
tuple
- get_title(delim=' ', limit=None, after_limit='…', beautify=False, nvr=False, amp=False)[source]¶
Return a title for the update based on the
Builds
it is associated with.- Parameters:
delim (str) – The delimiter used to separate the builds. Defaults to ‘ ‘.
limit (int or None) – If provided, limit the number of builds included to the given number. If
None
(the default), no limit is used.after_limit (str) – If a limit is set, use this string after the limit is reached. Defaults to ‘…’.
beautify (bool) – If provided, the returned string will be human readable, i.e. 3 or more builds will take the form “package1, package2 and XXX more”.
nvr (bool) – If specified, the title will include name, version and release information in package labels.
amp (bool) – If specified, it will replace the word ‘and’ with an ampersand, ‘&’.
- Returns:
A title for this update.
- Return type:
str
- greenwave_request_batches(verbose)[source]¶
Form and return the proper Greenwave API requests data for this Update.
- Returns:
- A list of dictionaries that are appropriate to be passed to the Greenwave API
for a decision about this Update.
- Return type:
list
- property greenwave_request_batches_json¶
Form and return the proper Greenwave API requests data for this Update as JSON.
- Returns:
- A JSON list of objects that are appropriate to be passed to the Greenwave
API for a decision about this Update.
- Return type:
str
- property greenwave_subject¶
Form and return the proper Greenwave API subject field for this Update.
- Returns:
- A list of dictionaries that are appropriate to be passed to the Greenwave API
subject field for a decision about this Update.
- Return type:
list
- property greenwave_subject_batch_size¶
Maximum number of subjects in single Greenwave request.
- property has_stable_comment¶
Return whether Bodhi has commented on the update that the requirements have been met.
This is used to determine whether bodhi should add the comment about the Update’s eligibility to be pushed, as we only want Bodhi to add the comment once.
- Returns:
See description above for what the bool might mean.
- Return type:
bool
- id¶
- property install_command: str¶
Return the appropriate command for installing the Update.
- There are four conditions under which the empty string is returned:
If the update is in testing status for rawhide.
If the update is not in a stable or testing repository.
If the release has not specified a package manager.
If the release has not specified a testing repository.
- Returns:
The dnf command to install the Update, or the empty string.
- property karma¶
Calculate and return the karma for the Update.
- Returns:
The Update’s current karma.
- Return type:
int
- property last_modified¶
Return the last time this update was edited or created.
This gets used specifically by taskotron/resultsdb queries so we only query for test runs that occur after the last time this update (in its current form) was in play.
- Returns:
The most recent time of modification or creation.
- Return type:
datetime.datetime
- Raises:
ValueError – If the update has no timestamps set, which should not be possible.
- property mandatory_days_in_testing¶
Calculate and return how many days an update should be in testing before becoming stable.
- Returns:
The number of mandatory days in testing.
- Return type:
int
- property meets_testing_requirements¶
Return whether or not this update meets its release’s testing requirements.
If this update’s release does not have a mandatory testing requirement, then simply return True.
- Returns:
True if the update meets testing requirements, False otherwise.
- Return type:
bool
- modify_bugs()[source]¶
Comment on and close this update’s bugs as necessary.
This typically gets called by the Composer at the end.
- classmethod new(request, data)[source]¶
Create a new update.
- Parameters:
request (pyramid.request.Request) – The current web request.
data (dict) – A key-value mapping of the new update’s attributes.
- Returns:
A 2-tuple of the edited update and a list of dictionaries that describe caveats.
- Return type:
tuple
- Raises:
RuntimeError – If the PDC did not give us a 200 code.
- property num_admin_approvals¶
Return the number of Releng/QA approvals of this update.
- Returns:
The number of admin approvals found in the comments of this update.
- Return type:
int
- obsolete(db, newer=None)[source]¶
Obsolete this update.
Even though unpushing/obsoletion is an “instant” action, changes in the repository will not propagate until the next compose takes place.
- Parameters:
db (sqlalchemy.orm.session.Session) – A database session.
newer (Update or None) – If given, the update that has obsoleted this one. Defaults to
None
.
- obsolete_if_unstable(db)[source]¶
Obsolete the update if it reached the negative karma threshold while pending.
- Parameters:
db (sqlalchemy.orm.session.Session) – A database session.
- obsolete_older_updates(db)[source]¶
Obsolete any older pending/testing updates.
If a build is associated with multiple updates, make sure that all updates are safe to obsolete, or else just skip it.
- Parameters:
db (sqlalchemy.orm.session.Session) – A database session.
- Returns:
A list of dictionaries that describe caveats.
- Return type:
list
- property product_version¶
Return a string of the product version that this update’s release is associated with.
The product version is a string, such as “fedora-26”, and is used when querying Greenwave for test gating decisions.
- Returns:
The product version associated with this Update’s Release.
- Return type:
str
- remove_tag(tag, koji=None)[source]¶
Remove the given koji tag from all builds in this update.
- Parameters:
tag (str) – The tag to remove from the
Builds
in this update.koji (koji.ClientSession or None) – A koji client to use to perform the action. If None (the default), this method will use
buildsys.get_session()
to get one and multicall will be used.
- Returns:
- If a koji client was provided,
None
is returned. Else, a list of tasks from
koji.multiCall()
are returned.
- If a koji client was provided,
- Return type:
list or None
- property requested_tag¶
Return the tag the update has requested.
- Returns:
The Koji tag that corresponds to the update’s current request.
- Return type:
str
- Raises:
RuntimeError – If a Koji tag is unable to be determined.
- property requirements_json¶
Return a JSON representation of this update’s requirements.
- Returns:
A JSON representation of this update’s requirements.
- Return type:
str
- revoke()[source]¶
Remove pending request for this update.
- Raises:
BodhiException – If the update doesn’t have a request set, or if it is not in an expected status.
- set_request(db, action, username)[source]¶
Set the update’s request to the given action.
- Parameters:
db (sqlalchemy.orm.session.Session) – A database session.
action (UpdateRequest or str) – The desired request. May be expressed as an UpdateRequest instance, or as a string describing the desired request.
username (str) – The username of the user making the request.
- Raises:
BodhiException – Two circumstances can raise this
Exception
: * If the user tries to push a critical path update directly from pending to stable. * If the update doesn’t meet testing requirements.LockedUpdateException – If the update is locked.
- property signed¶
Return whether the update is considered signed or not.
This will return
True
if allBuilds
associated with this update are signed, or if the associatedRelease
does not have apending_signing_tag
defined. Otherwise, it will returnFalse
.If the update is created
from_tag
always check if every build is signed.- Returns:
True
if the update is signed,False
otherwise.- Return type:
bool
- status_comment(db)[source]¶
Add a comment to this update about a change in status.
- Parameters:
db (sqlalchemy.orm.session.Session) – A database session.
- property test_cases¶
Return a list of all TestCase names associated with all packages in this update.
- Returns:
- A list of strings naming the
TestCases
associated with this update.
- A list of strings naming the
- Return type:
list
- property test_gating_passed: bool¶
Returns a boolean representing if this update has passed the test gating.
- Returns:
True if the Update’s test_gating_status property is None, ignored, or passed. Otherwise it returns False.
- property title: str¶
Return the Update’s title.
This is just an alias for get_title with default parameters.
- unpush(db)[source]¶
Move this update back to its dist-fX-updates-candidate tag.
- Parameters:
db (sqlalchemy.orm.session.Session) – A database session.
- Raises:
BodhiException – If the update isn’t in testing.
- untag(db, preserve_override: bool = False)[source]¶
Untag all of the
Builds
in this update.- Parameters:
db (sqlalchemy.orm.session.Session) – A database session.
preserve_override – whether to preserve the override tag or not
- update_bugs(bug_ids, session)[source]¶
Make the update’s bugs consistent with the given list of bug ids.
Create any new bugs, and remove any missing ones. Destroy removed bugs that are no longer referenced anymore. If any associated bug is found to be a security bug, alter the update to be a security update.
- Parameters:
bug_ids (list) – A list of strings of bug ids to associate with this update.
session (sqlalchemy.orm.session.Session) – A database session.
- Returns:
Bugs
that are newly associated with the update.- Return type:
list
- update_test_gating_status()[source]¶
Query Greenwave about this update and set the test_gating_status as appropriate.
- url(request=None)¶
Return the absolute URL to this update.
- Parameters:
request (pyramid.request.Request or None) – The current web request. Unused.
- validate_builds(key, build)[source]¶
Validate builds being appended to ensure they are all the same type.
- Parameters:
key (str) – The field’s key, which is un-used in this validator.
build (Build) – The build object which was appended to the list of builds.
- Raises:
ValueError – If the build being appended is not the same type as the existing builds.
- validate_release(key, release)[source]¶
Make sure the release is the same content type as this update.
- Parameters:
key (str) – The field’s key, which is un-used in this validator.
release (Release) – The release object which is being associated with this update.
- Raises:
ValueError – If the release being associated is not the same content type as the update.
- property version_hash¶
Return a SHA1 hash of the Builds NVRs.
- Returns:
a SHA1 hash of the builds NVRs.
- Return type:
str
- waive_test_results(username, comment=None, tests=None)[source]¶
Attempt to waive test results for this update.
- Parameters:
username (str) – The name of the user who is waiving the test results.
comment (str) – A comment from the user describing their decision.
tests (list of str) – A list of testcases to be waived. Defaults to
None
If left asNone
, allunsatisfied_requirements
returned by greenwave will be waived, otherwise only the testcase found in both list will be waived.
- Raises:
LockedUpdateException – If the Update is locked.
BodhiException – If test gating is not enabled in this Bodhi instance, or if the tests have passed.
RuntimeError – Either WaiverDB or Greenwave did not give us a 200 code.
- class bodhi.server.models.UpdateRequest[source]¶
Bases:
DeclEnum
An enum used to specify an update requesting to change states.
- testing¶
The update is requested to change to testing.
- Type:
- obsolete¶
The update has been obsoleted by another update.
- Type:
- unpush¶
The update no longer needs to be released.
- Type:
- revoke¶
The unpushed update will no longer be composed in any repository.
- Type:
- stable¶
The update is ready to be pushed to the stable repository.
- Type:
- class bodhi.server.models.UpdateSeverity[source]¶
Bases:
DeclEnum
An enum used to specify the severity of the update.
- unspecified¶
The packager has not specified a severity.
- Type:
- urgent¶
The update is urgent.
- Type:
- high¶
The update is high severity.
- Type:
- medium¶
The update is medium severity.
- Type:
- low¶
The update is low severity.
- Type:
- class bodhi.server.models.UpdateStatus[source]¶
Bases:
DeclEnum
An enum used to describe the current state of an update.
- pending¶
The update is not in any repository.
- Type:
- testing¶
The update is in the testing repository.
- Type:
- stable¶
The update is in the stable repository.
- Type:
- unpushed¶
The update had been in a testing repository, but has been removed.
- Type:
- obsolete¶
The update has been obsoleted by another update.
- Type:
- class bodhi.server.models.UpdateSuggestion[source]¶
Bases:
DeclEnum
An enum used to tell the user whether they need to reboot or logout after applying an update.
- unspecified¶
No action is needed.
- Type:
- reboot¶
The user should reboot after applying the update.
- Type:
- logout¶
The user should logout after applying the update.
- Type:
- class bodhi.server.models.UpdateType[source]¶
Bases:
DeclEnum
An enum used to classify the type of the update.
- bugfix¶
The update fixes bugs only.
- Type:
- security¶
The update addresses security issues.
- Type:
- newpackage¶
The update introduces new packages to the release.
- Type:
- enhancement¶
The update introduces new features.
- Type:
- class bodhi.server.models.User(**kwargs)[source]¶
Bases:
Base
A Bodhi user.
- name¶
The username.
- Type:
str
- email¶
An e-mail address for the user.
- Type:
str
- groups¶
An iterable of
Groups
the user is a member of.- Type:
sqlalchemy.orm.collections.InstrumentedList
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- avatar(request: pyramid.request) str | None [source]¶
Return a URL for the User’s avatar, or None if request is falsey.
- Parameters:
request – The current web request.
- Returns:
A URL for the User’s avatar, or None if request is falsey.
- id¶