f3b3d6db1cd52dbb9d39eff72d764a3975c03e90
[pti/o2.git] / o2app / service / handlers.py
1 # Copyright (C) 2021 Wind River Systems, Inc.
2 #
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
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
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.
14
15 # pylint: disable=unused-argument
16 from __future__ import annotations
17 # from dataclasses import asdict
18 from typing import List, Dict, Callable, Type
19 # TYPE_CHECKING
20 from o2ims.domain import commands, events
21 from o2ims.service.auditor import ocloud_handler, dms_handler, \
22     resourcepool_handler, pserver_handler, pserver_cpu_handler, \
23     pserver_mem_handler, pserver_port_handler, pserver_if_handler
24
25 # if TYPE_CHECKING:
26 #     from . import unit_of_work
27
28
29 class InvalidResourceType(Exception):
30     pass
31
32
33 EVENT_HANDLERS = {
34 }  # type: Dict[Type[events.Event], List[Callable]]
35
36
37 COMMAND_HANDLERS = {
38     commands.UpdateOCloud: ocloud_handler.update_ocloud,
39     commands.UpdateDms: dms_handler.update_dms,
40     commands.UpdateResourcePool: resourcepool_handler.update_resourcepool,
41     commands.UpdatePserver: pserver_handler.update_pserver,
42     commands.UpdatePserverCpu: pserver_cpu_handler.update_pserver_cpu,
43     commands.UpdatePserverMem: pserver_mem_handler.update_pserver_mem,
44     commands.UpdatePserverIf: pserver_if_handler.update_pserver_if,
45     commands.UpdatePserverPort: pserver_port_handler.update_pserver_port,
46 }  # type: Dict[Type[commands.Command], Callable]