blob: 60dac4e109961a811549e06854c956c5774bb04e [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
Mark Beierlb808fea2023-03-22 10:32:45 -040020
Gulsum Atici2f081e42023-04-06 13:41:36 +030021
22#######################################################################################
23# Defining States
24class VimState(IntEnum):
25 PROCESSING = auto()
26 ENABLED = auto()
27 ERROR = auto()
28
29
30class VimOperationState(IntEnum):
31 COMPLETED = auto()
32 FAILED = auto()
33
34
35class NsState(IntEnum):
36 PROCESSING = auto()
37 INSTANTIATED = auto()
38 ERROR = auto()
39
40
41class VnfLcmOperationState(IntEnum):
42 PROCESSING = auto()
43 COMPLETED = auto()
44 FAILED = auto()
45
46
47class VnfInstantiationState(IntEnum):
48 NOT_INSTANTIATED = auto()
49 INSTANTIATED = auto()
50
51
52class VnfState(IntEnum):
53 STOPPED = auto()
54 STARTED = auto()
55
56
57class LcmOperationState(IntEnum):
58 PROCESSING = auto()
59 COMPLETED = auto()
60 FAILED = auto()
61
62
Mark Beierlfd2324b2023-03-29 17:28:49 +000063#######################################################################################
Mark Beierla8d016d2023-03-23 10:24:59 +000064# Workflow Dataclasses
65
66
67@dataclass
Gulsum Atici654c3772023-03-23 15:59:56 +030068class 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 """
Mark Beierl30e05072023-03-28 18:04:47 +000084
Mark Beierla8d016d2023-03-23 10:24:59 +000085 vim_uuid: str
Gulsum Atici654c3772023-03-23 15:59:56 +030086 op_id: str
Mark Beierla8d016d2023-03-23 10:24:59 +000087
88
Mark Beierl248cb402023-04-05 20:01:05 +000089@dataclass
90class 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
Patricia Reinoso36a62b82023-03-31 11:22:42 +0000105@dataclass
106class 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
127class 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
146class 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
Gulsum Atici2f081e42023-04-06 13:41:36 +0300163@dataclass
164class 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
Dario Faccinaad0f782023-04-17 16:57:48 +0200174 model_name: str
Gulsum Atici2f081e42023-04-06 13:41:36 +0300175
176 """
177
178 vnfr_uuid: str
Dario Faccinaad0f782023-04-17 16:57:48 +0200179 model_name: str
Gulsum Atici2f081e42023-04-06 13:41:36 +0300180
181
Mark Beierlfd2324b2023-03-29 17:28:49 +0000182#######################################################################################
Mark Beierla8d016d2023-03-23 10:24:59 +0000183# Activity Dataclasses
184
Mark Beierlb808fea2023-03-22 10:32:45 -0400185
Mark Beierl248cb402023-04-05 20:01:05 +0000186@dataclass
187class 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
Mark Beierlb808fea2023-03-22 10:32:45 -0400224@dataclass
225class TestVimConnectivityInput:
Gulsum Atici654c3772023-03-23 15:59:56 +0300226 """
227 Input dataclass for the Test Vim Connectivity Ativity
Mark Beierlb808fea2023-03-22 10:32:45 -0400228
Gulsum Atici654c3772023-03-23 15:59:56 +0300229 Attributes:
230 -----------
231 vim_uuid : str
232 The UUID of the VIM account as stored in the OSM vim
233 collection in Mongo
234 """
Mark Beierl30e05072023-03-28 18:04:47 +0000235
Mark Beierlb808fea2023-03-22 10:32:45 -0400236 vim_uuid: str
237
Mark Beierla8d016d2023-03-23 10:24:59 +0000238
239@dataclass
Gulsum Atici654c3772023-03-23 15:59:56 +0300240class 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
Mark Beierlfd2324b2023-03-29 17:28:49 +0000250 operational_state : VimState
Gulsum Atici654c3772023-03-23 15:59:56 +0300251 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 """
Mark Beierl30e05072023-03-28 18:04:47 +0000259
Gulsum Atici654c3772023-03-23 15:59:56 +0300260 vim_uuid: str
Mark Beierlfd2324b2023-03-29 17:28:49 +0000261 operational_state: VimState
Gulsum Atici654c3772023-03-23 15:59:56 +0300262 message: str
263
264
265@dataclass
266class 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
Mark Beierlfd2324b2023-03-29 17:28:49 +0000281 op_state : VimOperationState
Gulsum Atici654c3772023-03-23 15:59:56 +0300282 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 """
Mark Beierl30e05072023-03-28 18:04:47 +0000290
Gulsum Atici654c3772023-03-23 15:59:56 +0300291 vim_uuid: str
292 op_id: str
Mark Beierlfd2324b2023-03-29 17:28:49 +0000293 op_state: VimOperationState
Gulsum Atici654c3772023-03-23 15:59:56 +0300294 message: str
Mark Beierl30e05072023-03-28 18:04:47 +0000295
296
297@dataclass
298class 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
Patricia Reinoso36a62b82023-03-31 11:22:42 +0000311
312
313@dataclass
314class 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
Patricia Reinoso36a62b82023-03-31 11:22:42 +0000328@dataclass
329class 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
Patricia Reinoso4ddf2c72023-04-12 15:57:25 +0000355class ModelInfo:
Patricia Reinoso36a62b82023-03-31 11:22:42 +0000356 """
Patricia Reinoso4ddf2c72023-04-12 15:57:25 +0000357 Contains the information related to a model.
Patricia Reinoso36a62b82023-03-31 11:22:42 +0000358
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
Patricia Reinoso4ddf2c72023-04-12 15:57:25 +0000366 Name of the Juju model used to deploy charms.
Patricia Reinoso36a62b82023-03-31 11:22:42 +0000367 """
368
369 vim_uuid: str
370 model_name: str
Gulsum Atici2f081e42023-04-06 13:41:36 +0300371
372
373@dataclass
Mark Beierleebe8f52023-04-11 21:01:22 +0000374class 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
Mark Beierle65a9db2023-04-18 14:33:05 +0000403class ChangeVnfStateInput:
Gulsum Atici2f081e42023-04-06 13:41:36 +0300404 """
Gulsum Atici56e41a52023-04-07 00:04:28 +0300405 Input dataclass for changing VNF State.
Gulsum Atici2f081e42023-04-06 13:41:36 +0300406
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
Dario Faccin42c4ba22023-04-14 10:24:38 +0200413 state : VnfState
Gulsum Atici2f081e42023-04-06 13:41:36 +0300414 A representation of the VNF state (STOPPED or STARTED).
415 """
416
417 vnfr_uuid: str
418 state: VnfState
419
420
421@dataclass
Dario Faccin42c4ba22023-04-14 10:24:38 +0200422class ChangeVnfInstantiationStateInput:
Gulsum Atici2f081e42023-04-06 13:41:36 +0300423 """
Gulsum Atici56e41a52023-04-07 00:04:28 +0300424 Input dataclass for changing VNF Instantiation State.
Gulsum Atici2f081e42023-04-06 13:41:36 +0300425
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
Dario Faccin42c4ba22023-04-14 10:24:38 +0200432 state : VnfInstantiationState
Gulsum Atici2f081e42023-04-06 13:41:36 +0300433 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
442class GetTaskQueueInput:
443 """
Gulsum Atici56e41a52023-04-07 00:04:28 +0300444 Input dataclass for get task queue activity.
Gulsum Atici2f081e42023-04-06 13:41:36 +0300445
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
458class 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
Gulsum Atici56e41a52023-04-07 00:04:28 +0300469
470
471@dataclass
472class 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
487class 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