1 #######################################################################################
2 # Copyright ETSI Contributors and Others.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #######################################################################################
18 from dataclasses
import dataclass
20 from osm_common
.dbbase
import DbBase
21 from osm_common
.temporal
.activities
.base
import BaseActivity
22 from osm_common
.temporal
.states
import VnfInstantiationState
, VnfState
25 class ChangeVnfState(BaseActivity
):
26 """Updates the VNF State in VNFR.
32 DbException: If DB access/update fails, the collection or DB record ID does not exist.
35 This activity should complete relatively quickly (less than a
36 second). However, it would be reasonable to wait up to 10
39 This activity will not report a heartbeat due to its
42 It is not necessary to implement a back-off strategy for this
43 activity, the operation is idempotent.
50 Input dataclass for changing VNF State.
55 The UUID of the VNF which is stored in the OSM vnfrs
59 A representation of the VNF state (STOPPED or STARTED).
65 def __init__(self
, db
: DbBase
):
69 async def __call__(self
, activity_input
: Input
) -> None:
70 raise NotImplementedError()
73 class ChangeVnfInstantiationState(BaseActivity
):
74 """Updates the VNF Instantiation State in VNFR.
80 DbException: If DB access or update fails, the collection or DB record ID does not exist.
83 This activity should complete relatively quickly (less than a
84 second). However, it would be reasonable to wait up to 10
87 This activity will not report a heartbeat due to its
90 It is not necessary to implement a back-off strategy for this
91 activity, the operation is idempotent.
98 Input dataclass for changing VNF Instantiation State.
103 The UUID of the VNF which is stored in the OSM vnfrs
106 state : VnfInstantiationState
107 A representation of the VNF instantiation state (NOT_INSTANTIATED or INSTANTIATED).
112 state
: VnfInstantiationState
114 def __init__(self
, db
: DbBase
):
118 async def __call__(self
, activity_input
: Input
) -> None:
119 raise NotImplementedError()
122 class GetVnfRecord(BaseActivity
):
123 """Gets the VNF record and VNF descriptor from Database.
129 DbException: If DB read operations fail, the collection or DB record ID does not exist.
132 This activity should complete relatively quickly (less than 10
135 This activity will not report a heartbeat due to its
136 short-running nature.
138 This is an idempotent activity.
145 Input dataclass for get vnf details activity.
150 The UUID of the VNF which is stored in the OSM vnfrs
159 Output dataclass for get vnf details activity.
169 def __init__(self
, db
: DbBase
):
173 async def __call__(self
, activity_input
: Input
) -> Output
:
174 raise NotImplementedError()
177 class GetVnfDescriptor(BaseActivity
):
178 """Gets the VNF record and VNF descriptor from Database.
184 DbException: If DB read operations fail, the collection or DB record ID does not exist.
187 This activity should complete relatively quickly (less than 10
190 This activity will not report a heartbeat due to its
191 short-running nature.
193 This is an idempotent activity.
200 Input dataclass for get vnf descriptor activity.
205 The UUID of the VNF descriptor which is stored in the OSM vnfds
214 Output dataclass for get vnf details activity.
219 VNF descriptor retrieved from Database.
224 def __init__(self
, db
: DbBase
):
228 async def __call__(self
, activity_input
: Input
) -> Output
:
229 raise NotImplementedError()
232 class SendNotificationForVnf(BaseActivity
):
233 """Perform Notification operations."""
238 Input dataclass for sending notifications for change in VNF Instantiation State.
243 The UUID of the VNF which is stored in the OSM vnfrs
246 state : VnfInstantiationState
247 A representation of the VNF instantiation state (NOT_INSTANTIATED or INSTANTIATED).
254 async def __call__(self
, activity_input
: Input
):
255 raise NotImplementedError()
258 class GetTaskQueue(BaseActivity
):
259 """Finds the appropriate task queue according to VIM type of VNF.
262 DB read: vim_accounts, vnfrs
265 DbException: If DB read operations fail, the collection or DB record ID does not exist.
268 This activity should complete relatively quickly (less than a
269 second). However, it would be reasonable to wait up to 10
272 This activity will not report a heartbeat due to its
273 short-running nature.
275 It is not necessary to implement a back-off strategy for this
276 activity, the operation is idempotent.
283 Input dataclass for get task queue activity.
288 The UUID of the VNF which is stored in the OSM vnfrs
298 Output dataclass for get task queue activity.
303 Name of the queue which is used to Deploy VNF.
308 def __init__(self
, db
: DbBase
):
312 async def __call__(self
, activity_input
: Input
) -> Output
:
313 raise NotImplementedError()
316 class GetVimCloud(BaseActivity
):
317 """Finds the cloud by checking the VIM account of VNF.
320 DB Read: vnfrs, vim_accounts
323 DbException: If DB read operations fail, the collection or DB record ID does not exist.
326 This activity should complete relatively quickly (less than a
327 second). However, it would be reasonable to wait up to 10
330 This activity will not report a heartbeat due to its
331 short-running nature.
333 It is not necessary to implement a back-off strategy for this
334 activity, the operation is idempotent.
341 Input dataclass for get vim cloud activity.
346 The UUID of the VNF which is stored in the OSM vnfrs
356 Output dataclass for get vim cloud activity.
361 Type of the cloud which is used to Deploy VNF.
366 def __init__(self
, db
: DbBase
):
370 async def __call__(self
, activity_input
: Input
) -> Output
:
371 raise NotImplementedError()
374 class SetVnfModel(BaseActivity
):
375 """Updates the model name of VNF in VNFR.
381 DbException: If DB access or update fails, the collection or DB record ID does not exist.
384 This activity should complete relatively quickly (less than a
385 second). However, it would be reasonable to wait up to 10
388 This activity will not report a heartbeat due to its
389 short-running nature.
391 It is not necessary to implement a back-off strategy for this
392 activity, the operation is idempotent.
399 Input dataclass for workflow that instantiates a VNF.
404 The UUID of the VNF which is stored in the OSM vnfrs
414 def __init__(self
, db
: DbBase
):
418 async def __call__(self
, activity_input
: Input
) -> None:
419 raise NotImplementedError()
422 class GetModelNames(BaseActivity
):
423 """Gets the models of VNFs associated with the NS.
429 DbException: If DB read operations fail
432 This activity should complete relatively quickly (less than a second).
434 This activity will not report a heartbeat due to its
435 short-running nature.
437 This is an idempotent activity.
446 The UUID of the NS from which we are looking for the model names.
456 model_names: set[str]
457 The set of model names associated with the NS.
460 model_names
: set[str]
462 def __init__(self
, db
: DbBase
):
466 async def __call__(self
, activity_input
: Input
) -> Output
:
467 raise NotImplementedError()
470 class DeleteVnfRecord(BaseActivity
):
471 """Delete a VNF record from DB.
477 DbException: If DB access fails, the collection does not exist.
480 This activity should complete relatively quickly (less than a
481 second). However, it would be reasonable to wait up to 10
484 This activity will not report a heartbeat due to its
485 short-running nature.
487 This operation is idempotent.
494 Input dataclass for activity that deletes a VNF record.
499 The UUID of the VNF to be deleted from the vnfrs
505 def __init__(self
, db
: DbBase
):
509 async def __call__(self
, activity_input
: Input
) -> None:
510 raise NotImplementedError()