From e9b16df036bbe092477834af538ef9cc2f993729 Mon Sep 17 00:00:00 2001 From: chenke Date: Wed, 4 Mar 2020 21:05:00 +0800 Subject: [PATCH] Optimize deployble object module Because the deployable object and the attribute object are independent, we should completely remove the attribute setting at the object level. When the attribute is removed, deployable can use the method of the base class like other objects (device, attach_handle). Therefore, this patch also removes the _from_db_object() method. Change-Id: Ieebc8242b68cbe1dfd4a3bc9081de2bb5f4075a7 Story: 2007369 Task: 38931 --- cyborg/objects/deployable.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/cyborg/objects/deployable.py b/cyborg/objects/deployable.py index 45dea58f..477ccbbd 100644 --- a/cyborg/objects/deployable.py +++ b/cyborg/objects/deployable.py @@ -65,7 +65,6 @@ class Deployable(base.CyborgObject, object_base.VersionedObjectDictCompat): db_dep = self.dbapi.deployable_create(context, values) self._from_db_object(self, db_dep) self.obj_reset_changes() - del self.attributes_list[:] @classmethod def get(cls, context, uuid): @@ -145,20 +144,6 @@ class Deployable(base.CyborgObject, object_base.VersionedObjectDictCompat): return obj_dpl_list - @staticmethod - def _from_db_object(obj, db_obj): - """Converts a deployable to a formal object. - - :param obj: An object of the class. - :param db_obj: 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_obj[field] - obj.attributes_list = [] - - return obj - @classmethod def get_list_by_device_id(cls, context, device_id): dep_filter = {'device_id': device_id}