1 # -*- coding: utf-8 -*-
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
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 from osm_common
.dataclasses
.temporal_dataclasses
import (
21 from osm_common
.temporal_constants
import (
27 WORKFLOW_NS_INSTANTIATE
,
29 from osm_common
.wftemporal
import WFTemporal
34 "created": WORKFLOW_VIM_CREATE
,
35 "edited": WORKFLOW_VIM_UPDATE
,
36 "delete": WORKFLOW_VIM_DELETE
,
39 def start_vim_workflow(self
, action
: str, content
: dict) -> None:
40 vim_uuid
= content
["_id"]
41 # Derive the operation id (although for a create it will always be 0)
42 op_id
= content
["op_id"].split(":")[1]
44 workflow
= NbiTemporal
.workflow_mappings
[action
]
46 if workflow
is not None:
47 workflow_data
= VimOperationInput(vim_uuid
, op_id
)
50 WFTemporal(logger_name
="nbi.vim_workflow").start_workflow(
51 task_queue
=LCM_TASK_QUEUE
,
52 workflow_name
=workflow
,
53 workflow_data
=workflow_data
,
58 lcm_workflow_mappings
= {
59 "instantiate": WORKFLOW_NS_INSTANTIATE
,
60 "terminate": WORKFLOW_NSLCM_NO_OP
,
61 "vca_status_refresh": WORKFLOW_NSLCM_NO_OP
,
62 "action": WORKFLOW_NSLCM_NO_OP
,
63 "update": WORKFLOW_NSLCM_NO_OP
,
64 "scale": WORKFLOW_NSLCM_NO_OP
,
65 "heal": WORKFLOW_NSLCM_NO_OP
,
66 "migrate": WORKFLOW_NSLCM_NO_OP
,
67 "verticalscale": WORKFLOW_NSLCM_NO_OP
,
68 "deleted": WORKFLOW_NSLCM_NO_OP
,
69 "vnf_terminated": WORKFLOW_NSLCM_NO_OP
,
70 "policy_updated": WORKFLOW_NSLCM_NO_OP
,
71 "terminated": WORKFLOW_NSLCM_NO_OP
,
72 "instantiated": WORKFLOW_NSLCM_NO_OP
,
73 "scaled": WORKFLOW_NSLCM_NO_OP
,
74 "healed": WORKFLOW_NSLCM_NO_OP
,
75 "actioned": WORKFLOW_NSLCM_NO_OP
,
76 "updated": WORKFLOW_NSLCM_NO_OP
,
77 "migrated": WORKFLOW_NSLCM_NO_OP
,
78 "verticalscaled": WORKFLOW_NSLCM_NO_OP
,
81 def start_ns_workflow(self
, nslcmop
: dict) -> None:
83 WFTemporal(logger_name
="nbi.lcm_workflow").start_workflow(
84 task_queue
=LCM_TASK_QUEUE
,
85 workflow_name
=NbiTemporal
.lcm_workflow_mappings
[
86 nslcmop
["lcmOperationType"]
88 workflow_data
=NsLcmOperationInput(nslcmop
=nslcmop
),