X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=o2ims%2Fservice%2Fauditor%2Fresourcepool_handler.py;h=366b77fe68e5f6e9768eeaa680d638ae4e9c095c;hb=8d6c2f135ee103b9a94ea6c29986a608069b6982;hp=88cf182114818814762961956dc59b3b3272da46;hpb=f73c8e3b01b8f5b7438ba544870e06d8f30cdea0;p=pti%2Fo2.git diff --git a/o2ims/service/auditor/resourcepool_handler.py b/o2ims/service/auditor/resourcepool_handler.py index 88cf182..366b77f 100644 --- a/o2ims/service/auditor/resourcepool_handler.py +++ b/o2ims/service/auditor/resourcepool_handler.py @@ -20,11 +20,12 @@ from o2ims.domain.stx_object import StxGenericModel # from dataclasses import asdict # from typing import List, Dict, Callable, Type # TYPE_CHECKING -from o2ims.domain import commands +from o2ims.domain import commands, events from o2common.service.unit_of_work import AbstractUnitOfWork # from o2ims.domain.resource_type import InvalidOcloudState from o2ims.domain.resource_type import MismatchedModel from o2ims.domain.ocloud import ResourcePool +from o2ims.domain.subscription_obj import NotificationEventEnum # if TYPE_CHECKING: # from . import unit_of_work @@ -74,15 +75,20 @@ def is_outdated(resourcepool: ResourcePool, stxobj: StxGenericModel): def create_by(stxobj: StxGenericModel, parentid: str) -> ResourcePool: content = json.loads(stxobj.content) - globalcloudId = stxobj.id # to be updated + globalLocationId = '' # to be updated description = "A Resource Pool" + location = content['location'] if content['location'] is not None else '' resourcepool = ResourcePool(stxobj.id, stxobj.name, - content['location'], - parentid, globalcloudId, description) + location, + parentid, globalLocationId, description) resourcepool.createtime = stxobj.createtime resourcepool.updatetime = stxobj.updatetime resourcepool.hash = stxobj.hash - + resourcepool.events.append(events.ResourcePoolChanged( + id=stxobj.id, + notificationEventType=NotificationEventEnum.CREATE, + updatetime=stxobj.updatetime + )) return resourcepool @@ -92,10 +98,15 @@ def update_by(target: ResourcePool, stxobj: StxGenericModel, raise MismatchedModel("Mismatched Id") content = json.loads(stxobj.content) target.name = stxobj.name - target.location = content['location'] + target.location = content['location'] if content['location'] is not None \ + else '' target.createtime = stxobj.createtime target.updatetime = stxobj.updatetime target.hash = stxobj.hash target.oCloudId = parentid target.version_number = target.version_number + 1 - target.events = [] + target.events.append(events.ResourcePoolChanged( + id=stxobj.id, + notificationEventType=NotificationEventEnum.MODIFY, + updatetime=stxobj.updatetime + ))