The nova.objects.base Module

Nova common internal object model

class NovaObject(context=None, **kwargs)

Bases: oslo_versionedobjects.base.VersionedObject

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.

OBJ_PROJECT_NAMESPACE = 'nova'
OBJ_SERIAL_NAMESPACE = 'nova_object'
obj_alternate_context(*args, **kwds)
obj_as_admin(*args, **kwds)

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()
obj_reset_changes(fields=None, recursive=False)

Reset the list of fields that have been changed.

Note

  • This is NOT “revert to previous values”
  • Specifying fields on recursive resets will only be honored at the top level. Everything below the top will reset all.
Parameters:
  • fields – List of fields to reset, or “all” if None.
  • recursive – Call obj_reset_changes(recursive=True) on any sub-objects within the list of fields being reset.
static should_migrate_data()

A check that can be used to inhibit online migration behavior

This is usually used to check if all services that will be accessing the db directly are ready for the new format.

class NovaObjectDictCompat

Bases: oslo_versionedobjects.base.VersionedObjectDictCompat

keys()
class NovaObjectRegistry

Bases: oslo_versionedobjects.base.VersionedObjectRegistry

registration_hook(cls, index)
class NovaObjectSerializer

Bases: oslo_messaging.serializer.NoOpSerializer

A NovaObject-aware Serializer.

This implements the Oslo Serializer interface and provides the ability to serialize and deserialize NovaObject entities. Any service that needs to accept or return NovaObjects as arguments or result values should pass this to its RPCClient and RPCServer objects.

conductor
deserialize_entity(context, entity)
serialize_entity(context, entity)
class NovaPersistentObject

Bases: object

Mixin class for Persistent objects.

This adds the fields that we use in common for most persistent objects.

fields = {'deleted_at': DateTime(default=<class 'oslo_versionedobjects.fields.UnspecifiedDefault'>,nullable=True), 'deleted': Boolean(default=False,nullable=False), 'updated_at': DateTime(default=<class 'oslo_versionedobjects.fields.UnspecifiedDefault'>,nullable=True), 'created_at': DateTime(default=<class 'oslo_versionedobjects.fields.UnspecifiedDefault'>,nullable=True)}
class NovaTimestampObject

Bases: object

Mixin class for db backed objects with timestamp fields.

Sqlalchemy models that inherit from the oslo_db TimestampMixin will include these fields and the corresponding objects will benefit from this mixin.

fields = {'updated_at': DateTime(default=<class 'oslo_versionedobjects.fields.UnspecifiedDefault'>,nullable=True), 'created_at': DateTime(default=<class 'oslo_versionedobjects.fields.UnspecifiedDefault'>,nullable=True)}
class ObjectListBase(*args, **kwargs)

Bases: oslo_versionedobjects.base.ObjectListBase

get_attrname(name)

Return the mangled name of the attribute’s underlying storage.

obj_equal_prims(obj_1, obj_2, ignore=None)

Compare two primitives for equivalence ignoring some keys.

This operation tests the primitives of two objects for equivalence. Object primitives may contain a list identifying fields that have been changed - this is ignored in the comparison. The ignore parameter lists any other keys to be ignored.

:param:obj1: The first object in the comparison :param:obj2: The second object in the comparison :param:ignore: A list of fields to ignore :returns: True if the primitives are equal ignoring changes and specified fields, otherwise False.

obj_make_dict_of_lists(context, list_cls, obj_list, item_key)

Construct a dictionary of object lists, keyed by item_key.

:param:context: Request context :param:list_cls: The ObjectListBase class :param:obj_list: The list of objects to place in the dictionary :param:item_key: The object attribute name to use as a dictionary key

obj_make_list(context, list_obj, item_cls, db_list, **extra_args)

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 context :param:list_obj: An ObjectListBase object :param:item_cls: The NovaObject 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

obj_to_primitive(obj)

Recursively turn an object into a python primitive.

A NovaObject becomes a dict, and anything that implements ObjectListBase becomes a list.

serialize_args(fn)

Decorator that will do the arguments serialization before remoting.

Previous topic

The nova.objects.bandwidth_usage Module

Next topic

The nova.objects.block_device Module

Project Source

This Page