ironic.objects.base
Module¶Ironic common internal object model
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.
convert_to_version
(target_version, remove_unavailable_fields=True)[source]¶Convert this object to the target version.
Convert the object to the target version. The target version may be the same, older, or newer than the version of the object. This is used for DB interactions as well as for serialization/deserialization.
The remove_unavailable_fields flag is used to distinguish these two cases:
_convert_to_version() does the actual work.
Parameters: |
|
---|
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:
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.
supports_version
(version)[source]¶Return whether this object supports a particular version.
Check the requested version against the object’s target version. The target version may not be the latest version during an upgrade, when object versions are pinned.
Parameters: | version – A tuple representing the version to check |
---|---|
Returns: | Whether the version is supported |
Raises: | ovo_exception.IncompatibleObjectVersion |
ironic.objects.base.
IronicObjectRegistry
[source]¶Bases: oslo_versionedobjects.base.VersionedObjectRegistry
ironic.objects.base.
IronicObjectSerializer
(is_server=False)[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’.
We assume that the client (ironic-API) is always talking to a server (ironic-conductor) that is running the same or a newer release than the client. The client doesn’t need to downgrade any IronicObjects when sending them over RPC. The server, on the other hand, will need to do so if the server is pinned and the target version of an IronicObject is older than the latest version of that Object.
(Internally, the services deal with the latest versions of objects so we know that these objects are always in the latest versions.)
Parameters: |
|
---|---|
Returns: | the serialized entity |
Raises: | ovo_exception.IncompatibleObjectVersion (via .get_target_version()) |
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.