| Mark Beierl | b808fea | 2023-03-22 10:32:45 -0400 | [diff] [blame] | 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 |
| Mark Beierl | fd2324b | 2023-03-29 17:28:49 +0000 | [diff] [blame] | 19 | from enum import auto, IntEnum |
| Mark Beierl | b808fea | 2023-03-22 10:32:45 -0400 | [diff] [blame] | 20 | |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 21 | |
| 22 | ####################################################################################### |
| 23 | # Defining States |
| 24 | class VimState(IntEnum): |
| 25 | PROCESSING = auto() |
| 26 | ENABLED = auto() |
| 27 | ERROR = auto() |
| 28 | |
| 29 | |
| 30 | class VimOperationState(IntEnum): |
| 31 | COMPLETED = auto() |
| 32 | FAILED = auto() |
| 33 | |
| 34 | |
| 35 | class NsState(IntEnum): |
| 36 | PROCESSING = auto() |
| 37 | INSTANTIATED = auto() |
| 38 | ERROR = auto() |
| 39 | |
| 40 | |
| 41 | class VnfLcmOperationState(IntEnum): |
| 42 | PROCESSING = auto() |
| 43 | COMPLETED = auto() |
| 44 | FAILED = auto() |
| 45 | |
| 46 | |
| 47 | class VnfInstantiationState(IntEnum): |
| 48 | NOT_INSTANTIATED = auto() |
| 49 | INSTANTIATED = auto() |
| 50 | |
| 51 | |
| 52 | class VnfState(IntEnum): |
| 53 | STOPPED = auto() |
| 54 | STARTED = auto() |
| 55 | |
| 56 | |
| 57 | class LcmOperationState(IntEnum): |
| 58 | PROCESSING = auto() |
| 59 | COMPLETED = auto() |
| 60 | FAILED = auto() |
| 61 | |
| 62 | |
| Mark Beierl | fd2324b | 2023-03-29 17:28:49 +0000 | [diff] [blame] | 63 | ####################################################################################### |
| Mark Beierl | a8d016d | 2023-03-23 10:24:59 +0000 | [diff] [blame] | 64 | # Workflow Dataclasses |
| 65 | |
| 66 | |
| 67 | @dataclass |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 68 | class 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 Beierl | 30e0507 | 2023-03-28 18:04:47 +0000 | [diff] [blame] | 84 | |
| Mark Beierl | a8d016d | 2023-03-23 10:24:59 +0000 | [diff] [blame] | 85 | vim_uuid: str |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 86 | op_id: str |
| Mark Beierl | a8d016d | 2023-03-23 10:24:59 +0000 | [diff] [blame] | 87 | |
| 88 | |
| Mark Beierl | 248cb40 | 2023-04-05 20:01:05 +0000 | [diff] [blame] | 89 | @dataclass |
| 90 | class 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 Reinoso | 36a62b8 | 2023-03-31 11:22:42 +0000 | [diff] [blame] | 105 | @dataclass |
| 106 | class 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 |
| 127 | class 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 |
| 146 | class 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 Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 163 | @dataclass |
| 164 | class 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 | |
| 174 | """ |
| 175 | |
| 176 | vnfr_uuid: str |
| 177 | |
| 178 | |
| 179 | @dataclass |
| 180 | class PrepareVnfInput: |
| 181 | """ |
| Gulsum Atici | 56e41a5 | 2023-04-07 00:04:28 +0300 | [diff] [blame] | 182 | Input dataclass for workflow that prepares a VNF. |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 183 | |
| 184 | Attributes: |
| 185 | ----------- |
| 186 | vnfr_uuid : str |
| 187 | The UUID of the VNF which is stored in the OSM vnfrs |
| 188 | collection in Mongo. |
| 189 | |
| 190 | """ |
| 191 | |
| 192 | vnfr_uuid: str |
| 193 | |
| 194 | |
| Mark Beierl | fd2324b | 2023-03-29 17:28:49 +0000 | [diff] [blame] | 195 | ####################################################################################### |
| Mark Beierl | a8d016d | 2023-03-23 10:24:59 +0000 | [diff] [blame] | 196 | # Activity Dataclasses |
| 197 | |
| Mark Beierl | b808fea | 2023-03-22 10:32:45 -0400 | [diff] [blame] | 198 | |
| Mark Beierl | 248cb40 | 2023-04-05 20:01:05 +0000 | [diff] [blame] | 199 | @dataclass |
| 200 | class UpdateLcmOperationStateInput: |
| 201 | """ |
| 202 | Input dataclass for updating LCM Operations in the Mongo nslcmops |
| 203 | collection. The following attributes will be updated automatically |
| 204 | - statusEnteredTime |
| 205 | - _admin.modified |
| 206 | |
| 207 | Attributes: |
| 208 | ----------- |
| 209 | op_id: str |
| 210 | The operation (task) id for this activity. This is the key |
| 211 | to the record in nslcmops collection that will be updated. |
| 212 | |
| 213 | op_state : LcmOperationState |
| 214 | A representation of the state of the specified operation id, |
| 215 | such as PROCESSING, COMPLETED, or FAILED. |
| 216 | |
| 217 | stage: str |
| 218 | Human readable checkpoint message, intended only to give the |
| 219 | user feedback. |
| 220 | |
| 221 | error_message: str |
| 222 | Human readable error message if any failure occurred. |
| 223 | |
| 224 | detailed_status : str |
| 225 | Human readable message providing additional details to the |
| 226 | operation state, such as the error message explaining why |
| 227 | the operation failed. |
| 228 | """ |
| 229 | |
| 230 | op_id: str |
| 231 | op_state: LcmOperationState |
| 232 | stage: str |
| 233 | error_message: str |
| 234 | detailed_status: str |
| 235 | |
| 236 | |
| Mark Beierl | b808fea | 2023-03-22 10:32:45 -0400 | [diff] [blame] | 237 | @dataclass |
| 238 | class TestVimConnectivityInput: |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 239 | """ |
| 240 | Input dataclass for the Test Vim Connectivity Ativity |
| Mark Beierl | b808fea | 2023-03-22 10:32:45 -0400 | [diff] [blame] | 241 | |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 242 | Attributes: |
| 243 | ----------- |
| 244 | vim_uuid : str |
| 245 | The UUID of the VIM account as stored in the OSM vim |
| 246 | collection in Mongo |
| 247 | """ |
| Mark Beierl | 30e0507 | 2023-03-28 18:04:47 +0000 | [diff] [blame] | 248 | |
| Mark Beierl | b808fea | 2023-03-22 10:32:45 -0400 | [diff] [blame] | 249 | vim_uuid: str |
| 250 | |
| Mark Beierl | a8d016d | 2023-03-23 10:24:59 +0000 | [diff] [blame] | 251 | |
| 252 | @dataclass |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 253 | class UpdateVimStateInput: |
| 254 | """ |
| 255 | Input dataclass for updating VIM state in the DB |
| 256 | |
| 257 | Attributes: |
| 258 | ----------- |
| 259 | vim_uuid : str |
| 260 | The UUID of the VIM account as stored in the OSM vim |
| 261 | collection in Mongo |
| 262 | |
| Mark Beierl | fd2324b | 2023-03-29 17:28:49 +0000 | [diff] [blame] | 263 | operational_state : VimState |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 264 | A representation of the operational state (ENABLED or ERROR) |
| 265 | of the VIM. |
| 266 | |
| 267 | message : str |
| 268 | Human readable message providing additional details to the |
| 269 | operational state, such as the error message associated |
| 270 | with the ERROR operational_state. |
| 271 | """ |
| Mark Beierl | 30e0507 | 2023-03-28 18:04:47 +0000 | [diff] [blame] | 272 | |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 273 | vim_uuid: str |
| Mark Beierl | fd2324b | 2023-03-29 17:28:49 +0000 | [diff] [blame] | 274 | operational_state: VimState |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 275 | message: str |
| 276 | |
| 277 | |
| 278 | @dataclass |
| 279 | class UpdateVimOperationStateInput: |
| 280 | """ |
| 281 | Input dataclass for updating VIM Operations in the Mongo VIM |
| 282 | collection. |
| 283 | |
| 284 | Attributes: |
| 285 | ----------- |
| 286 | vim_uuid : str |
| 287 | The UUID of the VIM account as stored in the OSM vim |
| 288 | collection in Mongo |
| 289 | |
| 290 | op_id: str |
| 291 | The operation (task) id for this workflow. This is used |
| 292 | to update the status of the operation in Mongo vim collection. |
| 293 | |
| Mark Beierl | fd2324b | 2023-03-29 17:28:49 +0000 | [diff] [blame] | 294 | op_state : VimOperationState |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 295 | A representation of the state of the specified operation id, |
| 296 | such as COMPLETED, or FAILED. |
| 297 | |
| 298 | message : str |
| 299 | Human readable message providing additional details to the |
| 300 | operation state, such as the error message explaining why |
| 301 | the operation failed. |
| 302 | """ |
| Mark Beierl | 30e0507 | 2023-03-28 18:04:47 +0000 | [diff] [blame] | 303 | |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 304 | vim_uuid: str |
| 305 | op_id: str |
| Mark Beierl | fd2324b | 2023-03-29 17:28:49 +0000 | [diff] [blame] | 306 | op_state: VimOperationState |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 307 | message: str |
| Mark Beierl | 30e0507 | 2023-03-28 18:04:47 +0000 | [diff] [blame] | 308 | |
| 309 | |
| 310 | @dataclass |
| 311 | class DeleteVimInput: |
| 312 | """ |
| 313 | Input dataclass for deleting vim record from the database |
| 314 | |
| 315 | Attributes: |
| 316 | ----------- |
| 317 | vim_uuid : str |
| 318 | The UUID of the VIM account as stored in the OSM vim |
| 319 | collection in Mongo |
| 320 | |
| 321 | """ |
| 322 | |
| 323 | vim_uuid: str |
| Patricia Reinoso | 36a62b8 | 2023-03-31 11:22:42 +0000 | [diff] [blame] | 324 | |
| 325 | |
| 326 | @dataclass |
| 327 | class DeployNsInput: |
| 328 | """ |
| 329 | Input dataclass for |
| 330 | |
| 331 | Attributes: |
| 332 | ----------- |
| 333 | ns_uuid : str |
| 334 | The UUID of the NS as stored in the OSM nsr |
| 335 | collection in Mongo |
| 336 | """ |
| 337 | |
| 338 | ns_uuid: str |
| 339 | |
| 340 | |
| Patricia Reinoso | 36a62b8 | 2023-03-31 11:22:42 +0000 | [diff] [blame] | 341 | @dataclass |
| 342 | class UpdateNsStateInput: |
| 343 | """ |
| 344 | Input dataclass for updating NS state in the DB |
| 345 | |
| 346 | Attributes: |
| 347 | ----------- |
| 348 | ns_uuid : str |
| 349 | The UUID of the NS as stored in the OSM ns |
| 350 | collection in Mongo |
| 351 | |
| 352 | operational_state : NsState |
| 353 | A representation of the operational state (ENABLED or ERROR) |
| 354 | of the NS. |
| 355 | |
| 356 | message : str |
| 357 | Human readable message providing additional details to the |
| 358 | operational state, such as the error message associated |
| 359 | with the ERROR operational_state. |
| 360 | """ |
| 361 | |
| 362 | ns_uuid: str |
| 363 | state: NsState |
| 364 | message: str |
| 365 | |
| 366 | |
| 367 | @dataclass |
| Patricia Reinoso | 4ddf2c7 | 2023-04-12 15:57:25 +0000 | [diff] [blame] | 368 | class ModelInfo: |
| Patricia Reinoso | 36a62b8 | 2023-03-31 11:22:42 +0000 | [diff] [blame] | 369 | """ |
| Patricia Reinoso | 4ddf2c7 | 2023-04-12 15:57:25 +0000 | [diff] [blame] | 370 | Contains the information related to a model. |
| Patricia Reinoso | 36a62b8 | 2023-03-31 11:22:42 +0000 | [diff] [blame] | 371 | |
| 372 | Attributes: |
| 373 | ----------- |
| 374 | vim_uuid : str |
| 375 | The UUID of the VIM as stored in the OSM vim_accounts |
| 376 | collection in Mongo. |
| 377 | |
| 378 | model_name : str |
| Patricia Reinoso | 4ddf2c7 | 2023-04-12 15:57:25 +0000 | [diff] [blame] | 379 | Name of the Juju model used to deploy charms. |
| Patricia Reinoso | 36a62b8 | 2023-03-31 11:22:42 +0000 | [diff] [blame] | 380 | """ |
| 381 | |
| 382 | vim_uuid: str |
| 383 | model_name: str |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 384 | |
| 385 | |
| 386 | @dataclass |
| Mark Beierl | eebe8f5 | 2023-04-11 21:01:22 +0000 | [diff] [blame] | 387 | class CheckCharmStatusInput: |
| 388 | """ |
| 389 | Input dataclass for checking on a specific charm's deployment |
| 390 | status |
| 391 | |
| 392 | Attributes: |
| 393 | ----------- |
| 394 | vim_uuid : str |
| 395 | The UUID of the VIM as stored in the OSM vim_accounts |
| 396 | collection in Mongo. |
| 397 | |
| 398 | model_name : str |
| 399 | Name of the model to create in Juju. |
| 400 | |
| 401 | application_name : str |
| 402 | Name of the application that the state is going to be |
| 403 | awaited. |
| 404 | |
| 405 | poll_interval : int (optional) |
| 406 | Time, in seconds, to wait between status checks. |
| 407 | """ |
| 408 | |
| 409 | vim_uuid: str |
| 410 | model_name: str |
| 411 | application_name: str |
| 412 | poll_interval: int = 1 |
| 413 | |
| 414 | |
| 415 | @dataclass |
| Mark Beierl | e65a9db | 2023-04-18 14:33:05 +0000 | [diff] [blame^] | 416 | class ChangeVnfStateInput: |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 417 | """ |
| Gulsum Atici | 56e41a5 | 2023-04-07 00:04:28 +0300 | [diff] [blame] | 418 | Input dataclass for changing VNF State. |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 419 | |
| 420 | Attributes: |
| 421 | ----------- |
| 422 | vnfr_uuid : str |
| 423 | The UUID of the VNF which is stored in the OSM vnfrs |
| 424 | collection in Mongo. |
| 425 | |
| Dario Faccin | 42c4ba2 | 2023-04-14 10:24:38 +0200 | [diff] [blame] | 426 | state : VnfState |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 427 | A representation of the VNF state (STOPPED or STARTED). |
| 428 | """ |
| 429 | |
| 430 | vnfr_uuid: str |
| 431 | state: VnfState |
| 432 | |
| 433 | |
| 434 | @dataclass |
| Dario Faccin | 42c4ba2 | 2023-04-14 10:24:38 +0200 | [diff] [blame] | 435 | class ChangeVnfInstantiationStateInput: |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 436 | """ |
| Gulsum Atici | 56e41a5 | 2023-04-07 00:04:28 +0300 | [diff] [blame] | 437 | Input dataclass for changing VNF Instantiation State. |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 438 | |
| 439 | Attributes: |
| 440 | ----------- |
| 441 | vnfr_uuid : str |
| 442 | The UUID of the VNF which is stored in the OSM vnfrs |
| 443 | collection in Mongo. |
| 444 | |
| Dario Faccin | 42c4ba2 | 2023-04-14 10:24:38 +0200 | [diff] [blame] | 445 | state : VnfInstantiationState |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 446 | A representation of the VNF instantiation state (NOT_INSTANTIATED or INSTANTIATED). |
| 447 | |
| 448 | """ |
| 449 | |
| 450 | vnfr_uuid: str |
| 451 | state: VnfInstantiationState |
| 452 | |
| 453 | |
| 454 | @dataclass |
| 455 | class GetTaskQueueInput: |
| 456 | """ |
| Gulsum Atici | 56e41a5 | 2023-04-07 00:04:28 +0300 | [diff] [blame] | 457 | Input dataclass for get task queue activity. |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 458 | |
| 459 | Attributes: |
| 460 | ----------- |
| 461 | vnfr_uuid : str |
| 462 | The UUID of the VNF which is stored in the OSM vnfrs |
| 463 | collection in Mongo. |
| 464 | |
| 465 | """ |
| 466 | |
| 467 | vnfr_uuid: str |
| 468 | |
| 469 | |
| 470 | @dataclass |
| 471 | class GetTaskQueueOutput: |
| 472 | """ |
| 473 | Output dataclass for get task queue activity. |
| 474 | |
| 475 | Attributes: |
| 476 | ----------- |
| 477 | task_queue : str |
| 478 | Name of the queue which is used to Deploy VNF. |
| 479 | """ |
| 480 | |
| 481 | task_queue: str |
| Gulsum Atici | 56e41a5 | 2023-04-07 00:04:28 +0300 | [diff] [blame] | 482 | |
| 483 | |
| 484 | @dataclass |
| 485 | class GetVnfDetailsInput: |
| 486 | """ |
| 487 | Input dataclass for get vnf details activity. |
| 488 | |
| 489 | Attributes: |
| 490 | ----------- |
| 491 | vnfr_uuid : str |
| 492 | The UUID of the VNF which is stored in the OSM vnfrs |
| 493 | collection in Mongo. |
| 494 | """ |
| 495 | |
| 496 | vnfr_uuid: str |
| 497 | |
| 498 | |
| 499 | @dataclass |
| 500 | class GetVnfDetailsOutput: |
| 501 | """ |
| 502 | Output dataclass for get vnf details activity. |
| 503 | |
| 504 | Attributes: |
| 505 | ----------- |
| 506 | vnfr : dict |
| 507 | VNF record retrieved from Database. |
| 508 | |
| 509 | vnfd : dict |
| 510 | VNF descriptor retrieved from Database. |
| 511 | """ |
| 512 | |
| 513 | vnfr: dict |
| 514 | vnfd: dict |