Cinder common internal object model
Bases: oslo_versionedobjects.base.ComparableVersionedObject
Bases: oslo_versionedobjects.base.VersionedObject
Bases: object
Class for conditional value selection for conditional_update.
Bases: cinder.db.api.Condition
Class for negated condition values for conditional_update.
By default NULL values will be treated like Python treats None instead of how SQL treats it.
So for example when values are (1, 2) it will evaluate to True when we have value 3 or NULL, instead of only with 3 like SQL does.
Returns a dict of changed fields with tz unaware datetimes.
Any timezone aware datetime field will be converted to UTC timezone and returned as timezone unaware datetime.
This will allow us to pass these fields directly to a db update method as they can’t have timezone information.
Compare-and-swap update.
A conditional object update that, unlike normal update, will SAVE the contents of the update to the DB.
Update will only occur in the DB and the object if conditions are met.
If no expected_values are passed in we will default to make sure that all fields have not been changed in the DB. Since we cannot know the original value in the DB for dirty fields in the object those will be excluded.
Method accepts additional filters, which are basically anything that can be passed to a sqlalchemy query’s filter method, for example: [~sql.exists().where(models.Volume.id == models.Snapshot.volume_id)]
We can select values based on conditions using Case objects in the ‘values’ argument. For example: has_snapshot_filter = sql.exists().where(
models.Snapshot.volume_id == models.Volume.id)
{‘status’: ‘available’}))
And we can use DB fields using model class attribute for example to store previous status in the corresponding field even though we don’t know which value is in the db from those we allowed: volume.conditional_update({‘status’: ‘deleting’,
‘previous_status’: volume.model.status},{‘status’: (‘available’, ‘error’)})
Parameters: |
|
---|
Bases: oslo_versionedobjects.base.VersionedObjectDictCompat
Mix-in to provide dictionary key access compat.
If an object needs to support attribute access using dictionary items instead of object attributes, inherit from this class. This should only be used as a temporary measure until all callers are converted to use modern attribute access.
NOTE(berrange) This class will eventually be deleted.
For backwards-compatibility with dict-based objects.
NOTE(danms): May be removed in the future.
Bases: oslo_versionedobjects.base.VersionedObjectRegistry
Bases: oslo_versionedobjects.base.VersionedObjectSerializer
alias of CinderObject
Bases: dict
Helper class that maintains objects version history.
Current state of object versions is aggregated in a single version number that explicitily identifies a set of object versions. That way a service is able to report what objects it supports using a single string and all the newer services will know exactly what that mean for a single object.
Bases: object
Mixin class for Persistent objects.
This adds the fields that we use in common for all persistent objects.
Context manager to make an object call as an admin.
This temporarily modifies the context embedded in an object to be elevated() and restores it after the call completes. Example usage:
- with obj.obj_as_admin():
- obj.save()
Bases: oslo_versionedobjects.base.ObjectListBase