Add registration the SMO's CRUD interface in IMS
[pti/o2.git] / o2app / service / handlers.py
index b551ca6..833ef4e 100644 (file)
@@ -14,6 +14,8 @@
 
 # pylint: disable=unused-argument
 from __future__ import annotations
+
+from o2dms.service import nfdeployment_handler
 # from dataclasses import asdict
 from typing import List, Dict, Callable, Type
 # TYPE_CHECKING
@@ -23,9 +25,11 @@ from o2dms.domain import commands as o2dms_cmmands
 from o2dms.domain import events as o2dms_events
 from o2ims.service.auditor import ocloud_handler, dms_handler, \
     resourcepool_handler, pserver_handler, pserver_cpu_handler, \
-    pserver_mem_handler, pserver_port_handler, pserver_if_handler
-from o2dms.service.nfdeployment_handler import publish_nfdeployment_created
-from o2dms.service.nfdeployment_handler import install_nfdeployment
+    pserver_mem_handler, pserver_port_handler, pserver_if_handler,\
+    pserver_eth_handler
+from o2ims.service.command import notify_handler
+from o2ims.service.event import ocloud_event, \
+    resource_event, resource_pool_event
 
 # if TYPE_CHECKING:
 #     from . import unit_of_work
@@ -36,8 +40,22 @@ class InvalidResourceType(Exception):
 
 
 EVENT_HANDLERS = {
-    o2dms_events.NfDeploymentCreated: [publish_nfdeployment_created]
-}
+    o2dms_events.NfDeploymentStateChanged: [
+        nfdeployment_handler.publish_nfdeployment_state_change
+    ],
+    # o2dms_events.NfDeploymentCreated: [
+    #     nfdeployment_handler.publish_nfdeployment_created],
+    # o2dms_events.NfDeploymentInstalled: [
+    #     nfdeployment_handler.publish_nfdeployment_installed],
+    # o2dms_events.NfDeploymentUninstalling: [
+    #     nfdeployment_handler.publish_nfdeployment_uninstalling],
+    # o2dms_events.NfDeploymentUninstalled: [
+    #     nfdeployment_handler.publish_nfdeployment_uninstalled]
+    events.OcloudChanged: [ocloud_event.notify_ocloud_update],
+    events.ResourceChanged: [resource_event.notify_resource_change],
+    events.ResourcePoolChanged: [resource_pool_event.\
+                                 notify_resourcepool_change],
+}  # type: Dict[Type[events.Event], Callable]
 
 
 COMMAND_HANDLERS = {
@@ -48,7 +66,15 @@ COMMAND_HANDLERS = {
     commands.UpdatePserverCpu: pserver_cpu_handler.update_pserver_cpu,
     commands.UpdatePserverMem: pserver_mem_handler.update_pserver_mem,
     commands.UpdatePserverIf: pserver_if_handler.update_pserver_if,
-    commands.UpdatePserverPort: pserver_port_handler.update_pserver_port,
-    o2dms_cmmands.InstallNfDeployment: install_nfdeployment
-
+    commands.UpdatePserverIfPort: pserver_port_handler.update_pserver_port,
+    commands.UpdatePserverEth: pserver_eth_handler.update_pserver_eth,
+    o2dms_cmmands.HandleNfDeploymentStateChanged:
+    nfdeployment_handler.handle_nfdeployment_statechanged,
+    o2dms_cmmands.InstallNfDeployment:
+    nfdeployment_handler.install_nfdeployment,
+    o2dms_cmmands.UninstallNfDeployment:
+    nfdeployment_handler.uninstall_nfdeployment,
+    o2dms_cmmands.DeleteNfDeployment:
+    nfdeployment_handler.delete_nfdeployment,
+    commands.PubMessage2SMO: notify_handler.notify_change_to_smo,
 }  # type: Dict[Type[commands.Command], Callable]