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 (
28 from osm_common
.wftemporal
import WFTemporal
33 "created": WORKFLOW_VIM_CREATE
,
34 "edited": WORKFLOW_VIM_UPDATE
,
35 "delete": WORKFLOW_VIM_DELETE
,
38 def start_vim_workflow(self
, action
: str, content
: dict) -> None:
39 vim_uuid
= content
["_id"]
40 # Derive the operation id (although for a create it will always be 0)
41 op_id
= content
["op_id"].split(":")[1]
43 workflow
= NbiTemporal
.workflow_mappings
[action
]
45 if workflow
is not None:
46 workflow_data
= VimOperationInput(vim_uuid
, op_id
)
49 WFTemporal(logger_name
="nbi.vim_workflow").start_workflow(
50 task_queue
=LCM_TASK_QUEUE
,
51 workflow_name
=workflow
,
52 workflow_data
=workflow_data
,
57 lcm_workflow_mappings
= {
58 "instantiate": WORKFLOW_NSLCM_NO_OP
,
59 "terminate": WORKFLOW_NSLCM_NO_OP
,
60 "vca_status_refresh": WORKFLOW_NSLCM_NO_OP
,
61 "action": WORKFLOW_NSLCM_NO_OP
,
62 "update": WORKFLOW_NSLCM_NO_OP
,
63 "scale": WORKFLOW_NSLCM_NO_OP
,
64 "heal": WORKFLOW_NSLCM_NO_OP
,
65 "migrate": WORKFLOW_NSLCM_NO_OP
,
66 "verticalscale": WORKFLOW_NSLCM_NO_OP
,
67 "deleted": WORKFLOW_NSLCM_NO_OP
,
68 "vnf_terminated": WORKFLOW_NSLCM_NO_OP
,
69 "policy_updated": WORKFLOW_NSLCM_NO_OP
,
70 "terminated": WORKFLOW_NSLCM_NO_OP
,
71 "instantiated": WORKFLOW_NSLCM_NO_OP
,
72 "scaled": WORKFLOW_NSLCM_NO_OP
,
73 "healed": WORKFLOW_NSLCM_NO_OP
,
74 "actioned": WORKFLOW_NSLCM_NO_OP
,
75 "updated": WORKFLOW_NSLCM_NO_OP
,
76 "migrated": WORKFLOW_NSLCM_NO_OP
,
77 "verticalscaled": WORKFLOW_NSLCM_NO_OP
,
80 def start_ns_workflow(self
, nslcmop
: dict) -> None:
82 WFTemporal(logger_name
="nbi.lcm_workflow").start_workflow(
83 task_queue
=LCM_TASK_QUEUE
,
84 workflow_name
=NbiTemporal
.lcm_workflow_mappings
[
85 nslcmop
["lcmOperationType"]
87 workflow_data
=NsLcmOperationInput(nslcmop
=nslcmop
),