The ironic.objects.base Module

Ironic common internal object model

class ironic.objects.base.IronicObject(context=None, **kwargs)[source]

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.

as_dict()[source]
convert_to_version(target_version)[source]

Convert this object to the target version.

_convert_to_version() does the actual work.

Parameters:target_version – the desired version of the object
do_version_changes_for_db()[source]

Change the object to the version needed for the database.

If needed, this changes the object (modifies object fields) to be in the correct version for saving to the database.

The version used to save the object in the DB is determined as follows:

  • If the object is pinned, we save the object in the pinned version. Since it is pinned, we must not save in a newer version, in case a rolling upgrade is happening and some services are still using the older version of ironic, with no knowledge of this newer version.
  • If the object isn’t pinned, we save the object in the latest version.

Because the object may be converted to a different object version, this method must only be called just before saving the object to the DB.

Returns:a dictionary of changed fields and their new values (could be an empty dictionary). These are the fields/values of the object that would be saved to the DB.
get_target_version()[source]

Returns the target version for this object.

This is the version in which the object should be manipulated, e.g. sent over the wire via RPC or saved in the DB.

Returns:if pinned, returns the version of this object corresponding to the pin. Otherwise, returns the version of the object.
Raises:ovo_exception.IncompatibleObjectVersion
obj_refresh(loaded_object)[source]

Applies updates for objects that inherit from base.IronicObject.

Checks for updated attributes in an object. Updates are applied from the loaded object column by column in comparison with the current object.

class ironic.objects.base.IronicObjectRegistry[source]

Bases: oslo_versionedobjects.base.VersionedObjectRegistry

registration_hook(cls, index)[source]
class ironic.objects.base.IronicObjectSerializer[source]

Bases: oslo_versionedobjects.base.VersionedObjectSerializer

OBJ_BASE_CLASS

alias of IronicObject

serialize_entity(context, entity)[source]

Serialize the entity.

This serializes the entity so that it can be sent over e.g. RPC. A serialized entity for an IronicObject is a dictionary with keys: ‘ironic_object.namespace’, ‘ironic_object.data’, ‘ironic_object.name’, ‘ironic_object.version’, and ‘ironic_object.changes’.

For IronicObjects, if the service (ironic-api or ironic-conductor) is pinned, we want the object to be in the target/pinned version, which is not necessarily the latest version of the object. (Internally, the services deal with the latest versions of objects so we know that these objects are always in the latest versions.)

Parameters:
  • context – security context
  • entity – the entity to be serialized; may be an IronicObject
Returns:

the serialized entity

Raises:

ovo_exception.IncompatibleObjectVersion (via .get_target_version())