1 # Copyright (C) 2021 Wind River Systems, Inc.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # pylint: disable=unused-argument
16 from __future__ import annotations
18 from o2dms.service import nfdeployment_handler
19 # from dataclasses import asdict
20 from typing import Dict, Callable, Type
22 from o2ims.domain import commands, events
24 from o2dms.domain import commands as o2dms_cmmands
25 from o2dms.domain import events as o2dms_events
26 from o2ims.service.auditor import ocloud_handler, dms_handler, \
27 resourcepool_handler, pserver_handler, pserver_cpu_handler, \
28 pserver_mem_handler, pserver_port_handler, pserver_if_handler,\
29 pserver_eth_handler, alarm_handler
30 from o2ims.service.command import notify_handler, registration_handler,\
32 from o2ims.service.event import ocloud_event, resource_event, \
33 resource_pool_event, alarm_event
36 # from . import unit_of_work
39 class InvalidResourceType(Exception):
44 o2dms_events.NfDeploymentStateChanged: [
45 nfdeployment_handler.publish_nfdeployment_state_change
47 # o2dms_events.NfDeploymentCreated: [
48 # nfdeployment_handler.publish_nfdeployment_created],
49 # o2dms_events.NfDeploymentInstalled: [
50 # nfdeployment_handler.publish_nfdeployment_installed],
51 # o2dms_events.NfDeploymentUninstalling: [
52 # nfdeployment_handler.publish_nfdeployment_uninstalling],
53 # o2dms_events.NfDeploymentUninstalled: [
54 # nfdeployment_handler.publish_nfdeployment_uninstalled]
55 events.OcloudChanged: [ocloud_event.notify_ocloud_update],
56 events.ResourceChanged: [resource_event.notify_resource_change],
57 events.ResourcePoolChanged: [resource_pool_event.\
58 notify_resourcepool_change],
59 events.AlarmEventChanged: [alarm_event.\
60 notify_alarm_event_change],
61 } # type: Dict[Type[events.Event], Callable]
65 commands.UpdateOCloud: ocloud_handler.update_ocloud,
66 commands.UpdateDms: dms_handler.update_dms,
67 commands.UpdateAlarm: alarm_handler.update_alarm,
68 commands.UpdateResourcePool: resourcepool_handler.update_resourcepool,
69 commands.UpdatePserver: pserver_handler.update_pserver,
70 commands.UpdatePserverCpu: pserver_cpu_handler.update_pserver_cpu,
71 commands.UpdatePserverMem: pserver_mem_handler.update_pserver_mem,
72 commands.UpdatePserverIf: pserver_if_handler.update_pserver_if,
73 commands.UpdatePserverIfPort: pserver_port_handler.update_pserver_port,
74 commands.UpdatePserverEth: pserver_eth_handler.update_pserver_eth,
75 o2dms_cmmands.HandleNfDeploymentStateChanged:
76 nfdeployment_handler.handle_nfdeployment_statechanged,
77 o2dms_cmmands.InstallNfDeployment:
78 nfdeployment_handler.install_nfdeployment,
79 o2dms_cmmands.UninstallNfDeployment:
80 nfdeployment_handler.uninstall_nfdeployment,
81 o2dms_cmmands.DeleteNfDeployment:
82 nfdeployment_handler.delete_nfdeployment,
83 commands.PubMessage2SMO: notify_handler.notify_change_to_smo,
84 commands.PubAlarm2SMO: notify_alarm_handler.notify_alarm_to_smo,
85 commands.Register2SMO: registration_handler.registry_to_smo,
86 } # type: Dict[Type[commands.Command], Callable]