CI: Add non voting tox verify GHA workflow call
[pti/o2.git] / o2ims / service / auditor / ocloud_handler.py
index 97cca3e..04b4800 100644 (file)
 
 # pylint: disable=unused-argument
 from __future__ import annotations
-from typing import Callable
+from typing import Callable
 
 # from dataclasses import asdict
 # from typing import List, Dict, Callable, Type
 # TYPE_CHECKING
 
-from o2common.config import config
+from o2common.config import config, conf
 # from o2common.service.messagebus import MessageBus
 from o2common.service.unit_of_work import AbstractUnitOfWork
 from o2ims.domain import events, commands
@@ -41,8 +41,7 @@ class InvalidResourceType(Exception):
 
 def update_ocloud(
     cmd: commands.UpdateOCloud,
-    uow: AbstractUnitOfWork,
-    publish: Callable
+    uow: AbstractUnitOfWork
 ):
     stxobj = cmd.data
     with uow:
@@ -82,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
 
@@ -101,6 +105,7 @@ def update_by(ocloud: Ocloud, stxobj: StxGenericModel) -> None:
     ocloud.createtime = stxobj.createtime
     ocloud.updatetime = stxobj.updatetime
     # ocloud.content = stxobj.content
+
     ocloud.hash = stxobj.hash
     ocloud.version_number = ocloud.version_number + 1
     ocloud.events.append(events.OcloudChanged(