Merge "Move _from_db_object() into base class"

changes/83/283983/3
Jenkins 7 years ago committed by Gerrit Code Review
commit 33b4bf8542
  1. 15
      ironic/objects/base.py
  2. 14
      ironic/objects/chassis.py
  3. 9
      ironic/objects/conductor.py
  4. 8
      ironic/objects/node.py
  5. 9
      ironic/objects/port.py
  6. 9
      ironic/objects/portgroup.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):

@ -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.

@ -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.

@ -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.

@ -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."""

@ -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."""

Loading…
Cancel
Save