OSMENG-987: Implement PrepareVnfWorkflow
[osm/common.git] / osm_common / dataclasses / temporal_dataclasses.py
1 #######################################################################################
2 # Copyright ETSI Contributors and Others.
3 #
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
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
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
13 # implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #######################################################################################
17
18 from dataclasses import dataclass
19 from enum import auto, IntEnum
20
21
22 #######################################################################################
23 # Defining States
24 class VimState(IntEnum):
25 PROCESSING = auto()
26 ENABLED = auto()
27 ERROR = auto()
28
29
30 class VimOperationState(IntEnum):
31 COMPLETED = auto()
32 FAILED = auto()
33
34
35 class NsState(IntEnum):
36 PROCESSING = auto()
37 INSTANTIATED = auto()
38 ERROR = auto()
39
40
41 class VnfLcmOperationState(IntEnum):
42 PROCESSING = auto()
43 COMPLETED = auto()
44 FAILED = auto()
45
46
47 class VnfInstantiationState(IntEnum):
48 NOT_INSTANTIATED = auto()
49 INSTANTIATED = auto()
50
51
52 class VnfState(IntEnum):
53 STOPPED = auto()
54 STARTED = auto()
55
56
57 class LcmOperationState(IntEnum):
58 PROCESSING = auto()
59 COMPLETED = auto()
60 FAILED = auto()
61
62
63 #######################################################################################
64 # Workflow Dataclasses
65
66
67 @dataclass
68 class VimOperationInput:
69 """
70 Input dataclass for workflows that perform operations
71 (create, update, delete) on VIMs.
72
73 Attributes:
74 -----------
75 vim_uuid : str
76 The UUID of the VIM account as stored in the OSM vim
77 collection in Mongo
78
79 op_id: str
80 The operation (task) id for this workflow. This is used
81 by the workflow at the end to update the status of the
82 operation in Mongo vim collection.
83 """
84
85 vim_uuid: str
86 op_id: str
87
88
89 @dataclass
90 class NsLcmOperationInput:
91 """
92 Input dataclass for workflows that run as LCM operations.
93
94 Attributes:
95 -----------
96
97 nslcmop: dict
98 A dictionary representing the nslcmop record from the
99 database.
100 """
101
102 nslcmop: dict
103
104
105 @dataclass
106 class NsInstantiateInput:
107 """
108 Input dataclass for workflow that instantiate NS.
109
110 Attributes:
111 -----------
112 ns_uuid : str
113 The UUID of the NS as stored in the OSM nsr
114 collection in Mongo
115
116 op_id: str
117 The operation (task) id for this workflow. This is used
118 by the workflow at the end to update the status of the
119 operation in Mongo vim collection.
120 """
121
122 ns_uuid: str
123 op_id: str
124
125
126 @dataclass
127 class CharmInfo:
128 """
129 Input dataclass for
130
131 Attributes:
132 -----------
133 app_name : str
134
135 channel: str
136
137 entity_url: str
138 """
139
140 app_name: str
141 channel: str
142 entity_url: str
143
144
145 @dataclass
146 class VduInstantiateInput:
147 """
148 Input dataclass for workflow that instantiates a VDU.
149
150 vim_uuid: str
151
152 model_name: str
153
154 charm_info : CharmInfo
155
156 """
157
158 vim_uuid: str
159 model_name: str
160 charm_info: CharmInfo
161
162
163 @dataclass
164 class VnfInstantiateInput:
165 """
166 Input dataclass for workflow that instantiates a VNF.
167
168 Attributes:
169 -----------
170 vnfr_uuid : str
171 The UUID of the VNF which is stored in the OSM vnfrs
172 collection in Mongo.
173
174 model_name: str
175
176 """
177
178 vnfr_uuid: str
179 model_name: str
180
181
182 #######################################################################################
183 # Activity Dataclasses
184
185
186 @dataclass
187 class UpdateLcmOperationStateInput:
188 """
189 Input dataclass for updating LCM Operations in the Mongo nslcmops
190 collection. The following attributes will be updated automatically
191 - statusEnteredTime
192 - _admin.modified
193
194 Attributes:
195 -----------
196 op_id: str
197 The operation (task) id for this activity. This is the key
198 to the record in nslcmops collection that will be updated.
199
200 op_state : LcmOperationState
201 A representation of the state of the specified operation id,
202 such as PROCESSING, COMPLETED, or FAILED.
203
204 stage: str
205 Human readable checkpoint message, intended only to give the
206 user feedback.
207
208 error_message: str
209 Human readable error message if any failure occurred.
210
211 detailed_status : str
212 Human readable message providing additional details to the
213 operation state, such as the error message explaining why
214 the operation failed.
215 """
216
217 op_id: str
218 op_state: LcmOperationState
219 stage: str
220 error_message: str
221 detailed_status: str
222
223
224 @dataclass
225 class TestVimConnectivityInput:
226 """
227 Input dataclass for the Test Vim Connectivity Ativity
228
229 Attributes:
230 -----------
231 vim_uuid : str
232 The UUID of the VIM account as stored in the OSM vim
233 collection in Mongo
234 """
235
236 vim_uuid: str
237
238
239 @dataclass
240 class UpdateVimStateInput:
241 """
242 Input dataclass for updating VIM state in the DB
243
244 Attributes:
245 -----------
246 vim_uuid : str
247 The UUID of the VIM account as stored in the OSM vim
248 collection in Mongo
249
250 operational_state : VimState
251 A representation of the operational state (ENABLED or ERROR)
252 of the VIM.
253
254 message : str
255 Human readable message providing additional details to the
256 operational state, such as the error message associated
257 with the ERROR operational_state.
258 """
259
260 vim_uuid: str
261 operational_state: VimState
262 message: str
263
264
265 @dataclass
266 class UpdateVimOperationStateInput:
267 """
268 Input dataclass for updating VIM Operations in the Mongo VIM
269 collection.
270
271 Attributes:
272 -----------
273 vim_uuid : str
274 The UUID of the VIM account as stored in the OSM vim
275 collection in Mongo
276
277 op_id: str
278 The operation (task) id for this workflow. This is used
279 to update the status of the operation in Mongo vim collection.
280
281 op_state : VimOperationState
282 A representation of the state of the specified operation id,
283 such as COMPLETED, or FAILED.
284
285 message : str
286 Human readable message providing additional details to the
287 operation state, such as the error message explaining why
288 the operation failed.
289 """
290
291 vim_uuid: str
292 op_id: str
293 op_state: VimOperationState
294 message: str
295
296
297 @dataclass
298 class DeleteVimInput:
299 """
300 Input dataclass for deleting vim record from the database
301
302 Attributes:
303 -----------
304 vim_uuid : str
305 The UUID of the VIM account as stored in the OSM vim
306 collection in Mongo
307
308 """
309
310 vim_uuid: str
311
312
313 @dataclass
314 class DeployNsInput:
315 """
316 Input dataclass for
317
318 Attributes:
319 -----------
320 ns_uuid : str
321 The UUID of the NS as stored in the OSM nsr
322 collection in Mongo
323 """
324
325 ns_uuid: str
326
327
328 @dataclass
329 class UpdateNsStateInput:
330 """
331 Input dataclass for updating NS state in the DB
332
333 Attributes:
334 -----------
335 ns_uuid : str
336 The UUID of the NS as stored in the OSM ns
337 collection in Mongo
338
339 operational_state : NsState
340 A representation of the operational state (ENABLED or ERROR)
341 of the NS.
342
343 message : str
344 Human readable message providing additional details to the
345 operational state, such as the error message associated
346 with the ERROR operational_state.
347 """
348
349 ns_uuid: str
350 state: NsState
351 message: str
352
353
354 @dataclass
355 class ModelInfo:
356 """
357 Contains the information related to a model.
358
359 Attributes:
360 -----------
361 vim_uuid : str
362 The UUID of the VIM as stored in the OSM vim_accounts
363 collection in Mongo.
364
365 model_name : str
366 Name of the Juju model used to deploy charms.
367 """
368
369 vim_uuid: str
370 model_name: str
371
372
373 @dataclass
374 class CheckCharmStatusInput:
375 """
376 Input dataclass for checking on a specific charm's deployment
377 status
378
379 Attributes:
380 -----------
381 vim_uuid : str
382 The UUID of the VIM as stored in the OSM vim_accounts
383 collection in Mongo.
384
385 model_name : str
386 Name of the model to create in Juju.
387
388 application_name : str
389 Name of the application that the state is going to be
390 awaited.
391
392 poll_interval : int (optional)
393 Time, in seconds, to wait between status checks.
394 """
395
396 vim_uuid: str
397 model_name: str
398 application_name: str
399 poll_interval: int = 1
400
401
402 @dataclass
403 class ChangeVnfStateInput:
404 """
405 Input dataclass for changing VNF State.
406
407 Attributes:
408 -----------
409 vnfr_uuid : str
410 The UUID of the VNF which is stored in the OSM vnfrs
411 collection in Mongo.
412
413 state : VnfState
414 A representation of the VNF state (STOPPED or STARTED).
415 """
416
417 vnfr_uuid: str
418 state: VnfState
419
420
421 @dataclass
422 class ChangeVnfInstantiationStateInput:
423 """
424 Input dataclass for changing VNF Instantiation State.
425
426 Attributes:
427 -----------
428 vnfr_uuid : str
429 The UUID of the VNF which is stored in the OSM vnfrs
430 collection in Mongo.
431
432 state : VnfInstantiationState
433 A representation of the VNF instantiation state (NOT_INSTANTIATED or INSTANTIATED).
434
435 """
436
437 vnfr_uuid: str
438 state: VnfInstantiationState
439
440
441 @dataclass
442 class GetTaskQueueInput:
443 """
444 Input dataclass for get task queue activity.
445
446 Attributes:
447 -----------
448 vnfr_uuid : str
449 The UUID of the VNF which is stored in the OSM vnfrs
450 collection in Mongo.
451
452 """
453
454 vnfr_uuid: str
455
456
457 @dataclass
458 class GetTaskQueueOutput:
459 """
460 Output dataclass for get task queue activity.
461
462 Attributes:
463 -----------
464 task_queue : str
465 Name of the queue which is used to Deploy VNF.
466 """
467
468 task_queue: str
469
470
471 @dataclass
472 class GetVnfDetailsInput:
473 """
474 Input dataclass for get vnf details activity.
475
476 Attributes:
477 -----------
478 vnfr_uuid : str
479 The UUID of the VNF which is stored in the OSM vnfrs
480 collection in Mongo.
481 """
482
483 vnfr_uuid: str
484
485
486 @dataclass
487 class GetVnfDetailsOutput:
488 """
489 Output dataclass for get vnf details activity.
490
491 Attributes:
492 -----------
493 vnfr : dict
494 VNF record retrieved from Database.
495
496 vnfd : dict
497 VNF descriptor retrieved from Database.
498 """
499
500 vnfr: dict
501 vnfd: dict