Cinder common internal object model
Bases: object
Base class and object factory.
This forms the base of all objects that can be remoted or instantiated via RPC. Simply defining a class that inherits from this base class will make it remotely instantiatable. Objects should implement the necessary “get” classmethod routines as well as “save” object methods as appropriate.
Test object to see if attrname is present.
Returns True if the named attribute has a value set, or False if not. Raises AttributeError if attrname is not a valid attribute for this object.
Returns a class from the registry based on a name and version.
Create a copy.
Object field-by-field hydration.
Returns a dict of changed fields and their new values.
Load an additional attribute from the real object.
Make an object representation compatible with a target version.
This is responsible for taking the primitive representation of an object and making it suitable for the given target_version. This may mean converting the format of object attributes, removing attributes that have been added since the target version, etc. In general:
:param:primitive: The result of self.obj_to_primitive() :param:target_version: The version string requested by the recipient of the object :raises: cinder.exception.UnsupportedObjectError if conversion is not possible for some reason
Return a canonical name for this object.
The canonical name will be used over the wire for remote hydration.
Reset the list of fields that have been changed.
Note that this is NOT “revert to previous values”
Simple base-case dehydration.
This calls to_primitive() for each item in fields.
Returns a set of fields that have been modified.
Save the changed fields back to the store.
This is optional for subclasses, but is presented here in the base class for consistency among those that do.
Bases: object
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.
For backwards-compatibility with dict-based objects.
NOTE(danms): May be removed in the future.
For backwards-compatibility with dict-base objects.
NOTE(danms): May be removed in the future.
Bases: type
Metaclass that allows tracking of object classes.
Bases: oslo_messaging.serializer.NoOpSerializer
A CinderObject-aware Serializer.
This implements the Oslo Serializer interface and provides the ability to serialize and deserialize CinderObject entities. Any service that needs to accept or return CinderObjects as arguments or result values should pass this to its RPCClient and RPCServer objects.
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: object
Bases: object
Mixin class for lists of objects.
This mixin class can be added as a base class for an object that is implementing a list of objects. It adds a single field of ‘objects’, which is the list store, and behaves like a list itself. It supports serialization of the list of objects automatically.
List count of value occurrences.
List index of value.
Return the mangled name of the attribute’s underlying storage.
Construct an object list from a list of primitives.
This calls item_cls._from_db_object() on each item of db_list, and adds the resulting object to list_obj.
:param:context: Request contextr :param:list_obj: An ObjectListBase object :param:item_cls: The CinderObject class of the objects within the list :param:db_list: The list of primitives to convert to objects :param:extra_args: Extra arguments to pass to _from_db_object() :returns: list_obj
Recursively turn an object into a python primitive.
A CinderObject becomes a dict, and anything that implements ObjectListBase becomes a list.
Decorator for remotable object methods.
Decorator for remotable classmethods.
Decorator that will do the arguments serialization before remoting.