| 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 |
| Daniel Arndt | 58076ca | 2023-04-19 14:43:26 -0300 | [diff] [blame] | 20 | from typing import List |
| Mark Beierl | b808fea | 2023-03-22 10:32:45 -0400 | [diff] [blame] | 21 | |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 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 | |
| Mark Beierl | fd2324b | 2023-03-29 17:28:49 +0000 | [diff] [blame] | 64 | ####################################################################################### |
| Mark Beierl | a8d016d | 2023-03-23 10:24:59 +0000 | [diff] [blame] | 65 | # Workflow Dataclasses |
| 66 | |
| 67 | |
| 68 | @dataclass |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 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 | """ |
| Mark Beierl | 30e0507 | 2023-03-28 18:04:47 +0000 | [diff] [blame] | 85 | |
| Mark Beierl | a8d016d | 2023-03-23 10:24:59 +0000 | [diff] [blame] | 86 | vim_uuid: str |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 87 | op_id: str |
| Mark Beierl | a8d016d | 2023-03-23 10:24:59 +0000 | [diff] [blame] | 88 | |
| 89 | |
| Mark Beierl | 248cb40 | 2023-04-05 20:01:05 +0000 | [diff] [blame] | 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 | |
| Patricia Reinoso | 36a62b8 | 2023-03-31 11:22:42 +0000 | [diff] [blame] | 106 | @dataclass |
| Patricia Reinoso | 36a62b8 | 2023-03-31 11:22:42 +0000 | [diff] [blame] | 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 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 Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 143 | @dataclass |
| 144 | class 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 Faccin | aad0f78 | 2023-04-17 16:57:48 +0200 | [diff] [blame] | 154 | model_name: str |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 155 | |
| 156 | """ |
| 157 | |
| 158 | vnfr_uuid: str |
| Dario Faccin | aad0f78 | 2023-04-17 16:57:48 +0200 | [diff] [blame] | 159 | model_name: str |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 160 | |
| 161 | |
| Mark Beierl | fd2324b | 2023-03-29 17:28:49 +0000 | [diff] [blame] | 162 | ####################################################################################### |
| Mark Beierl | a8d016d | 2023-03-23 10:24:59 +0000 | [diff] [blame] | 163 | # Activity Dataclasses |
| 164 | |
| Mark Beierl | b808fea | 2023-03-22 10:32:45 -0400 | [diff] [blame] | 165 | |
| Mark Beierl | 248cb40 | 2023-04-05 20:01:05 +0000 | [diff] [blame] | 166 | @dataclass |
| 167 | class 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 Beierl | b808fea | 2023-03-22 10:32:45 -0400 | [diff] [blame] | 204 | @dataclass |
| 205 | class TestVimConnectivityInput: |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 206 | """ |
| 207 | Input dataclass for the Test Vim Connectivity Ativity |
| Mark Beierl | b808fea | 2023-03-22 10:32:45 -0400 | [diff] [blame] | 208 | |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 209 | 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 Beierl | 30e0507 | 2023-03-28 18:04:47 +0000 | [diff] [blame] | 215 | |
| Mark Beierl | b808fea | 2023-03-22 10:32:45 -0400 | [diff] [blame] | 216 | vim_uuid: str |
| 217 | |
| Mark Beierl | a8d016d | 2023-03-23 10:24:59 +0000 | [diff] [blame] | 218 | |
| 219 | @dataclass |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 220 | class 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 Beierl | fd2324b | 2023-03-29 17:28:49 +0000 | [diff] [blame] | 230 | operational_state : VimState |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 231 | 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 Beierl | 30e0507 | 2023-03-28 18:04:47 +0000 | [diff] [blame] | 239 | |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 240 | vim_uuid: str |
| Mark Beierl | fd2324b | 2023-03-29 17:28:49 +0000 | [diff] [blame] | 241 | operational_state: VimState |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 242 | message: str |
| 243 | |
| 244 | |
| 245 | @dataclass |
| 246 | class 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 Beierl | fd2324b | 2023-03-29 17:28:49 +0000 | [diff] [blame] | 261 | op_state : VimOperationState |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 262 | 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 Beierl | 30e0507 | 2023-03-28 18:04:47 +0000 | [diff] [blame] | 270 | |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 271 | vim_uuid: str |
| 272 | op_id: str |
| Mark Beierl | fd2324b | 2023-03-29 17:28:49 +0000 | [diff] [blame] | 273 | op_state: VimOperationState |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 274 | message: str |
| Mark Beierl | 30e0507 | 2023-03-28 18:04:47 +0000 | [diff] [blame] | 275 | |
| 276 | |
| 277 | @dataclass |
| 278 | class 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 Reinoso | 36a62b8 | 2023-03-31 11:22:42 +0000 | [diff] [blame] | 291 | |
| 292 | |
| 293 | @dataclass |
| 294 | class 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 Reinoso | 36a62b8 | 2023-03-31 11:22:42 +0000 | [diff] [blame] | 308 | @dataclass |
| 309 | class 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 Reinoso | 4ddf2c7 | 2023-04-12 15:57:25 +0000 | [diff] [blame] | 335 | class ModelInfo: |
| Patricia Reinoso | 36a62b8 | 2023-03-31 11:22:42 +0000 | [diff] [blame] | 336 | """ |
| Patricia Reinoso | 4ddf2c7 | 2023-04-12 15:57:25 +0000 | [diff] [blame] | 337 | Contains the information related to a model. |
| Patricia Reinoso | 36a62b8 | 2023-03-31 11:22:42 +0000 | [diff] [blame] | 338 | |
| 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 Reinoso | 4ddf2c7 | 2023-04-12 15:57:25 +0000 | [diff] [blame] | 346 | Name of the Juju model used to deploy charms. |
| Patricia Reinoso | 36a62b8 | 2023-03-31 11:22:42 +0000 | [diff] [blame] | 347 | """ |
| 348 | |
| 349 | vim_uuid: str |
| 350 | model_name: str |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 351 | |
| 352 | |
| 353 | @dataclass |
| Mark Beierl | eebe8f5 | 2023-04-11 21:01:22 +0000 | [diff] [blame] | 354 | class 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 Beierl | e65a9db | 2023-04-18 14:33:05 +0000 | [diff] [blame] | 383 | class ChangeVnfStateInput: |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 384 | """ |
| Gulsum Atici | 56e41a5 | 2023-04-07 00:04:28 +0300 | [diff] [blame] | 385 | Input dataclass for changing VNF State. |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 386 | |
| 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 Faccin | 42c4ba2 | 2023-04-14 10:24:38 +0200 | [diff] [blame] | 393 | state : VnfState |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 394 | A representation of the VNF state (STOPPED or STARTED). |
| 395 | """ |
| 396 | |
| 397 | vnfr_uuid: str |
| 398 | state: VnfState |
| 399 | |
| 400 | |
| 401 | @dataclass |
| Dario Faccin | 42c4ba2 | 2023-04-14 10:24:38 +0200 | [diff] [blame] | 402 | class ChangeVnfInstantiationStateInput: |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 403 | """ |
| Gulsum Atici | 56e41a5 | 2023-04-07 00:04:28 +0300 | [diff] [blame] | 404 | Input dataclass for changing VNF Instantiation State. |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 405 | |
| 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 Faccin | 42c4ba2 | 2023-04-14 10:24:38 +0200 | [diff] [blame] | 412 | state : VnfInstantiationState |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 413 | 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 |
| 422 | class GetTaskQueueInput: |
| 423 | """ |
| Gulsum Atici | 56e41a5 | 2023-04-07 00:04:28 +0300 | [diff] [blame] | 424 | Input dataclass for get task queue activity. |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 425 | |
| 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 |
| 438 | class 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 Atici | 56e41a5 | 2023-04-07 00:04:28 +0300 | [diff] [blame] | 449 | |
| 450 | |
| 451 | @dataclass |
| 452 | class 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 |
| 467 | class 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 Arndt | 58076ca | 2023-04-19 14:43:26 -0300 | [diff] [blame] | 482 | |
| 483 | |
| 484 | @dataclass |
| 485 | class 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 |
| 497 | class 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] |