Use IronicObject._from_db_object_list method
This cleans up the code so that wherever an object needs to convert a list of database entities to a list of the objects, IronicObject._from_db_object_list() is used. Individual object's _from_db_object_list() methods are removed. Change-Id: Ic9d16b30da0067606804ad6b5997af4bc864ad93
This commit is contained in:
parent
d69a3b6c58
commit
349a4dd323
@ -111,8 +111,7 @@ class Chassis(base.IronicObject, object_base.VersionedObjectDictCompat):
|
|||||||
marker=marker,
|
marker=marker,
|
||||||
sort_key=sort_key,
|
sort_key=sort_key,
|
||||||
sort_dir=sort_dir)
|
sort_dir=sort_dir)
|
||||||
return [Chassis._from_db_object(cls(context), obj)
|
return cls._from_db_object_list(context, db_chassis)
|
||||||
for obj in db_chassis]
|
|
||||||
|
|
||||||
# NOTE(xek): We don't want to enable RPC on this call just yet. Remotable
|
# 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.
|
# methods can be used in the future to replace current explicit RPC calls.
|
||||||
|
@ -251,7 +251,7 @@ class Node(base.IronicObject, object_base.VersionedObjectDictCompat):
|
|||||||
db_nodes = cls.dbapi.get_node_list(filters=filters, limit=limit,
|
db_nodes = cls.dbapi.get_node_list(filters=filters, limit=limit,
|
||||||
marker=marker, sort_key=sort_key,
|
marker=marker, sort_key=sort_key,
|
||||||
sort_dir=sort_dir)
|
sort_dir=sort_dir)
|
||||||
return [Node._from_db_object(cls(context), obj) for obj in db_nodes]
|
return cls._from_db_object_list(context, db_nodes)
|
||||||
|
|
||||||
# NOTE(xek): We don't want to enable RPC on this call just yet. Remotable
|
# 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.
|
# methods can be used in the future to replace current explicit RPC calls.
|
||||||
|
@ -52,11 +52,6 @@ class Port(base.IronicObject, object_base.VersionedObjectDictCompat):
|
|||||||
'internal_info': object_fields.FlexibleDictField(nullable=True),
|
'internal_info': object_fields.FlexibleDictField(nullable=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _from_db_object_list(db_objects, cls, context):
|
|
||||||
"""Converts a list of database entities to a list of formal objects."""
|
|
||||||
return [Port._from_db_object(cls(context), obj) for obj in db_objects]
|
|
||||||
|
|
||||||
# NOTE(xek): We don't want to enable RPC on this call just yet. Remotable
|
# 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.
|
# methods can be used in the future to replace current explicit RPC calls.
|
||||||
# Implications of calling new remote procedures should be thought through.
|
# Implications of calling new remote procedures should be thought through.
|
||||||
@ -157,7 +152,7 @@ class Port(base.IronicObject, object_base.VersionedObjectDictCompat):
|
|||||||
marker=marker,
|
marker=marker,
|
||||||
sort_key=sort_key,
|
sort_key=sort_key,
|
||||||
sort_dir=sort_dir)
|
sort_dir=sort_dir)
|
||||||
return Port._from_db_object_list(db_ports, cls, context)
|
return cls._from_db_object_list(context, db_ports)
|
||||||
|
|
||||||
# NOTE(xek): We don't want to enable RPC on this call just yet. Remotable
|
# 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.
|
# methods can be used in the future to replace current explicit RPC calls.
|
||||||
@ -181,7 +176,7 @@ class Port(base.IronicObject, object_base.VersionedObjectDictCompat):
|
|||||||
marker=marker,
|
marker=marker,
|
||||||
sort_key=sort_key,
|
sort_key=sort_key,
|
||||||
sort_dir=sort_dir)
|
sort_dir=sort_dir)
|
||||||
return Port._from_db_object_list(db_ports, cls, context)
|
return cls._from_db_object_list(context, db_ports)
|
||||||
|
|
||||||
# NOTE(xek): We don't want to enable RPC on this call just yet. Remotable
|
# 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.
|
# methods can be used in the future to replace current explicit RPC calls.
|
||||||
@ -206,7 +201,7 @@ class Port(base.IronicObject, object_base.VersionedObjectDictCompat):
|
|||||||
marker=marker,
|
marker=marker,
|
||||||
sort_key=sort_key,
|
sort_key=sort_key,
|
||||||
sort_dir=sort_dir)
|
sort_dir=sort_dir)
|
||||||
return Port._from_db_object_list(db_ports, cls, context)
|
return cls._from_db_object_list(context, db_ports)
|
||||||
|
|
||||||
# NOTE(xek): We don't want to enable RPC on this call just yet. Remotable
|
# 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.
|
# methods can be used in the future to replace current explicit RPC calls.
|
||||||
|
@ -45,12 +45,6 @@ class Portgroup(base.IronicObject, object_base.VersionedObjectDictCompat):
|
|||||||
'standalone_ports_supported': object_fields.BooleanField(),
|
'standalone_ports_supported': object_fields.BooleanField(),
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _from_db_object_list(db_objects, cls, context):
|
|
||||||
"""Converts a list of database entities to a list of formal objects."""
|
|
||||||
return [Portgroup._from_db_object(cls(context), obj) for obj in
|
|
||||||
db_objects]
|
|
||||||
|
|
||||||
# NOTE(xek): We don't want to enable RPC on this call just yet. Remotable
|
# 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.
|
# methods can be used in the future to replace current explicit RPC calls.
|
||||||
# Implications of calling new remote procedures should be thought through.
|
# Implications of calling new remote procedures should be thought through.
|
||||||
@ -170,7 +164,7 @@ class Portgroup(base.IronicObject, object_base.VersionedObjectDictCompat):
|
|||||||
marker=marker,
|
marker=marker,
|
||||||
sort_key=sort_key,
|
sort_key=sort_key,
|
||||||
sort_dir=sort_dir)
|
sort_dir=sort_dir)
|
||||||
return Portgroup._from_db_object_list(db_portgroups, cls, context)
|
return cls._from_db_object_list(context, db_portgroups)
|
||||||
|
|
||||||
# NOTE(xek): We don't want to enable RPC on this call just yet. Remotable
|
# 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.
|
# methods can be used in the future to replace current explicit RPC calls.
|
||||||
@ -196,7 +190,7 @@ class Portgroup(base.IronicObject, object_base.VersionedObjectDictCompat):
|
|||||||
marker=marker,
|
marker=marker,
|
||||||
sort_key=sort_key,
|
sort_key=sort_key,
|
||||||
sort_dir=sort_dir)
|
sort_dir=sort_dir)
|
||||||
return Portgroup._from_db_object_list(db_portgroups, cls, context)
|
return cls._from_db_object_list(context, db_portgroups)
|
||||||
|
|
||||||
# NOTE(xek): We don't want to enable RPC on this call just yet. Remotable
|
# 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.
|
# methods can be used in the future to replace current explicit RPC calls.
|
||||||
|
@ -39,12 +39,6 @@ class VolumeConnector(base.IronicObject,
|
|||||||
'extra': object_fields.FlexibleDictField(nullable=True),
|
'extra': object_fields.FlexibleDictField(nullable=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _from_db_object_list(db_objects, cls, context):
|
|
||||||
"""Convert a list of database entities to a list of formal objects."""
|
|
||||||
return [VolumeConnector._from_db_object(cls(context), obj)
|
|
||||||
for obj in db_objects]
|
|
||||||
|
|
||||||
# NOTE(xek): We don't want to enable RPC on this call just yet. Remotable
|
# 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.
|
# methods can be used in the future to replace current explicit RPC calls.
|
||||||
# Implications of calling new remote procedures should be thought through.
|
# Implications of calling new remote procedures should be thought through.
|
||||||
@ -126,8 +120,7 @@ class VolumeConnector(base.IronicObject,
|
|||||||
marker=marker,
|
marker=marker,
|
||||||
sort_key=sort_key,
|
sort_key=sort_key,
|
||||||
sort_dir=sort_dir)
|
sort_dir=sort_dir)
|
||||||
return VolumeConnector._from_db_object_list(db_connectors,
|
return cls._from_db_object_list(context, db_connectors)
|
||||||
cls, context)
|
|
||||||
|
|
||||||
# NOTE(xek): We don't want to enable RPC on this call just yet. Remotable
|
# 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.
|
# methods can be used in the future to replace current explicit RPC calls.
|
||||||
@ -153,8 +146,7 @@ class VolumeConnector(base.IronicObject,
|
|||||||
marker=marker,
|
marker=marker,
|
||||||
sort_key=sort_key,
|
sort_key=sort_key,
|
||||||
sort_dir=sort_dir)
|
sort_dir=sort_dir)
|
||||||
return VolumeConnector._from_db_object_list(db_connectors,
|
return cls._from_db_object_list(context, db_connectors)
|
||||||
cls, context)
|
|
||||||
|
|
||||||
# NOTE(xek): We don't want to enable RPC on this call just yet. Remotable
|
# 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.
|
# methods can be used in the future to replace current explicit RPC calls.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user