bodhi.server.models

Bodhi’s database models.

Classes

BodhiBase Base class for the SQLAlchemy model base class.
Bug(**kwargs) Represents a Bugzilla bug.
BugKarma(**kwargs) Karma for a bug associated with a comment.
Build(**kwargs) This model represents a specific build of a package.
BuildrootOverride(**kwargs) This model represents a Koji buildroot override.
CVE(**kwargs) Represents a CVE.
Comment(**kwargs) An update comment.
Compose(**kwargs) Express the status of an in-progress compose job.
ComposeState Define the various states that a Compose can be in.
ContainerBuild(**kwargs) Represents a Container build.
ContainerPackage(**kwargs) Represents a Container package.
ContentType Used to differentiate between different kinds of content in various models.
DeclEnum Declarative enumeration.
DeclEnumType(enum) A database column type for an enum.
EnumMeta(classname, bases, dict_) Generate new DeclEnum classes.
EnumSymbol(cls_, name, value, description) Define a fixed symbol tied to a parent class.
Group(**kwargs) A group of users.
ModuleBuild(**kwargs) Represents a Module build.
ModulePackage(**kwargs) Represents a Module package.
Package(**kwargs) This model represents a package.
Release(**kwargs) Represent a distribution release, such as Fedora 27.
ReleaseState An enum that describes the state of a Release.
RpmBuild(**kwargs) Represents an RPM build.
RpmPackage(**kwargs) Represents a RPM package.
Stack(**kwargs) A group of packages that are commonly pushed together as a group.
TestCase(**kwargs) Represents test cases from the wiki.
TestCaseKarma(**kwargs) Karma for a TestCase associated with a comment.
TestGatingStatus This class lists the different status the Update.test_gating_status flag can have.
Update(**kwargs) This model represents an update.
UpdateRequest An enum used to specify an update requesting to change states.
UpdateSeverity An enum used to specify the severity of the update.
UpdateStatus An enum used to describe the current state of an update.
UpdateSuggestion An enum used to tell the user whether they need to reboot or logout after applying an update.
UpdateType An enum used to classify the type of the update.
User(**kwargs) A Bodhi user.
class bodhi.server.models.BodhiBase[source]

Bases: object

Base class for the SQLAlchemy model base class.

__exclude_columns__

tuple – A list of columns to exclude from JSON

__include_extras__

tuple – A list of methods or attrs to include in JSON

__get_by__

tuple – A list of columns that get() will query.

id

int – An integer id that serves as the default primary key.

query

sqlalchemy.orm.query.Query – a class property which produces a Query object against the class and the current Session when called.

__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, anonymize=False, exclude=None, include=None)[source]

Return a JSON representation of this model.

Parameters:
  • request (pyramid.util.Request or None) – The current web request, or None.
  • anonymize (bool) – If True, scrub out some information from the JSON blob using the model’s __anonymity_map__. Defaults to False.
  • 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:basestring
__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:

BodhiBase

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.
classmethod get(id)[source]

Return an instance of the model by using its __get_by__ attribute with id.

Parameters:id (object) – An attribute to look up the model by.
Returns:An instance of the model that matches the id, or None if no match was found.
Return type:BodhiBase or None
classmethod grid_columns()[source]

Return the column names for the model, except for the excluded ones.

Returns:A list of column names, with excluded ones removed.
Return type:list
update_relationship(name, model, data, db)[source]

Add items to or remove items from a many-to-many relationship.

pragma: no cover is on this method because it is only used by Stacks, which is not used by Fedora and will likely be removed in the future. See https://github.com/fedora-infra/bodhi/issues/2241

Parameters:
  • name (basestring) – The name of the relationship column on self, as well as the key in data.
  • model (BodhiBase) – The model class of the relationship that we’re updating.
  • data (dict) – A dict containing the key name with a list of values.
  • db (sqlalchemy.orm.session.Session) – A database session.
Returns:

A three-tuple of lists, new, same, and removed, indicating which items have been added and removed, and which remain unchanged.

Return type:

tuple

class bodhi.server.models.Bug(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

Represents a Bugzilla bug.

bug_id

int – The bug’s id.

title

unicode – The description of the bug.

security

bool – True if the bug is marked as a security issue.

url

unicode – The URL for the bug. Inaccessible due to being overridden by the url property (https://github.com/fedora-infra/bodhi/issues/1995).

parent

bool – True if this is a parent tracker bug for release-specific bugs.

cves

sqlalchemy.orm.collections.InstrumentedList – An interable of CVEs this bug is associated with.

__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, comment=None)[source]

Add a comment to the bug, pertaining to the given update.

Parameters:
  • update (Update) – The update that is related to the bug.
  • comment (basestring or None) – The comment to add to the bug. If None, a default message is added to the bug. Defaults to None.
close_bug(update)[source]

Close the bug.

Parameters:update (Update) – The update associated with the bug.
default_message(update)[source]

Return a default comment to add to a bug with add_comment().

Parameters:update (Update) – The update that is related to the bug.
Returns:The default comment to add to the bug related to the given update.
Return type:basestring
modified(update, comment)[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 (Update) – The update that is associated with this bug.
testing(update)[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 (Update) – The update associated with the bug.
update_details(bug=None)[source]

Grab details from rhbz to populate our bug fields.

This is typically called “offline” in the UpdatesHandler consumer.

Parameters:bug (bugzilla.bug.Bug or None) – The Bug to retrieve details from Bugzilla about. If None, self.bug_id will be used to retrieve the bug. Defaults to None.
url

Return a URL to the bug.

Returns:The URL to this bug.
Return type:basestring
class bodhi.server.models.BugKarma(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

Karma for a bug associated with a comment.

karma

int – The karma associated with this bug and comment.

comment

Comment – The comment this BugKarma is part of.

bug

Bug – The bug this BugKarma pertains to.

__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.

class bodhi.server.models.Build(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

This model represents a specific build of a package.

This model uses single-table inheritance to allow for different build types.

inherited

bool – The purpose of this column is unknown, and it appears to be unused. At the time of this writing, there are 112,234 records with inherited set to False and 0 with it set to True in the Fedora Bodhi deployment.

nvr

unicode – 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.

package_id

int – A foreign key to the Package that this Build is part of.

release_id

int – A foreign key to the Release that this Build is part of.

signed

bool – If True, this package has been signed by robosignatory. If False, it has not been signed yet.

update_id

int – A foreign key to the Update that this Build is part of.

release

sqlalchemy.orm.relationship – A relationship to the Release that this build is part of.

type

int – The polymorphic identify of the row. This is used by sqlalchemy to identify which subclass of Build to use.

__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_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_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_url()[source]

Return a the url to details about this build.

This method appears to be unused and incorrect.

Returns:A URL for this build.
Return type:str
nvr_name

Return the RPM name.

Returns:The name of the Build.
Return type:str
nvr_release

Return the RPM release.

Returns:The release of the Build.
Return type:str
nvr_version

Return the RPM version.

Returns:The version of the Build.
Return type:str
unpush(koji)[source]

Move this build back to the candidate tag and remove any pending tags.

Parameters:koji (bodhi.server.buildsys.Buildsysem or koji.ClientSession) – A koji client.
class bodhi.server.models.BuildrootOverride(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.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

unicode – A text field that holds arbitrary notes about the buildroot override.

submission_date

DateTime – The date that the buildroot override was submitted.

expiration_date

DateTime – The date that the buildroot override expires.

expired_date

DateTime – The date that the buildroot override expired.

build_id

int – The primary key of the Build this override is related to.

build

Build – The build this override is related to.

submitter_id

int – The primary key of the User this override was created by.

submitter

User – The user this override was created by.

__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, **data)[source]

Edit an existing buildroot override.

Parameters:
  • request (pyramid.util.Request) – The current web request.
  • data (dict) – The changed being made to the BuildrootOverride.
Returns:

The new updated override.

Return type:

BuildrootOverride

enable()[source]

Mark the BuildrootOverride as enabled.

expire()[source]

Mark the BuildrootOverride as expired.

classmethod new(request, **data)[source]

Create a new buildroot override.

Parameters:
  • request (pyramid.util.Request) – The current web request.
  • data (dict) – A dictionary of all the attributes to be used on the new override.
Returns:

The newly created BuildrootOverride instance.

Return type:

BuildrootOverride

nvr

Return the NVR of the Build associated with this override.

Returns:The override’s Build's NVR.
Return type:basestring
class bodhi.server.models.CVE(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

Represents a CVE.

cve_id

unicode – The CVE identifier for this CVE.

updates

sqlalchemy.orm.collections.InstrumentedList – An iterable of Updates associated with this CVE.

bugs

sqlalchemy.orm.collections.InstrumentedList – An iterable of Bugs associated with this CVE.

__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.

url

Return a URL about this CVE.

Returns:A URL describing this CVE.
Return type:str
class bodhi.server.models.Comment(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

An update comment.

karma

int – The karma associated with this comment. Defaults to 0.

karma_critpath

int – The critpath karma associated with this comment. Defaults to 0.

text

unicode – The text of the comment.

anonymous

bool – If True, the comment was from an anonymous user. Defaults to False.

timestamp

datetime.datetime – The time the comment was created. Defaults to the return value of datetime.utcnow().

update

Update – The update that this comment pertains to.

user

User – The user who wrote this comment.

__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)[source]

Return a JSON string representation of this comment.

Parameters:
Returns:

A JSON representation of this comment.

Return type:

basestring

__str__()[source]

Return a str representation of this comment.

Returns:A str representation of this comment.
Return type:str
rss_title

Return a formatted title for the comment using update alias and comment id.

Returns:A string represenatation of the comment for RSS feed.
Return type:basestring
unique_testcase_feedback

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.
Return type:list
url()[source]

Return a URL to this comment.

Returns:A URL to this comment.
Return type:basestring
class bodhi.server.models.Compose(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.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__

tuple – A tuple of columns to exclude when __json__() is called.

__include_extras__

tuple – A tuple of attributes to add when __json__() is called.

__tablename__

str – The name of the table in the database.

checkpoints

unicode – A JSON serialized object describing the checkpoints the masher has reached.

date_created

datetime.datetime – The time this Compose was created.

error_message

unicode – An error message indicating what happened if the Compose failed.

id

None – We don’t want the superclass’s primary key since we will use a natural primary key for this model.

release_id

int – The primary key of the Release that is being composed. Forms half of the primary key, with the other half being the request.

request

UpdateRequest – The request of the release that is being composed. Forms half of the primary key, with the other half being the release_id.

release

Release – The release that is being composed.

state_date

datetime.datetime – The time of the most recent change to the state attribute.

state

ComposeState – The state of the compose.

updates

sqlalchemy.orm.collections.InstrumentedList – An iterable of updates included in this compose.

__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, anonymize=False, exclude=None, include=None, composer=False)[source]

Serialize this compose in JSON format.

Parameters:
  • request (pyramid.util.Request or None) – The current web request, or None.
  • anonymize (bool) – If True, scrub out some information from the JSON blob using the model’s __anonymity_map__. Defaults to False.
  • 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:

basestring

__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, else False.
Return type:bool
__str__()[source]

Return a human-readable representation of this compose.

Returns:A string to be displayed to users decribing this compose.
Return type:basestring
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:

bodhi.server.models.Compose

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
security

Return whether this compose is a security related compose or not.

Returns:
True if any of the Updates in this compose are marked as
security 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.
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: bodhi.server.models.DeclEnum

Define the various states that a Compose can be in.

requested

EnumSymbol – A compose has been requested, but it has not started yet.

pending

EnumSymbol – The request for the compose has been received by the backend worker, but the compose has not started yet.

initializing

EnumSymbol – The compose is initializing.

updateinfo

EnumSymbol – The updateinfo.xml is being generated.

punging

EnumSymbol – A Pungi soldier has been deployed to deal with the situation.

notifying

EnumSymbol – Pungi has finished successfully, and we are now sending out various forms of notifications, such as e-mail, fedmsgs, and bugzilla.

success

EnumSymbol – The Compose has completed successfully.

failed

EnumSymbol – The compose has failed, abandon hope.

signing_repo

EnumSymbol – Waiting for the repo to be signed.

cleaning

EnumSymbol – Cleaning old Composes after successful completion.

class bodhi.server.models.ContainerBuild(**kwargs)[source]

Bases: bodhi.server.models.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.

class bodhi.server.models.ContainerPackage(**kwargs)[source]

Bases: bodhi.server.models.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.

class bodhi.server.models.ContentType[source]

Bases: bodhi.server.models.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

EnumSymbol – This is used to represent base classes that are shared between specific content types.

rpm

EnumSymbol – Used to represent RPM related objects.

module

EnumSymbol – Used to represent Module related objects.

container

EnumSymbol – Used to represent Container related objects.

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.

Parameters:
  • base (BodhiBase) – A base model class, such as Build or Package.
  • build (dict) – Information about the build from the build system (koji).
Returns:

The type-specific child class of base that is appropriate to use with the given koji build.

Return type:

BodhiBase

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:DeclEnumType
classmethod from_string(value)[source]

Convert a string version of the enum to its enum type.

Parameters:value (basestring) – A string that you wish to convert to an Enum value.
Returns:The symbol corresponding to the value.
Return type:EnumSymbol
Raises:ValueError – If no symbol matches the given value.
classmethod values()[source]

Return the possible values that this enum can take on.

Returns:A list of strings of the values that this enum can represent.
Return type:list
class bodhi.server.models.DeclEnumType(enum)[source]

Bases: sqlalchemy.sql.sqltypes.SchemaType, sqlalchemy.sql.type_api.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.
copy()[source]

Return a copy of self.

Returns:A copy of self.
Return type:DeclEnumType
create(bind=None, checkfirst=False)[source]

Issue CREATE ddl for this type, if applicable.

drop(bind=None, checkfirst=False)[source]

Issue DROP ddl for this type, if applicable.

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:

basestring

process_result_value(value, dialect)[source]

Return the enum that matches the given string.

Parameters:
  • value (basestring) – The name of an enum.
  • dialect (sqlalchemy.engine.default.DefaultDialect) – Unused.
Returns:

The enum that matches value, or None if value is None.

Return type:

EnumSymbol or None

class bodhi.server.models.EnumMeta(classname, bases, dict_)[source]

Bases: type

Generate new DeclEnum classes.

__init__(classname, bases, dict_)[source]

Initialize the metaclass.

Parameters:
  • classname (basestring) – The name of the enum.
  • bases (list) – A list of base classes for the enum.
  • dict (dict) – A key-value mapping for the new enum’s attributes.
Returns:

A new DeclEnum.

Return type:

DeclEnum

__iter__()[source]

Iterate the enum values.

Returns:An iterator for the enum values.
Return type:iterator
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 (basestring) – The name of this symbol.
  • value (basestring) – The value used in the database to represent this symbol.
  • description (basestring) – 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.util.Request) – The current request.
Returns:A string representation of this EnumSymbol’s value.
Return type:basestring
__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:basestring
__str__()

Return a string representation of this EnumSymbol.

Returns:A string representation of this EnumSymbol’s value.
Return type:unicode
__unicode__()[source]

Return a string representation of this EnumSymbol.

Returns:A string representation of this EnumSymbol’s value.
Return type:unicode
__weakref__

list of weak references to the object (if defined)

class bodhi.server.models.Group(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

A group of users.

name

unicode – The name of the Group.

users

sqlalchemy.orm.collections.InstrumentedList – An iterable of the Users who are in the group.

__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.

class bodhi.server.models.ModuleBuild(**kwargs)[source]

Bases: bodhi.server.models.Build

Represents a Module build.

Note that this model uses single-table inheritance with its Build superclass.

nvr

unicode – A unique Koji identifier for the module build.

__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.

nvr_name

Return the ModuleBuild’s name.

Returns:The name of the module.
Return type:str
nvr_release

Return the ModuleBuild’s version and context.

Returns:The version of the ModuleBuild.
Return type:str
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: bodhi.server.models.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.

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
class bodhi.server.models.Package(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

This model represents a package.

This model uses single-table inheritance to allow for different package types.

name

unicode – A unicode string that uniquely identifies the package.

requirements

unicode – A unicode string that lists space-separated taskotron test results that must pass for this package

type

int – The polymorphic identity column. This is used to identify what Python class to create when loading rows from the database.

builds

sqlalchemy.orm.collections.InstrumentedList – A list of Build objects.

test_cases

sqlalchemy.orm.collections.InstrumentedList – A list of TestCase objects.

committers

sqlalchemy.orm.collections.InstrumentedList – A list of User objects who are committers.

stack_id

int – A foreign key to the Stack

__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:basestring
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
fetch_test_cases(db)[source]

Get a list of test cases for this package from the wiki.

Parameters:db (sqlalchemy.orm.session.Session) – A database session.
static get_or_create(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: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:Package
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.

get_pkg_pushers(branch, settings)[source]

Return users who can commit and are watching a package.

pragma: no cover is used on this method because pkgdb support is planned to be dropped in Bodhi. See https://github.com/fedora-infra/bodhi/issues/1970

Return two two-tuples of lists:
  • The first tuple is for usernames. The second tuple is for groups.
  • The first list of the tuples is for committers. The second is for watchers.
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.Release(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

Represent a distribution release, such as Fedora 27.

name

unicode – The name of the release, such as ‘F27’.

long_name

unicode – A human readable name for the release, such as ‘Fedora 27’.

version

unicode – The version of the release, such as ‘27’.

id_prefix

unicode – The prefix to use when forming update aliases for this release, such as ‘FEDORA’.

branch

unicode – The dist-git branch associated with this release, such as ‘f27’.

dist_tag

unicode – The koji dist_tag associated with this release, such as ‘f27’.

stable_tag

unicode – The koji tag to be used for stable builds in this release, such as ‘f27-updates’.

testing_tag

unicode – The koji tag to be used for testing builds in this release, such as ‘f27-updates-testing’.

candidate_tag

unicode – The koji tag used for builds that are candidates to be updates, such as ‘f27-updates-candidate’.

pending_signing_tag

unicode – The koji tag that specifies that a build is waiting to be signed, such as ‘f27-signing-pending’.

pending_testing_tag

unicode – The koji tag that indicates that a build is waiting to be mashed into the testing repository, such as ‘f27-updates-testing-pending’.

pending_stable_tag

unicode – The koji tag that indicates that a build is waiting to be mashed into the stable repository, such as ‘f27-updates-pending’.

override_tag

unicode – The koji tag that is used when a build is added as a buildroot override, such as ‘f27-override’.

state

ReleaseState – The current state of the release. Defaults to ReleaseState.disabled.

id

int – The primary key of this release.

builds

sqlalchemy.orm.collections.InstrumentedList – An iterable of Builds associated with this release.

__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
collection_name

Return the collection name of this release (eg – Fedora EPEL).

Returns:The collection name of this release.
Return type:basestring
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

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
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, None is returned.
Return type:int or None
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: bodhi.server.models.DeclEnum

An enum that describes the state of a Release.

disabled

EnumSymbol – Indicates that the release is disabled.

pending

EnumSymbol – Indicates that the release is pending.

current

EnumSymbol – Indicates that the release is current.

archived

EnumSymbol – Indicates taht the release is archived.

class bodhi.server.models.RpmBuild(**kwargs)[source]

Bases: bodhi.server.models.Build

Represents an RPM build.

Note that this model uses single-table inheritance with its Build superclass.

nvr

unicode – A dash (-) separated string of an RPM’s name, version, and release (e.g. u’bodhi-2.5.0-1.fc26’)

epoch

int – The RPM’s epoch.

__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.

evr

Return the RpmBuild’s epoch, version, release, all basestrings in a 3-tuple.

Returns:(epoch, version, release)
Return type:tuple
get_changelog(timelimit=0)[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.
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:basestring or None
class bodhi.server.models.RpmPackage(**kwargs)[source]

Bases: bodhi.server.models.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.

class bodhi.server.models.Stack(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

A group of packages that are commonly pushed together as a group.

name

unicode – The name of the stack.

packages

sqlalchemy.orm.collections.InstrumentedList – An iterable of Packages associated with this stack.

description

unicode – A human readable description of the stack.

requirements

unicode – The required tests for the stack.

users

sqlalchemy.orm.collections.InstrumentedList – An iterable of Users associated with this stack.

groups

sqlalchemy.orm.collections.InstrumentedList – An iterable of Groups associated with this stack.

__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.

class bodhi.server.models.TestCase(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

Represents test cases from the wiki.

name

unicode – The name of the test case.

package_id

int – The primary key of the Package associated with this test case.

package

Package – The package associated with this test case.

__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.

class bodhi.server.models.TestCaseKarma(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

Karma for a TestCase associated with a comment.

karma

int – The karma associated with this TestCase comment.

comment

Comment – The comment this TestCaseKarma is associated with.

testcase

TestCase – The TestCase this TestCaseKarma pertains to.

__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.

class bodhi.server.models.TestGatingStatus[source]

Bases: bodhi.server.models.DeclEnum

This class lists the different status the Update.test_gating_status flag can have.

waiting

EnumSymbol – Bodhi is waiting to hear about the test gating status of the update.

ignored

EnumSymbol – Greenwave said that the update does not require any tests.

queued

EnumSymbol – Greenwave said that the required tests for this update have been queued.

running

EnumSymbol – Greenwave said that the required tests for this update are running.

passed

EnumSymbol – Greenwave said that the required tests for this update have passed.

failed

EnumSymbol – Greenwave said that the required tests for this update have failed.

class bodhi.server.models.Update(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

This model represents an update.

title

unicode – The update’s title which uniquely identifies the update. This is generally an ordered list of the build NVRs contained in the update.

autokarma

bool – A boolean that indicates whether or not the update will be automatically pushed when the stable_karma threshold is reached.

stable_karma

int – A positive integer that indicates the amount of “good” karma the update must receive before being automatically marked as stable.

unstable_karma

int – A positive integer that indicates the amount of “bad” karma the update must receive before being automatically marked as unstable.

requirements

unicode – A list of taskotron tests that must pass for this update to be considered stable.

require_bugs

bool – Indicates whether or not positive feedback needs to be provided for the associated bugs before the update can be considered stable.

require_testcases

bool – 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.

display_name

str – Allows the user to customize the name of the update.

notes

unicode – Notes about the update. This is a human-readable field that describes what the update is for (e.g. the bugs it fixes).

type

EnumSymbol – The type of the update (e.g. enhancement, bugfix, etc). It must be one of the values defined in UpdateType.

status

EnumSymbol – 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.

request

EnumSymbol – The requested status of the update. This must be one of the values defined in UpdateRequest or None.

severity

EnumSymbol – The update’s severity. This must be one of the values defined in UpdateSeverity.

suggest

EnumSymbol – Suggested action a user should take after applying the update. This must be one of the values defined in UpdateSuggestion.

locked

bool – Indicates whether or not the update is locked and un-editable. This is usually set by the masher because the update is going through a state transition.

pushed

bool – Indicates whether or not the update has been pushed to its requested repository.

critpath

bool – 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 kernel RpmPackage is a critical path package.

close_bugs

bool – Indicates whether the Bugzilla bugs that this update is related to should be closed automatically when the update is pushed to stable.

date_submitted

DateTime – The date that the update was created.

date_modified

DateTime – The date the update was last modified or None.

date_approved

DateTime – The date the update was approved or None.

date_pushed

DateTime – The date the update was pushed or None.

date_testing

DateTime – The date the update was placed into the testing repository or None.

date_stable

DateTime – The date the update was placed into the stable repository or None.

alias

unicode – The update alias (e.g. FEDORA-EPEL-2009-12345).

old_updateid

unicode – The legacy update ID which has been deprecated.

release_id

int – A foreign key to the releases id.

release

Release – The Release object this update relates to via the release_id.

comments

sqlalchemy.orm.collections.InstrumentedList – A list of the Comment objects for this update.

builds

sqlalchemy.orm.collections.InstrumentedList – A list of Build objects contained in this update.

bugs

sqlalchemy.orm.collections.InstrumentedList – A list of Bug objects associated with this update.

cves

sqlalchemy.orm.collections.InstrumentedList – A list of CVE objects associated with this update.

user_id

int – A foreign key to the User that created this update.

test_gating_status

EnumSymbol – The test gating status of the update. This must be one of the values defined in TestGatingStatus or None. None indicates that Greenwave integration was not enabled when the update was created.

greenwave_summary_string

unicode – A short summary of the outcome from Greenwave (e.g. 2 of 32 required tests failed).

greenwave_unsatisfied_requirements

unicode – When test_gating_status is failed, Bodhi will set this to a JSON representation of the unsatisfied_requirements field from Greewave’s response.

compose

Compose – The Compose that this update is currently being mashed in. The update is locked if this is defined.

__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, anonymize=False)[source]

Return a JSON representation of this update.

Parameters:
  • request (pyramid.util.Request or None) – The current web request, or None. Passed on to BodhiBase.__json__().
  • anonymize (bool) – Whether to anonymize the results. Passed on to BodhiBase.__json__().
Returns:

A JSON representation of this update.

Return type:

basestring

__str__()[source]

Return a string representation of this update.

Returns:A string representation of the update.
Return type:basestring
abs_url(request=None)[source]

Return the absolute URL to this update.

Parameters:request (pyramid.util.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 (basestring) – The tag to be added to the builds.
assign_alias()[source]

Return a randomly-suffixed update ID.

This function used to construct update IDs in a monotonic sequence, but we ran into race conditions so we do it randomly now.

beautify_title(amp=False, nvr=False)[source]

Return a human readable title for this update.

This is used mostly in subject of a update notification email and displaying the title in html. If there are 3 or more builds per title the title be:

“package1, package, 2 and XXX more”

If the “amp” parameter is specified it will replace the and with and & html entity

If the “nvr” parameter is specified it will include name, version and release information in package labels.

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:basestring
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 (basestring) – 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, anonymous=False, karma_critpath=0, bug_feedback=None, testcase_feedback=None, check_karma=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.

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_name)[source]

Determine if there is a critpath component in the builds passed in.

Parameters:
  • builds (list) – Builds to be considered.
  • release_name (basestring) – The name of the release, such as “f25”.
Returns:

True if the update contains a critical path package, False otherwise.

Return type:

bool

content_type

Return the ContentType associated with this update.

If the update has no Builds, this evaluates to None.

Returns:The content type of this update or None.
Return type:ContentType or None
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
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
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
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.util.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.

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:basestring
get_cvestring()[source]

Return a space-delimited string of CVE ids for this update.

Returns:A space-separated list of CVE ids.
Return type:basestring
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.
Return type:list
get_tags()[source]

Return all koji tags for all builds on this update.

Returns:basestrings 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:The response from Greenwave for this update.
Return type:dict
Raises:BodhiException – When the greenwave_api_url is undefined in configuration.
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='\xe2\x80\xa6')[source]

Return a title for the update based on the Builds it is associated with.

Parameters:
  • delim (basestring) – The delimeter 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 (basestring) – If a limit is set, use this string after the limit is reached. Defaults to ‘…’.
Returns:

A title for this update.

Return type:

basestring

get_url()[source]

Return the relative URL to this update.

Returns:A URL.
Return type:basestring
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
greenwave_subject_json

Form and return the proper Greenwave API subject field for this Update as JSON.

Returns:
A JSON list of objects that are appropriate to be passed to the Greenwave
API subject field for a decision about this Update.
Return type:basestring
karma

Calculate and return the karma for the Update.

Returns:The Update’s current karma.
Return type:int
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.
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
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
met_testing_requirements

Return True if the update has already been found to meet requirements in the past.

Return whether or not this update has already met the testing requirements and 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.

If this release does not have a mandatory testing requirement, then simply return True.

Returns:See description above for what the bool might mean.
Return type:bool
modify_bugs()[source]

Comment on and close this update’s bugs as necessary.

This typically gets called by the Masher at the end.

classmethod new(request, data)[source]

Create a new update.

Parameters:
  • request (pyramid.util.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

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 mash 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.

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:basestring
remove_tag(tag, koji=None)[source]

Remove the given koji tag from all builds in this update.

Parameters:
  • tag (basestring) – 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.

Return type:

list or None

requested_tag

Return the tag the update has requested.

Returns:The Koji tag that corresponds to the update’s current request.
Return type:basestring
Raises:RuntimeError – If a Koji tag is unable to be determined.
requirements_json

Return a JSON representation of this update’s requirements.

Returns:A JSON representation of this update’s requirements.
Return type:basestring
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.
send_update_notice()[source]

Send e-mail notices about this update.

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 basestring) – The desired request. May be expressed as an UpdateRequest instance, or as a string describing the desired request.
  • username (basestring) – 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.
side_tag_locked

Return the lock state of the side tag.

Returns:True if sidetag is locked, False otherwise.
Return type:bool
signed

Return whether the update is considered signed or not.

This will return True if all Builds associated with this update are signed, or if the associated Release does not have a pending_signing_tag defined. Otherwise, it will return False.

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.
test_cases

Return a list of all TestCase names associated with all packages in this update.

Returns:
A list of basestrings naming the TestCases associated with
this update.
Return type:list
test_gating_passed

Returns a boolean representing if this update has passed the test gating.

Returns:
Returns True if the Update’s test_gating_status property is None, ignored,
or passed. Otherwise it returns False.
Return type:bool
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)[source]

Untag all of the Builds in this update.

Parameters:db (sqlalchemy.orm.session.Session) – A database session.
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 basestrings 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_cves(cves, session)[source]

Create any new CVES, and remove any missing ones.

This method cannot possibly work:
https://github.com/fedora-infra/bodhi/issues/1998#issuecomment-344332011
Parameters:
  • cves (list) – A list of basestrings of CVE identifiers.
  • session (sqlalchemy.orm.session.Session) – A database session.
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.util.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.

waive_test_results(username, comment=None, tests=None)[source]

Attempt to waive test results for this update.

Parameters:
  • username (basestring) – The name of the user who is waiving the test results.
  • comment (basestring) – A comment from the user describing their decision.
  • tests (list of basestring) – A list of testcases to be waived. Defaults to None If left as None, all unsatisfied_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.
class bodhi.server.models.UpdateRequest[source]

Bases: bodhi.server.models.DeclEnum

An enum used to specify an update requesting to change states.

testing

EnumSymbol – The update is requested to change to testing.

batched

EnumSymbol – The update is requested to be pushed to stable during the next batch push.

obsolete

EnumSymbol – The update has been obsoleted by another update.

unpush

EnumSymbol – The update no longer needs to be released.

revoke

EnumSymbol – The unpushed update will no longer be mashed in any repository.

stable

EnumSymbol – The update is ready to be pushed to the stable repository.

class bodhi.server.models.UpdateSeverity[source]

Bases: bodhi.server.models.DeclEnum

An enum used to specify the severity of the update.

unspecified

EnumSymbol – The packager has not specified a severity.

urgent

EnumSymbol – The update is urgent, and will skip the batched state automatically.

high

EnumSymbol – The update is high severity.

medium

EnumSymbol – The update is medium severity.

low

EnumSymbol – The update is low severity.

class bodhi.server.models.UpdateStatus[source]

Bases: bodhi.server.models.DeclEnum

An enum used to describe the current state of an update.

pending

EnumSymbol – The update is not in any repository.

testing

EnumSymbol – The update is in the testing repository.

stable

EnumSymbol – The update is in the stable repository.

unpushed

EnumSymbol – The update had been in a testing repository, but has been removed.

obsolete

EnumSymbol – The update has been obsoleted by another update.

processing

EnumSymbol – Unused.

side_tag_active

EnumSymbol – The update’s side tag is currently active.

side_tag_expired

EnumSymbol – The update’s side tag has expired.

class bodhi.server.models.UpdateSuggestion[source]

Bases: bodhi.server.models.DeclEnum

An enum used to tell the user whether they need to reboot or logout after applying an update.

unspecified

EnumSymbol – No action is needed.

reboot

EnumSymbol – The user should reboot after applying the update.

logout

EnumSymbol – The user should logout after applying the update.

class bodhi.server.models.UpdateType[source]

Bases: bodhi.server.models.DeclEnum

An enum used to classify the type of the update.

bugfix

EnumSymbol – The update fixes bugs only.

security

EnumSymbol – The update addresses security issues.

newpackage

EnumSymbol – The update introduces new packages to the release.

enhancement

EnumSymbol – The update introduces new features.

class bodhi.server.models.User(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

A Bodhi user.

name

unicode – The username.

email

unicode – An e-mail address for the user.

show_popups

bool – If True, the web interface will display fedmsg popups to the user. Defaults to True.

comments

sqlalchemy.orm.dynamic.AppenderQuery – An iterable of Comments the user has written.

updates

sqlalchemy.orm.dynamic.AppenderQuery – An iterable of Updates the user has created.

groups

sqlalchemy.orm.collections.InstrumentedList – An iterable of Groups the user is a member of.

__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)[source]

Return a URL for the User’s avatar, or None if request is falsey.

Parameters:request (pyramid.util.Request) – The current web request.
Returns:A URL for the User’s avatar, or None if request is falsey.
Return type:basestring or None
openid(request)[source]

Return an openid identity URL.

Parameters:request (pyramid.util.Request) – The current web request.
Returns:The openid identity URL for the User object.
Return type:basestring