diff options
author | John L. Villalovos <john.l.villalovos@intel.com> | 2016-02-05 15:55:53 -0800 |
---|---|---|
committer | John L. Villalovos <john.l.villalovos@intel.com> | 2016-02-24 06:33:31 -0800 |
commit | bbee55df15004a08314217dc1b63bcc80f728283 (patch) | |
tree | 07cb7bd79587eea8d53c54282b909675dff355f8 /ironic/objects/base.py | |
parent | 86198097ec0bb4c19ff325ee1477c40f578103ca (diff) | |
download | ironic-bbee55df15004a08314217dc1b63bcc80f728283.tar.gz |
Move _from_db_object() into base class
Had five copies of the def _from_db_object() function in various
classes. Move this function into their common base class.
Change-Id: I543386a708d80f7c89455e556e2abc6d532661b0
Diffstat (limited to 'ironic/objects/base.py')
-rw-r--r-- | ironic/objects/base.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ironic/objects/base.py b/ironic/objects/base.py index 25d4add64..61af72b10 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): |