diff options
author | Ruby Loo <ruby.loo@intel.com> | 2016-12-06 17:20:26 +0000 |
---|---|---|
committer | Ruby Loo <ruby.loo@intel.com> | 2016-12-06 17:20:26 +0000 |
commit | 349a4dd3235f76548afdf92ce69b6ff6aacc74bd (patch) | |
tree | a059aba0f3d9a1caacb01bca0d020bba7f775240 /ironic | |
parent | d69a3b6c58f9f9d10f1639f76d593141b2afae4a (diff) | |
download | ironic-349a4dd3235f76548afdf92ce69b6ff6aacc74bd.tar.gz |
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
Diffstat (limited to 'ironic')
-rw-r--r-- | ironic/objects/chassis.py | 3 | ||||
-rw-r--r-- | ironic/objects/node.py | 2 | ||||
-rw-r--r-- | ironic/objects/port.py | 11 | ||||
-rw-r--r-- | ironic/objects/portgroup.py | 10 | ||||
-rw-r--r-- | ironic/objects/volume_connector.py | 12 |
5 files changed, 9 insertions, 29 deletions
diff --git a/ironic/objects/chassis.py b/ironic/objects/chassis.py index 4ade052fe..102dc5a96 100644 --- a/ironic/objects/chassis.py +++ b/ironic/objects/chassis.py @@ -111,8 +111,7 @@ class Chassis(base.IronicObject, object_base.VersionedObjectDictCompat): marker=marker, sort_key=sort_key, sort_dir=sort_dir) - return [Chassis._from_db_object(cls(context), obj) - for obj in db_chassis] + return cls._from_db_object_list(context, db_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. diff --git a/ironic/objects/node.py b/ironic/objects/node.py index 1fcef73e8..bd63a1770 100644 --- a/ironic/objects/node.py +++ b/ironic/objects/node.py @@ -251,7 +251,7 @@ class Node(base.IronicObject, object_base.VersionedObjectDictCompat): db_nodes = cls.dbapi.get_node_list(filters=filters, limit=limit, marker=marker, sort_key=sort_key, 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 # methods can be used in the future to replace current explicit RPC calls. diff --git a/ironic/objects/port.py b/ironic/objects/port.py index e8b318659..98a83cd27 100644 --- a/ironic/objects/port.py +++ b/ironic/objects/port.py @@ -52,11 +52,6 @@ class Port(base.IronicObject, object_base.VersionedObjectDictCompat): '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 # methods can be used in the future to replace current explicit RPC calls. # Implications of calling new remote procedures should be thought through. @@ -157,7 +152,7 @@ class Port(base.IronicObject, object_base.VersionedObjectDictCompat): marker=marker, sort_key=sort_key, 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 # 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, sort_key=sort_key, 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 # 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, sort_key=sort_key, 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 # methods can be used in the future to replace current explicit RPC calls. diff --git a/ironic/objects/portgroup.py b/ironic/objects/portgroup.py index 021a7620a..75917f1be 100644 --- a/ironic/objects/portgroup.py +++ b/ironic/objects/portgroup.py @@ -45,12 +45,6 @@ class Portgroup(base.IronicObject, object_base.VersionedObjectDictCompat): '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 # methods can be used in the future to replace current explicit RPC calls. # Implications of calling new remote procedures should be thought through. @@ -170,7 +164,7 @@ class Portgroup(base.IronicObject, object_base.VersionedObjectDictCompat): marker=marker, sort_key=sort_key, 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 # 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, sort_key=sort_key, 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 # methods can be used in the future to replace current explicit RPC calls. diff --git a/ironic/objects/volume_connector.py b/ironic/objects/volume_connector.py index e91c5e8cc..86459e4b2 100644 --- a/ironic/objects/volume_connector.py +++ b/ironic/objects/volume_connector.py @@ -39,12 +39,6 @@ class VolumeConnector(base.IronicObject, '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 # methods can be used in the future to replace current explicit RPC calls. # Implications of calling new remote procedures should be thought through. @@ -126,8 +120,7 @@ class VolumeConnector(base.IronicObject, marker=marker, sort_key=sort_key, sort_dir=sort_dir) - return VolumeConnector._from_db_object_list(db_connectors, - cls, context) + return cls._from_db_object_list(context, db_connectors) # 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. @@ -153,8 +146,7 @@ class VolumeConnector(base.IronicObject, marker=marker, sort_key=sort_key, sort_dir=sort_dir) - return VolumeConnector._from_db_object_list(db_connectors, - cls, context) + return cls._from_db_object_list(context, db_connectors) # 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. |