OSMENG-1048 Implement day1 configuration for VDU
[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 """
211
212 vnfr_uuid: str
213 model_name: str
214
215
216 @dataclass
217 class GetNsRecordInput:
218 """
219 Input dataclass for getting NS record activity.
220
221 Attributes:
222 -----------
223 nsr_uuid :
224 The UUID of the NS record which is stored in the OSM nsrs
225 collection in Mongo.
226
227 """
228
229 nsr_uuid: str
230
231
232 @dataclass
233 class GetNsRecordOutput:
234 """
235 Output dataclass for getting NS record activity.
236
237 Attributes:
238 -----------
239 nsr : dict
240 NS record retrieved from Database..
241
242 """
243
244 nsr: dict
245
246
247 #######################################################################################
248 # Activity Dataclasses
249
250
251 @dataclass
252 class UpdateLcmOperationStateInput:
253 """
254 Input dataclass for updating LCM Operations in the Mongo nslcmops
255 collection. The following attributes will be updated automatically
256 - statusEnteredTime
257 - _admin.modified
258
259 Attributes:
260 -----------
261 op_id: str
262 The operation (task) id for this activity. This is the key
263 to the record in nslcmops collection that will be updated.
264
265 op_state : LcmOperationState
266 A representation of the state of the specified operation id,
267 such as PROCESSING, COMPLETED, or FAILED.
268
269 stage: str
270 Human readable checkpoint message, intended only to give the
271 user feedback.
272
273 error_message: str
274 Human readable error message if any failure occurred.
275
276 detailed_status : str
277 Human readable message providing additional details to the
278 operation state, such as the error message explaining why
279 the operation failed.
280 """
281
282 op_id: str
283 op_state: LcmOperationState
284 stage: str
285 error_message: str
286 detailed_status: str
287
288
289 @dataclass
290 class TestVimConnectivityInput:
291 """
292 Input dataclass for the Test Vim Connectivity Ativity
293
294 Attributes:
295 -----------
296 vim_uuid : str
297 The UUID of the VIM account as stored in the OSM vim
298 collection in Mongo
299 """
300
301 vim_uuid: str
302
303
304 @dataclass
305 class UpdateVimStateInput:
306 """
307 Input dataclass for updating VIM state in the DB
308
309 Attributes:
310 -----------
311 vim_uuid : str
312 The UUID of the VIM account as stored in the OSM vim
313 collection in Mongo
314
315 operational_state : VimState
316 A representation of the operational state (ENABLED or ERROR)
317 of the VIM.
318
319 message : str
320 Human readable message providing additional details to the
321 operational state, such as the error message associated
322 with the ERROR operational_state.
323 """
324
325 vim_uuid: str
326 operational_state: VimState
327 message: str
328
329
330 @dataclass
331 class UpdateVimOperationStateInput:
332 """
333 Input dataclass for updating VIM Operations in the Mongo VIM
334 collection.
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 op_id: str
343 The operation (task) id for this workflow. This is used
344 to update the status of the operation in Mongo vim collection.
345
346 op_state : VimOperationState
347 A representation of the state of the specified operation id,
348 such as COMPLETED, or FAILED.
349
350 message : str
351 Human readable message providing additional details to the
352 operation state, such as the error message explaining why
353 the operation failed.
354 """
355
356 vim_uuid: str
357 op_id: str
358 op_state: VimOperationState
359 message: str
360
361
362 @dataclass
363 class DeleteVimInput:
364 """
365 Input dataclass for deleting vim record from the database
366
367 Attributes:
368 -----------
369 vim_uuid : str
370 The UUID of the VIM account as stored in the OSM vim
371 collection in Mongo
372
373 """
374
375 vim_uuid: str
376
377
378 @dataclass
379 class DeployNsInput:
380 """
381 Input dataclass for
382
383 Attributes:
384 -----------
385 ns_uuid : str
386 The UUID of the NS as stored in the OSM nsr
387 collection in Mongo
388 """
389
390 ns_uuid: str
391
392
393 @dataclass
394 class UpdateNsStateInput:
395 """
396 Input dataclass for updating NS state in the DB
397
398 Attributes:
399 -----------
400 ns_uuid : str
401 The UUID of the NS as stored in the OSM ns
402 collection in Mongo
403
404 operational_state : NsState
405 A representation of the operational state (ENABLED or ERROR)
406 of the NS.
407
408 message : str
409 Human readable message providing additional details to the
410 operational state, such as the error message associated
411 with the ERROR operational_state.
412 """
413
414 ns_uuid: str
415 state: NsState
416 message: str
417
418
419 @dataclass
420 class ModelInfo:
421 """
422 Contains the information related to a model.
423
424 Attributes:
425 -----------
426 vim_uuid : str
427 The UUID of the VIM as stored in the OSM vim_accounts
428 collection in Mongo.
429
430 model_name : str
431 Name of the Juju model used to deploy charms.
432 """
433
434 vim_uuid: str
435 model_name: str
436
437
438 @dataclass
439 class CheckCharmStatusInput:
440 """
441 Input dataclass for checking on a specific charm's deployment
442 status
443
444 Attributes:
445 -----------
446 vim_uuid : str
447 The UUID of the VIM as stored in the OSM vim_accounts
448 collection in Mongo.
449
450 model_name : str
451 Name of the model to create in Juju.
452
453 application_name : str
454 Name of the application that the state is going to be
455 awaited.
456
457 poll_interval : int (optional)
458 Time, in seconds, to wait between status checks.
459 """
460
461 vim_uuid: str
462 model_name: str
463 application_name: str
464 poll_interval: int = 1
465
466
467 @dataclass
468 class ChangeVnfStateInput:
469 """
470 Input dataclass for changing VNF State.
471
472 Attributes:
473 -----------
474 vnfr_uuid : str
475 The UUID of the VNF which is stored in the OSM vnfrs
476 collection in Mongo.
477
478 state : VnfState
479 A representation of the VNF state (STOPPED or STARTED).
480 """
481
482 vnfr_uuid: str
483 state: VnfState
484
485
486 @dataclass
487 class ChangeVnfInstantiationStateInput:
488 """
489 Input dataclass for changing VNF Instantiation State.
490
491 Attributes:
492 -----------
493 vnfr_uuid : str
494 The UUID of the VNF which is stored in the OSM vnfrs
495 collection in Mongo.
496
497 state : VnfInstantiationState
498 A representation of the VNF instantiation state (NOT_INSTANTIATED or INSTANTIATED).
499
500 """
501
502 vnfr_uuid: str
503 state: VnfInstantiationState
504
505
506 @dataclass
507 class GetTaskQueueInput:
508 """
509 Input dataclass for get task queue activity.
510
511 Attributes:
512 -----------
513 vnfr_uuid : str
514 The UUID of the VNF which is stored in the OSM vnfrs
515 collection in Mongo.
516
517 """
518
519 vnfr_uuid: str
520
521
522 @dataclass
523 class GetTaskQueueOutput:
524 """
525 Output dataclass for get task queue activity.
526
527 Attributes:
528 -----------
529 task_queue : str
530 Name of the queue which is used to Deploy VNF.
531 """
532
533 task_queue: str
534
535
536 @dataclass
537 class GetVnfDetailsInput:
538 """
539 Input dataclass for get vnf details activity.
540
541 Attributes:
542 -----------
543 vnfr_uuid : str
544 The UUID of the VNF which is stored in the OSM vnfrs
545 collection in Mongo.
546 """
547
548 vnfr_uuid: str
549
550
551 @dataclass
552 class GetVnfDetailsOutput:
553 """
554 Output dataclass for get vnf details activity.
555
556 Attributes:
557 -----------
558 vnfr : dict
559 VNF record retrieved from Database.
560
561 vnfd : dict
562 VNF descriptor retrieved from Database.
563 """
564
565 vnfr: dict
566 vnfd: dict
567
568
569 @dataclass
570 class GetVnfRecordIdsInput:
571 """
572 Attributes:
573 -----------
574 ns_uuid : str
575 The UUID of the NS from which to retrieve the VNF records.
576 """
577
578 ns_uuid: str
579
580
581 @dataclass
582 class GetVnfRecordIdsOutput:
583 """
584 Attributes:
585 -----------
586 vnfr_ids : list[str]
587 List of the VNF record IDs associated with the NS.
588 """
589
590 vnfr_ids: List[str]