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