blob: 38dfcfabc4d80bddfefa26790cbf1dd3309a8d66 [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
126class VduInstantiateInput:
127 """
128 Input dataclass for workflow that instantiates a VDU.
129
130 vim_uuid: str
131
132 model_name: str
133
134 charm_info : CharmInfo
135
136 """
137
138 vim_uuid: str
139 model_name: str
140 charm_info: CharmInfo
141
142
Gulsum Atici2f081e42023-04-06 13:41:36 +0300143@dataclass
144class VnfInstantiateInput:
145 """
146 Input dataclass for workflow that instantiates a VNF.
147
148 Attributes:
149 -----------
150 vnfr_uuid : str
151 The UUID of the VNF which is stored in the OSM vnfrs
152 collection in Mongo.
153
Dario Faccinaad0f782023-04-17 16:57:48 +0200154 model_name: str
Gulsum Atici2f081e42023-04-06 13:41:36 +0300155
156 """
157
158 vnfr_uuid: str
Dario Faccinaad0f782023-04-17 16:57:48 +0200159 model_name: str
Gulsum Atici2f081e42023-04-06 13:41:36 +0300160
161
Mark Beierlfd2324b2023-03-29 17:28:49 +0000162#######################################################################################
Mark Beierla8d016d2023-03-23 10:24:59 +0000163# Activity Dataclasses
164
Mark Beierlb808fea2023-03-22 10:32:45 -0400165
Mark Beierl248cb402023-04-05 20:01:05 +0000166@dataclass
167class UpdateLcmOperationStateInput:
168 """
169 Input dataclass for updating LCM Operations in the Mongo nslcmops
170 collection. The following attributes will be updated automatically
171 - statusEnteredTime
172 - _admin.modified
173
174 Attributes:
175 -----------
176 op_id: str
177 The operation (task) id for this activity. This is the key
178 to the record in nslcmops collection that will be updated.
179
180 op_state : LcmOperationState
181 A representation of the state of the specified operation id,
182 such as PROCESSING, COMPLETED, or FAILED.
183
184 stage: str
185 Human readable checkpoint message, intended only to give the
186 user feedback.
187
188 error_message: str
189 Human readable error message if any failure occurred.
190
191 detailed_status : str
192 Human readable message providing additional details to the
193 operation state, such as the error message explaining why
194 the operation failed.
195 """
196
197 op_id: str
198 op_state: LcmOperationState
199 stage: str
200 error_message: str
201 detailed_status: str
202
203
Mark Beierlb808fea2023-03-22 10:32:45 -0400204@dataclass
205class TestVimConnectivityInput:
Gulsum Atici654c3772023-03-23 15:59:56 +0300206 """
207 Input dataclass for the Test Vim Connectivity Ativity
Mark Beierlb808fea2023-03-22 10:32:45 -0400208
Gulsum Atici654c3772023-03-23 15:59:56 +0300209 Attributes:
210 -----------
211 vim_uuid : str
212 The UUID of the VIM account as stored in the OSM vim
213 collection in Mongo
214 """
Mark Beierl30e05072023-03-28 18:04:47 +0000215
Mark Beierlb808fea2023-03-22 10:32:45 -0400216 vim_uuid: str
217
Mark Beierla8d016d2023-03-23 10:24:59 +0000218
219@dataclass
Gulsum Atici654c3772023-03-23 15:59:56 +0300220class UpdateVimStateInput:
221 """
222 Input dataclass for updating VIM state in the DB
223
224 Attributes:
225 -----------
226 vim_uuid : str
227 The UUID of the VIM account as stored in the OSM vim
228 collection in Mongo
229
Mark Beierlfd2324b2023-03-29 17:28:49 +0000230 operational_state : VimState
Gulsum Atici654c3772023-03-23 15:59:56 +0300231 A representation of the operational state (ENABLED or ERROR)
232 of the VIM.
233
234 message : str
235 Human readable message providing additional details to the
236 operational state, such as the error message associated
237 with the ERROR operational_state.
238 """
Mark Beierl30e05072023-03-28 18:04:47 +0000239
Gulsum Atici654c3772023-03-23 15:59:56 +0300240 vim_uuid: str
Mark Beierlfd2324b2023-03-29 17:28:49 +0000241 operational_state: VimState
Gulsum Atici654c3772023-03-23 15:59:56 +0300242 message: str
243
244
245@dataclass
246class UpdateVimOperationStateInput:
247 """
248 Input dataclass for updating VIM Operations in the Mongo VIM
249 collection.
250
251 Attributes:
252 -----------
253 vim_uuid : str
254 The UUID of the VIM account as stored in the OSM vim
255 collection in Mongo
256
257 op_id: str
258 The operation (task) id for this workflow. This is used
259 to update the status of the operation in Mongo vim collection.
260
Mark Beierlfd2324b2023-03-29 17:28:49 +0000261 op_state : VimOperationState
Gulsum Atici654c3772023-03-23 15:59:56 +0300262 A representation of the state of the specified operation id,
263 such as COMPLETED, or FAILED.
264
265 message : str
266 Human readable message providing additional details to the
267 operation state, such as the error message explaining why
268 the operation failed.
269 """
Mark Beierl30e05072023-03-28 18:04:47 +0000270
Gulsum Atici654c3772023-03-23 15:59:56 +0300271 vim_uuid: str
272 op_id: str
Mark Beierlfd2324b2023-03-29 17:28:49 +0000273 op_state: VimOperationState
Gulsum Atici654c3772023-03-23 15:59:56 +0300274 message: str
Mark Beierl30e05072023-03-28 18:04:47 +0000275
276
277@dataclass
278class DeleteVimInput:
279 """
280 Input dataclass for deleting vim record from the database
281
282 Attributes:
283 -----------
284 vim_uuid : str
285 The UUID of the VIM account as stored in the OSM vim
286 collection in Mongo
287
288 """
289
290 vim_uuid: str
Patricia Reinoso36a62b82023-03-31 11:22:42 +0000291
292
293@dataclass
294class DeployNsInput:
295 """
296 Input dataclass for
297
298 Attributes:
299 -----------
300 ns_uuid : str
301 The UUID of the NS as stored in the OSM nsr
302 collection in Mongo
303 """
304
305 ns_uuid: str
306
307
Patricia Reinoso36a62b82023-03-31 11:22:42 +0000308@dataclass
309class UpdateNsStateInput:
310 """
311 Input dataclass for updating NS state in the DB
312
313 Attributes:
314 -----------
315 ns_uuid : str
316 The UUID of the NS as stored in the OSM ns
317 collection in Mongo
318
319 operational_state : NsState
320 A representation of the operational state (ENABLED or ERROR)
321 of the NS.
322
323 message : str
324 Human readable message providing additional details to the
325 operational state, such as the error message associated
326 with the ERROR operational_state.
327 """
328
329 ns_uuid: str
330 state: NsState
331 message: str
332
333
334@dataclass
Patricia Reinoso4ddf2c72023-04-12 15:57:25 +0000335class ModelInfo:
Patricia Reinoso36a62b82023-03-31 11:22:42 +0000336 """
Patricia Reinoso4ddf2c72023-04-12 15:57:25 +0000337 Contains the information related to a model.
Patricia Reinoso36a62b82023-03-31 11:22:42 +0000338
339 Attributes:
340 -----------
341 vim_uuid : str
342 The UUID of the VIM as stored in the OSM vim_accounts
343 collection in Mongo.
344
345 model_name : str
Patricia Reinoso4ddf2c72023-04-12 15:57:25 +0000346 Name of the Juju model used to deploy charms.
Patricia Reinoso36a62b82023-03-31 11:22:42 +0000347 """
348
349 vim_uuid: str
350 model_name: str
Gulsum Atici2f081e42023-04-06 13:41:36 +0300351
352
353@dataclass
Mark Beierleebe8f52023-04-11 21:01:22 +0000354class CheckCharmStatusInput:
355 """
356 Input dataclass for checking on a specific charm's deployment
357 status
358
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
366 Name of the model to create in Juju.
367
368 application_name : str
369 Name of the application that the state is going to be
370 awaited.
371
372 poll_interval : int (optional)
373 Time, in seconds, to wait between status checks.
374 """
375
376 vim_uuid: str
377 model_name: str
378 application_name: str
379 poll_interval: int = 1
380
381
382@dataclass
Mark Beierle65a9db2023-04-18 14:33:05 +0000383class ChangeVnfStateInput:
Gulsum Atici2f081e42023-04-06 13:41:36 +0300384 """
Gulsum Atici56e41a52023-04-07 00:04:28 +0300385 Input dataclass for changing VNF State.
Gulsum Atici2f081e42023-04-06 13:41:36 +0300386
387 Attributes:
388 -----------
389 vnfr_uuid : str
390 The UUID of the VNF which is stored in the OSM vnfrs
391 collection in Mongo.
392
Dario Faccin42c4ba22023-04-14 10:24:38 +0200393 state : VnfState
Gulsum Atici2f081e42023-04-06 13:41:36 +0300394 A representation of the VNF state (STOPPED or STARTED).
395 """
396
397 vnfr_uuid: str
398 state: VnfState
399
400
401@dataclass
Dario Faccin42c4ba22023-04-14 10:24:38 +0200402class ChangeVnfInstantiationStateInput:
Gulsum Atici2f081e42023-04-06 13:41:36 +0300403 """
Gulsum Atici56e41a52023-04-07 00:04:28 +0300404 Input dataclass for changing VNF Instantiation State.
Gulsum Atici2f081e42023-04-06 13:41:36 +0300405
406 Attributes:
407 -----------
408 vnfr_uuid : str
409 The UUID of the VNF which is stored in the OSM vnfrs
410 collection in Mongo.
411
Dario Faccin42c4ba22023-04-14 10:24:38 +0200412 state : VnfInstantiationState
Gulsum Atici2f081e42023-04-06 13:41:36 +0300413 A representation of the VNF instantiation state (NOT_INSTANTIATED or INSTANTIATED).
414
415 """
416
417 vnfr_uuid: str
418 state: VnfInstantiationState
419
420
421@dataclass
422class GetTaskQueueInput:
423 """
Gulsum Atici56e41a52023-04-07 00:04:28 +0300424 Input dataclass for get task queue activity.
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
432 """
433
434 vnfr_uuid: str
435
436
437@dataclass
438class GetTaskQueueOutput:
439 """
440 Output dataclass for get task queue activity.
441
442 Attributes:
443 -----------
444 task_queue : str
445 Name of the queue which is used to Deploy VNF.
446 """
447
448 task_queue: str
Gulsum Atici56e41a52023-04-07 00:04:28 +0300449
450
451@dataclass
452class GetVnfDetailsInput:
453 """
454 Input dataclass for get vnf details activity.
455
456 Attributes:
457 -----------
458 vnfr_uuid : str
459 The UUID of the VNF which is stored in the OSM vnfrs
460 collection in Mongo.
461 """
462
463 vnfr_uuid: str
464
465
466@dataclass
467class GetVnfDetailsOutput:
468 """
469 Output dataclass for get vnf details activity.
470
471 Attributes:
472 -----------
473 vnfr : dict
474 VNF record retrieved from Database.
475
476 vnfd : dict
477 VNF descriptor retrieved from Database.
478 """
479
480 vnfr: dict
481 vnfd: dict
Daniel Arndt58076ca2023-04-19 14:43:26 -0300482
483
484@dataclass
485class GetVnfRecordIdsInput:
486 """
487 Attributes:
488 -----------
489 ns_uuid : str
490 The UUID of the NS from which to retrieve the VNF records.
491 """
492
493 ns_uuid: str
494
495
496@dataclass
497class GetVnfRecordIdsOutput:
498 """
499 Attributes:
500 -----------
501 vnfr_ids : list[str]
502 List of the VNF record IDs associated with the NS.
503 """
504
505 vnfr_ids: List[str]