OSMENG-1048 Implement day1 configuration for VDU (improved)
[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 from typing import List
21
22
23 #######################################################################################
24 # Defining States
25 class VimState(IntEnum):
26 PROCESSING = auto()
27 ENABLED = auto()
28 ERROR = auto()
29
30
31 class VimOperationState(IntEnum):
32 COMPLETED = auto()
33 FAILED = auto()
34
35
36 class NsState(IntEnum):
37 PROCESSING = auto()
38 INSTANTIATED = auto()
39 ERROR = auto()
40
41
42 class VnfLcmOperationState(IntEnum):
43 PROCESSING = auto()
44 COMPLETED = auto()
45 FAILED = auto()
46
47
48 class VnfInstantiationState(IntEnum):
49 NOT_INSTANTIATED = auto()
50 INSTANTIATED = auto()
51
52
53 class VnfState(IntEnum):
54 STOPPED = auto()
55 STARTED = auto()
56
57
58 class LcmOperationState(IntEnum):
59 PROCESSING = auto()
60 COMPLETED = auto()
61 FAILED = auto()
62
63
64 #######################################################################################
65 # Workflow Dataclasses
66
67
68 @dataclass
69 class VimOperationInput:
70 """
71 Input dataclass for workflows that perform operations
72 (create, update, delete) on VIMs.
73
74 Attributes:
75 -----------
76 vim_uuid : str
77 The UUID of the VIM account as stored in the OSM vim
78 collection in Mongo
79
80 op_id: str
81 The operation (task) id for this workflow. This is used
82 by the workflow at the end to update the status of the
83 operation in Mongo vim collection.
84 """
85
86 vim_uuid: str
87 op_id: str
88
89
90 @dataclass
91 class NsLcmOperationInput:
92 """
93 Input dataclass for workflows that run as LCM operations.
94
95 Attributes:
96 -----------
97
98 nslcmop: dict
99 A dictionary representing the nslcmop record from the
100 database.
101 """
102
103 nslcmop: dict
104
105
106 @dataclass
107 class CharmInfo:
108 """
109 Input dataclass for
110
111 Attributes:
112 -----------
113 app_name : str
114
115 channel: str
116
117 entity_url: str
118 """
119
120 app_name: str
121 channel: str
122 entity_url: str
123
124
125 @dataclass
126 class GetVimCloudInput:
127 """
128 Input dataclass for get vim cloud activity.
129
130 Attributes:
131 -----------
132 vnfr_uuid : str
133 The UUID of the VNF which is stored in the OSM vnfrs
134 collection in Mongo.
135
136 """
137
138 vnfr_uuid: str
139
140
141 @dataclass
142 class GetVimCloudOutput:
143 """
144 Output dataclass for get vim cloud activity.
145
146 Attributes:
147 -----------
148 cloud : str
149 Type of the cloud which is used to Deploy VNF.
150 """
151
152 cloud: str
153
154
155 @dataclass
156 class VduComputeConstraints:
157 """
158 Input dataclass for VDU constraints
159
160 Attributes:
161 -----------
162 cores : int (Number of virtual CPUs)
163
164 mem: int (GB)
165 """
166
167 cores: int
168 mem: int
169
170
171 @dataclass
172 class VduInstantiateInput:
173 """
174 Input dataclass for workflow that instantiates a VDU.
175
176 vim_uuid: str
177
178 model_name: str
179
180 charm_info : CharmInfo
181
182 constraints: VduComputeConstraints
183
184 cloud: VIM cloud type
185
186 config: Config details of application
187 """
188
189 vim_uuid: str
190 model_name: str
191 charm_info: CharmInfo
192 constraints: VduComputeConstraints
193 cloud: str
194 config: dict
195
196
197 @dataclass
198 class VnfInstantiateInput:
199 """
200 Input dataclass for workflow that instantiates a VNF.
201
202 Attributes:
203 -----------
204 vnfr_uuid : str
205 The UUID of the VNF which is stored in the OSM vnfrs
206 collection in Mongo.
207
208 model_name: str
209
210 instantiation_config: dict
211 The instantiation configuration of the VNF
212
213 """
214
215 vnfr_uuid: str
216 model_name: str
217 instantiation_config: dict
218
219
220 @dataclass
221 class SetVnfModelInput:
222 """
223 Input dataclass for activity that sets the VNF Model.
224
225 Attributes:
226 -----------
227 vnfr_uuid : str
228 The UUID of the VNF which is stored in the OSM vnfrs
229 collection in Mongo.
230
231 model_name: str
232
233 """
234
235 vnfr_uuid: str
236 model_name: str
237
238
239 @dataclass
240 class VnfPrepareInput:
241 """
242 Input dataclass for workflow that prepare a VNF.
243
244 Attributes:
245 -----------
246 vnfr_uuid : str
247 The UUID of the VNF which is stored in the OSM vnfrs
248 collection in Mongo.
249
250 model_name: str
251
252 """
253
254 vnfr_uuid: str
255 model_name: str
256
257
258 @dataclass
259 class GetNsRecordInput:
260 """
261 Input dataclass for getting NS record activity.
262
263 Attributes:
264 -----------
265 nsr_uuid :
266 The UUID of the NS record which is stored in the OSM nsrs
267 collection in Mongo.
268
269 """
270
271 nsr_uuid: str
272
273
274 @dataclass
275 class GetNsRecordOutput:
276 """
277 Output dataclass for getting NS record activity.
278
279 Attributes:
280 -----------
281 nsr : dict
282 NS record retrieved from Database..
283
284 """
285
286 nsr: dict
287
288
289 #######################################################################################
290 # Activity Dataclasses
291
292
293 @dataclass
294 class UpdateLcmOperationStateInput:
295 """
296 Input dataclass for updating LCM Operations in the Mongo nslcmops
297 collection. The following attributes will be updated automatically
298 - statusEnteredTime
299 - _admin.modified
300
301 Attributes:
302 -----------
303 op_id: str
304 The operation (task) id for this activity. This is the key
305 to the record in nslcmops collection that will be updated.
306
307 op_state : LcmOperationState
308 A representation of the state of the specified operation id,
309 such as PROCESSING, COMPLETED, or FAILED.
310
311 stage: str
312 Human readable checkpoint message, intended only to give the
313 user feedback.
314
315 error_message: str
316 Human readable error message if any failure occurred.
317
318 detailed_status : str
319 Human readable message providing additional details to the
320 operation state, such as the error message explaining why
321 the operation failed.
322 """
323
324 op_id: str
325 op_state: LcmOperationState
326 stage: str
327 error_message: str
328 detailed_status: str
329
330
331 @dataclass
332 class TestVimConnectivityInput:
333 """
334 Input dataclass for the Test Vim Connectivity Ativity
335
336 Attributes:
337 -----------
338 vim_uuid : str
339 The UUID of the VIM account as stored in the OSM vim
340 collection in Mongo
341 """
342
343 vim_uuid: str
344
345
346 @dataclass
347 class UpdateVimStateInput:
348 """
349 Input dataclass for updating VIM state in the DB
350
351 Attributes:
352 -----------
353 vim_uuid : str
354 The UUID of the VIM account as stored in the OSM vim
355 collection in Mongo
356
357 operational_state : VimState
358 A representation of the operational state (ENABLED or ERROR)
359 of the VIM.
360
361 message : str
362 Human readable message providing additional details to the
363 operational state, such as the error message associated
364 with the ERROR operational_state.
365 """
366
367 vim_uuid: str
368 operational_state: VimState
369 message: str
370
371
372 @dataclass
373 class UpdateVimOperationStateInput:
374 """
375 Input dataclass for updating VIM Operations in the Mongo VIM
376 collection.
377
378 Attributes:
379 -----------
380 vim_uuid : str
381 The UUID of the VIM account as stored in the OSM vim
382 collection in Mongo
383
384 op_id: str
385 The operation (task) id for this workflow. This is used
386 to update the status of the operation in Mongo vim collection.
387
388 op_state : VimOperationState
389 A representation of the state of the specified operation id,
390 such as COMPLETED, or FAILED.
391
392 message : str
393 Human readable message providing additional details to the
394 operation state, such as the error message explaining why
395 the operation failed.
396 """
397
398 vim_uuid: str
399 op_id: str
400 op_state: VimOperationState
401 message: str
402
403
404 @dataclass
405 class DeleteVimInput:
406 """
407 Input dataclass for deleting vim record from the database
408
409 Attributes:
410 -----------
411 vim_uuid : str
412 The UUID of the VIM account as stored in the OSM vim
413 collection in Mongo
414
415 """
416
417 vim_uuid: str
418
419
420 @dataclass
421 class DeployNsInput:
422 """
423 Input dataclass for
424
425 Attributes:
426 -----------
427 ns_uuid : str
428 The UUID of the NS as stored in the OSM nsr
429 collection in Mongo
430 """
431
432 ns_uuid: str
433
434
435 @dataclass
436 class UpdateNsStateInput:
437 """
438 Input dataclass for updating NS state in the DB
439
440 Attributes:
441 -----------
442 ns_uuid : str
443 The UUID of the NS as stored in the OSM ns
444 collection in Mongo
445
446 operational_state : NsState
447 A representation of the operational state (ENABLED or ERROR)
448 of the NS.
449
450 message : str
451 Human readable message providing additional details to the
452 operational state, such as the error message associated
453 with the ERROR operational_state.
454 """
455
456 ns_uuid: str
457 state: NsState
458 message: str
459
460
461 @dataclass
462 class ModelInfo:
463 """
464 Contains the information related to a model.
465
466 Attributes:
467 -----------
468 vim_uuid : str
469 The UUID of the VIM as stored in the OSM vim_accounts
470 collection in Mongo.
471
472 model_name : str
473 Name of the Juju model used to deploy charms.
474 """
475
476 vim_uuid: str
477 model_name: str
478
479
480 @dataclass
481 class CheckCharmStatusInput:
482 """
483 Input dataclass for checking on a specific charm's deployment
484 status
485
486 Attributes:
487 -----------
488 vim_uuid : str
489 The UUID of the VIM as stored in the OSM vim_accounts
490 collection in Mongo.
491
492 model_name : str
493 Name of the model to create in Juju.
494
495 application_name : str
496 Name of the application that the state is going to be
497 awaited.
498
499 poll_interval : int (optional)
500 Time, in seconds, to wait between status checks.
501 """
502
503 vim_uuid: str
504 model_name: str
505 application_name: str
506 poll_interval: int = 1
507
508
509 @dataclass
510 class ChangeVnfStateInput:
511 """
512 Input dataclass for changing VNF State.
513
514 Attributes:
515 -----------
516 vnfr_uuid : str
517 The UUID of the VNF which is stored in the OSM vnfrs
518 collection in Mongo.
519
520 state : VnfState
521 A representation of the VNF state (STOPPED or STARTED).
522 """
523
524 vnfr_uuid: str
525 state: VnfState
526
527
528 @dataclass
529 class ChangeVnfInstantiationStateInput:
530 """
531 Input dataclass for changing VNF Instantiation State.
532
533 Attributes:
534 -----------
535 vnfr_uuid : str
536 The UUID of the VNF which is stored in the OSM vnfrs
537 collection in Mongo.
538
539 state : VnfInstantiationState
540 A representation of the VNF instantiation state (NOT_INSTANTIATED or INSTANTIATED).
541
542 """
543
544 vnfr_uuid: str
545 state: VnfInstantiationState
546
547
548 @dataclass
549 class GetTaskQueueInput:
550 """
551 Input dataclass for get task queue activity.
552
553 Attributes:
554 -----------
555 vnfr_uuid : str
556 The UUID of the VNF which is stored in the OSM vnfrs
557 collection in Mongo.
558
559 """
560
561 vnfr_uuid: str
562
563
564 @dataclass
565 class GetTaskQueueOutput:
566 """
567 Output dataclass for get task queue activity.
568
569 Attributes:
570 -----------
571 task_queue : str
572 Name of the queue which is used to Deploy VNF.
573 """
574
575 task_queue: str
576
577
578 @dataclass
579 class GetVnfRecordInput:
580 """
581 Input dataclass for get vnf details activity.
582
583 Attributes:
584 -----------
585 vnfr_uuid : str
586 The UUID of the VNF which is stored in the OSM vnfrs
587 collection in Mongo.
588 """
589
590 vnfr_uuid: str
591
592
593 @dataclass
594 class GetVnfRecordOutput:
595 """
596 Output dataclass for get vnf details activity.
597
598 Attributes:
599 -----------
600 vnfr : dict
601 VNF record retrieved from Database.
602
603 """
604
605 vnfr: dict
606
607
608 @dataclass
609 class GetVnfDescriptorInput:
610 """
611 Input dataclass for get vnf details activity.
612
613 Attributes:
614 -----------
615 vnfd_uuid : str
616 The UUID of the VNF descriptor which is stored in the OSM vnfds
617 collection in Mongo.
618 """
619
620 vnfd_uuid: str
621
622
623 @dataclass
624 class GetVnfDescriptorOutput:
625 """
626 Output dataclass for get vnf details activity.
627
628 Attributes:
629 -----------
630 vnfd : dict
631 VNF descriptor retrieved from Database.
632 """
633
634 vnfd: dict
635
636
637 @dataclass
638 class GetVnfDetailsInput:
639 """
640 Attributes:
641 -----------
642 ns_uuid : str
643 The UUID of the NS from which to retrieve the VNF records.
644 """
645
646 ns_uuid: str
647
648
649 @dataclass
650 class GetVnfDetailsOutput:
651 """
652 Attributes:
653 -----------
654 vnf_details: list[(vnfr_ids: str, vnf_member_index_ref: str), .. ]
655 List of tuples including VNF details associated with the NS.
656 Tuple(VNF record IDs, vnf_member_index_ref)
657 """
658
659 vnf_details: List[tuple]