blob: 26797a643b03245633fd704f3d90d9870c7fd302 [file] [log] [blame]
Mark Beierlb808fea2023-03-22 10:32:45 -04001#######################################################################################
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
18from dataclasses import dataclass
Mark Beierlfd2324b2023-03-29 17:28:49 +000019from enum import auto, IntEnum
Daniel Arndt58076ca2023-04-19 14:43:26 -030020from typing import List
Mark Beierlb808fea2023-03-22 10:32:45 -040021
Gulsum Atici2f081e42023-04-06 13:41:36 +030022
23#######################################################################################
24# Defining States
25class VimState(IntEnum):
26 PROCESSING = auto()
27 ENABLED = auto()
28 ERROR = auto()
29
30
31class VimOperationState(IntEnum):
32 COMPLETED = auto()
33 FAILED = auto()
34
35
36class NsState(IntEnum):
37 PROCESSING = auto()
38 INSTANTIATED = auto()
39 ERROR = auto()
40
41
42class VnfLcmOperationState(IntEnum):
43 PROCESSING = auto()
44 COMPLETED = auto()
45 FAILED = auto()
46
47
48class VnfInstantiationState(IntEnum):
49 NOT_INSTANTIATED = auto()
50 INSTANTIATED = auto()
51
52
53class VnfState(IntEnum):
54 STOPPED = auto()
55 STARTED = auto()
56
57
58class LcmOperationState(IntEnum):
59 PROCESSING = auto()
60 COMPLETED = auto()
61 FAILED = auto()
62
63
Mark Beierlfd2324b2023-03-29 17:28:49 +000064#######################################################################################
Mark Beierla8d016d2023-03-23 10:24:59 +000065# Workflow Dataclasses
66
67
68@dataclass
Gulsum Atici654c3772023-03-23 15:59:56 +030069class 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 """
Mark Beierl30e05072023-03-28 18:04:47 +000085
Mark Beierla8d016d2023-03-23 10:24:59 +000086 vim_uuid: str
Gulsum Atici654c3772023-03-23 15:59:56 +030087 op_id: str
Mark Beierla8d016d2023-03-23 10:24:59 +000088
89
Mark Beierl248cb402023-04-05 20:01:05 +000090@dataclass
91class 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
Patricia Reinoso36a62b82023-03-31 11:22:42 +0000106@dataclass
Patricia Reinoso36a62b82023-03-31 11:22:42 +0000107class 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
Gulsum Atici0d5d9aa2023-04-25 14:56:49 +0300126class 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
142class 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
156class VduComputeConstraints:
157 """
158 Input dataclass for VDU constraints
159
160 Attributes:
161 -----------
162 cores : int (Number of virtual CPUs)
163
164 mem: int (GB)
Gulsum Atici0d5d9aa2023-04-25 14:56:49 +0300165 """
166
167 cores: int
168 mem: int
Gulsum Atici0d5d9aa2023-04-25 14:56:49 +0300169
170
171@dataclass
Patricia Reinoso36a62b82023-03-31 11:22:42 +0000172class 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
Gulsum Atici0d5d9aa2023-04-25 14:56:49 +0300182 constraints: VduComputeConstraints
Gulsum Atici8e8a21c2023-04-27 00:44:26 +0300183
184 cloud: VIM cloud type
Patricia Reinoso36a62b82023-03-31 11:22:42 +0000185 """
186
187 vim_uuid: str
188 model_name: str
189 charm_info: CharmInfo
Gulsum Atici0d5d9aa2023-04-25 14:56:49 +0300190 constraints: VduComputeConstraints
Gulsum Atici8e8a21c2023-04-27 00:44:26 +0300191 cloud: str
Patricia Reinoso36a62b82023-03-31 11:22:42 +0000192
193
Gulsum Atici2f081e42023-04-06 13:41:36 +0300194@dataclass
195class 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
Dario Faccinaad0f782023-04-17 16:57:48 +0200205 model_name: str
Gulsum Atici2f081e42023-04-06 13:41:36 +0300206
207 """
208
209 vnfr_uuid: str
Dario Faccinaad0f782023-04-17 16:57:48 +0200210 model_name: str
Gulsum Atici2f081e42023-04-06 13:41:36 +0300211
212
Mark Beierlfd2324b2023-03-29 17:28:49 +0000213#######################################################################################
Mark Beierla8d016d2023-03-23 10:24:59 +0000214# Activity Dataclasses
215
Mark Beierlb808fea2023-03-22 10:32:45 -0400216
Mark Beierl248cb402023-04-05 20:01:05 +0000217@dataclass
218class 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
Mark Beierlb808fea2023-03-22 10:32:45 -0400255@dataclass
256class TestVimConnectivityInput:
Gulsum Atici654c3772023-03-23 15:59:56 +0300257 """
258 Input dataclass for the Test Vim Connectivity Ativity
Mark Beierlb808fea2023-03-22 10:32:45 -0400259
Gulsum Atici654c3772023-03-23 15:59:56 +0300260 Attributes:
261 -----------
262 vim_uuid : str
263 The UUID of the VIM account as stored in the OSM vim
264 collection in Mongo
265 """
Mark Beierl30e05072023-03-28 18:04:47 +0000266
Mark Beierlb808fea2023-03-22 10:32:45 -0400267 vim_uuid: str
268
Mark Beierla8d016d2023-03-23 10:24:59 +0000269
270@dataclass
Gulsum Atici654c3772023-03-23 15:59:56 +0300271class 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
Mark Beierlfd2324b2023-03-29 17:28:49 +0000281 operational_state : VimState
Gulsum Atici654c3772023-03-23 15:59:56 +0300282 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 """
Mark Beierl30e05072023-03-28 18:04:47 +0000290
Gulsum Atici654c3772023-03-23 15:59:56 +0300291 vim_uuid: str
Mark Beierlfd2324b2023-03-29 17:28:49 +0000292 operational_state: VimState
Gulsum Atici654c3772023-03-23 15:59:56 +0300293 message: str
294
295
296@dataclass
297class 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
Mark Beierlfd2324b2023-03-29 17:28:49 +0000312 op_state : VimOperationState
Gulsum Atici654c3772023-03-23 15:59:56 +0300313 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 """
Mark Beierl30e05072023-03-28 18:04:47 +0000321
Gulsum Atici654c3772023-03-23 15:59:56 +0300322 vim_uuid: str
323 op_id: str
Mark Beierlfd2324b2023-03-29 17:28:49 +0000324 op_state: VimOperationState
Gulsum Atici654c3772023-03-23 15:59:56 +0300325 message: str
Mark Beierl30e05072023-03-28 18:04:47 +0000326
327
328@dataclass
329class 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
Patricia Reinoso36a62b82023-03-31 11:22:42 +0000342
343
344@dataclass
345class 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
Patricia Reinoso36a62b82023-03-31 11:22:42 +0000359@dataclass
360class 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
Patricia Reinoso4ddf2c72023-04-12 15:57:25 +0000386class ModelInfo:
Patricia Reinoso36a62b82023-03-31 11:22:42 +0000387 """
Patricia Reinoso4ddf2c72023-04-12 15:57:25 +0000388 Contains the information related to a model.
Patricia Reinoso36a62b82023-03-31 11:22:42 +0000389
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
Patricia Reinoso4ddf2c72023-04-12 15:57:25 +0000397 Name of the Juju model used to deploy charms.
Patricia Reinoso36a62b82023-03-31 11:22:42 +0000398 """
399
400 vim_uuid: str
401 model_name: str
Gulsum Atici2f081e42023-04-06 13:41:36 +0300402
403
404@dataclass
Mark Beierleebe8f52023-04-11 21:01:22 +0000405class 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
Mark Beierle65a9db2023-04-18 14:33:05 +0000434class ChangeVnfStateInput:
Gulsum Atici2f081e42023-04-06 13:41:36 +0300435 """
Gulsum Atici56e41a52023-04-07 00:04:28 +0300436 Input dataclass for changing VNF State.
Gulsum Atici2f081e42023-04-06 13:41:36 +0300437
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
Dario Faccin42c4ba22023-04-14 10:24:38 +0200444 state : VnfState
Gulsum Atici2f081e42023-04-06 13:41:36 +0300445 A representation of the VNF state (STOPPED or STARTED).
446 """
447
448 vnfr_uuid: str
449 state: VnfState
450
451
452@dataclass
Dario Faccin42c4ba22023-04-14 10:24:38 +0200453class ChangeVnfInstantiationStateInput:
Gulsum Atici2f081e42023-04-06 13:41:36 +0300454 """
Gulsum Atici56e41a52023-04-07 00:04:28 +0300455 Input dataclass for changing VNF Instantiation State.
Gulsum Atici2f081e42023-04-06 13:41:36 +0300456
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
Dario Faccin42c4ba22023-04-14 10:24:38 +0200463 state : VnfInstantiationState
Gulsum Atici2f081e42023-04-06 13:41:36 +0300464 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
473class GetTaskQueueInput:
474 """
Gulsum Atici56e41a52023-04-07 00:04:28 +0300475 Input dataclass for get task queue activity.
Gulsum Atici2f081e42023-04-06 13:41:36 +0300476
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
489class 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
Gulsum Atici56e41a52023-04-07 00:04:28 +0300500
501
502@dataclass
503class 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
518class 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
Daniel Arndt58076ca2023-04-19 14:43:26 -0300533
534
535@dataclass
536class 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
548class 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]