X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=o2ims%2Fservice%2Fauditor%2Focloud_handler.py;h=388013fbdb3c5ea73dd27bffd53ff991bfcae75d;hb=e0e63509e5d7bf6195b8d7f40b44c75dce7e4306;hp=c0d8eaf700b10e4b1cc667eb4b3a6f8568a78a80;hpb=44f01a560347914798d8f913696d0e495ee076f8;p=pti%2Fo2.git diff --git a/o2ims/service/auditor/ocloud_handler.py b/o2ims/service/auditor/ocloud_handler.py index c0d8eaf..388013f 100644 --- a/o2ims/service/auditor/ocloud_handler.py +++ b/o2ims/service/auditor/ocloud_handler.py @@ -14,17 +14,20 @@ # pylint: disable=unused-argument from __future__ import annotations +# from typing import Callable -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 o2common.config import config, conf +# from o2common.service.messagebus import MessageBus 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 import events, commands from o2ims.domain.ocloud import Ocloud -from o2common.config import config +from o2ims.domain.stx_object import StxGenericModel +from o2ims.domain.resource_type import InvalidOcloudState, MismatchedModel +from o2ims.domain.subscription_obj import NotificationEventEnum # if TYPE_CHECKING: # from . import unit_of_work @@ -78,14 +81,19 @@ def is_outdated(ocloud: Ocloud, stxobj: StxGenericModel): def create_by(stxobj: StxGenericModel) -> Ocloud: - imsendpoint = config.get_api_url() + config.get_o2ims_api_base() - globalcloudId = stxobj.id # to be updated + imsendpoint = config.get_api_url() + globalcloudId = conf.DEFAULT.ocloud_global_id description = "An ocloud" ocloud = Ocloud(stxobj.id, stxobj.name, imsendpoint, globalcloudId, description, 1) ocloud.createtime = stxobj.createtime ocloud.updatetime = stxobj.updatetime ocloud.hash = stxobj.hash + ocloud.events.append(events.OcloudChanged( + id=stxobj.id, + notificationEventType=NotificationEventEnum.CREATE, + updatetime=stxobj.updatetime + )) return ocloud @@ -99,4 +107,8 @@ def update_by(ocloud: Ocloud, stxobj: StxGenericModel) -> None: # ocloud.content = stxobj.content ocloud.hash = stxobj.hash ocloud.version_number = ocloud.version_number + 1 - ocloud.events = [] + ocloud.events.append(events.OcloudChanged( + id=stxobj.id, + notificationEventType=NotificationEventEnum.MODIFY, + updatetime=stxobj.updatetime + ))