diff --git a/ironic/objects/base.py b/ironic/objects/base.py index 25d4add641c..61af72b10e8 100644 --- a/ironic/objects/base.py +++ b/ironic/objects/base.py @@ -74,6 +74,21 @@ class IronicObject(object_base.VersionedObject): self[field] != loaded_object[field]): self[field] = loaded_object[field] + @staticmethod + def _from_db_object(obj, db_object): + """Converts a database entity to a formal object. + + :param obj: An object of the class. + :param db_object: A DB model of the object + :return: The object of the class with the database entity added + """ + + for field in obj.fields: + obj[field] = db_object[field] + + obj.obj_reset_changes() + return obj + class IronicObjectIndirectionAPI(object_base.VersionedObjectIndirectionAPI): def __init__(self): diff --git a/ironic/objects/chassis.py b/ironic/objects/chassis.py index 8983ca0a7e2..4ade052fe90 100644 --- a/ironic/objects/chassis.py +++ b/ironic/objects/chassis.py @@ -41,20 +41,6 @@ class Chassis(base.IronicObject, object_base.VersionedObjectDictCompat): 'description': object_fields.StringField(nullable=True), } - @staticmethod - def _from_db_object(chassis, db_chassis): - """Converts a database entity to a formal :class:`Chassis` object. - - :param chassis: An object of :class:`Chassis`. - :param db_chassis: A DB model of a chassis. - :return: a :class:`Chassis` object. - """ - for field in chassis.fields: - chassis[field] = db_chassis[field] - - chassis.obj_reset_changes() - return chassis - # NOTE(xek): We don't want to enable RPC on this call just yet. Remotable # methods can be used in the future to replace current explicit RPC calls. # Implications of calling new remote procedures should be thought through. diff --git a/ironic/objects/conductor.py b/ironic/objects/conductor.py index e0028e93a2f..56ce7cdb75e 100644 --- a/ironic/objects/conductor.py +++ b/ironic/objects/conductor.py @@ -33,15 +33,6 @@ class Conductor(base.IronicObject, object_base.VersionedObjectDictCompat): 'hostname': object_fields.StringField(), } - @staticmethod - def _from_db_object(conductor, db_obj): - """Converts a database entity to a formal object.""" - for field in conductor.fields: - conductor[field] = db_obj[field] - - conductor.obj_reset_changes() - return conductor - # NOTE(xek): We don't want to enable RPC on this call just yet. Remotable # methods can be used in the future to replace current explicit RPC calls. # Implications of calling new remote procedures should be thought through. diff --git a/ironic/objects/node.py b/ironic/objects/node.py index 11536ac00a6..2e5049b7a1e 100644 --- a/ironic/objects/node.py +++ b/ironic/objects/node.py @@ -103,14 +103,6 @@ class Node(base.IronicObject, object_base.VersionedObjectDictCompat): 'extra': object_fields.FlexibleDictField(nullable=True), } - @staticmethod - def _from_db_object(node, db_node): - """Converts a database entity to a formal object.""" - for field in node.fields: - node[field] = db_node[field] - node.obj_reset_changes() - return node - def _validate_property_values(self, properties): """Check if the input of local_gb, cpus and memory_mb are valid. diff --git a/ironic/objects/port.py b/ironic/objects/port.py index a93365b9a56..7a0ede80887 100644 --- a/ironic/objects/port.py +++ b/ironic/objects/port.py @@ -50,15 +50,6 @@ class Port(base.IronicObject, object_base.VersionedObjectDictCompat): 'pxe_enabled': object_fields.BooleanField() } - @staticmethod - def _from_db_object(port, db_port): - """Converts a database entity to a formal object.""" - for field in port.fields: - port[field] = db_port[field] - - port.obj_reset_changes() - return port - @staticmethod def _from_db_object_list(db_objects, cls, context): """Converts a list of database entities to a list of formal objects.""" diff --git a/ironic/objects/portgroup.py b/ironic/objects/portgroup.py index b3d83a53145..388ae297352 100644 --- a/ironic/objects/portgroup.py +++ b/ironic/objects/portgroup.py @@ -40,15 +40,6 @@ class Portgroup(base.IronicObject, object_base.VersionedObjectDictCompat): 'extra': object_fields.FlexibleDictField(nullable=True), } - @staticmethod - def _from_db_object(portgroup, db_portgroup): - """Converts a database entity to a formal object.""" - for field in portgroup.fields: - portgroup[field] = db_portgroup[field] - - portgroup.obj_reset_changes() - return portgroup - @staticmethod def _from_db_object_list(db_objects, cls, context): """Converts a list of database entities to a list of formal objects."""