X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=o2common%2Fdomain%2Fbase.py;h=698843c73627ed3292e1898b2c51c9f3c1854351;hb=8ce4f0cb5acc8af28a7ed0ff101bb2b2804cf73e;hp=e56672b89a13afcb4fd3c359fb275c5ce13a43a4;hpb=defe8209b3628593c186487857fe02586d7e1503;p=pti%2Fo2.git diff --git a/o2common/domain/base.py b/o2common/domain/base.py index e56672b..698843c 100644 --- a/o2common/domain/base.py +++ b/o2common/domain/base.py @@ -20,6 +20,20 @@ from sqlalchemy.exc import NoInspectionAvailable from .events import Event +class InfrastructureInventoryObject: + ObjectState = {} + + def __init__(self) -> None: + # self.ObjectState = {} + pass + + def get_fields_as_dict(self, fields): + for field in fields: + if hasattr(self, field): + self.ObjectState[field] = getattr(self, field) + return self.ObjectState + + class AgRoot: events = [] @@ -39,13 +53,13 @@ class Serializer(object): def serialize(self): try: - # d = {c: getattr(self, c) for c in inspect(self).attrs.keys()} + d = {c: getattr(self, c) for c in inspect(self).attrs.keys()} # if 'createtime' in d: # d['createtime'] = d['createtime'].isoformat() # if 'updatetime' in d: # d['updatetime'] = d['updatetime'].isoformat() - # return d - return {c: getattr(self, c) for c in inspect(self).attrs.keys()} + return d + # return {c: getattr(self, c) for c in inspect(self).attrs.keys()} except NoInspectionAvailable: return self.__dict__