| 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 | |
| Dario Faccin | aad0f78 | 2023-04-17 16:57:48 +0200 | [diff] [blame^] | 174 | model_name: str |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 175 | |
| 176 | """ |
| 177 | |
| 178 | vnfr_uuid: str |
| Dario Faccin | aad0f78 | 2023-04-17 16:57:48 +0200 | [diff] [blame^] | 179 | model_name: str |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 180 | |
| 181 | |
| Mark Beierl | fd2324b | 2023-03-29 17:28:49 +0000 | [diff] [blame] | 182 | ####################################################################################### |
| Mark Beierl | a8d016d | 2023-03-23 10:24:59 +0000 | [diff] [blame] | 183 | # Activity Dataclasses |
| 184 | |
| Mark Beierl | b808fea | 2023-03-22 10:32:45 -0400 | [diff] [blame] | 185 | |
| Mark Beierl | 248cb40 | 2023-04-05 20:01:05 +0000 | [diff] [blame] | 186 | @dataclass |
| 187 | class 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 Beierl | b808fea | 2023-03-22 10:32:45 -0400 | [diff] [blame] | 224 | @dataclass |
| 225 | class TestVimConnectivityInput: |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 226 | """ |
| 227 | Input dataclass for the Test Vim Connectivity Ativity |
| Mark Beierl | b808fea | 2023-03-22 10:32:45 -0400 | [diff] [blame] | 228 | |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 229 | 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 Beierl | 30e0507 | 2023-03-28 18:04:47 +0000 | [diff] [blame] | 235 | |
| Mark Beierl | b808fea | 2023-03-22 10:32:45 -0400 | [diff] [blame] | 236 | vim_uuid: str |
| 237 | |
| Mark Beierl | a8d016d | 2023-03-23 10:24:59 +0000 | [diff] [blame] | 238 | |
| 239 | @dataclass |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 240 | class 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 Beierl | fd2324b | 2023-03-29 17:28:49 +0000 | [diff] [blame] | 250 | operational_state : VimState |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 251 | 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 Beierl | 30e0507 | 2023-03-28 18:04:47 +0000 | [diff] [blame] | 259 | |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 260 | vim_uuid: str |
| Mark Beierl | fd2324b | 2023-03-29 17:28:49 +0000 | [diff] [blame] | 261 | operational_state: VimState |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 262 | message: str |
| 263 | |
| 264 | |
| 265 | @dataclass |
| 266 | class 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 Beierl | fd2324b | 2023-03-29 17:28:49 +0000 | [diff] [blame] | 281 | op_state : VimOperationState |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 282 | 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 Beierl | 30e0507 | 2023-03-28 18:04:47 +0000 | [diff] [blame] | 290 | |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 291 | vim_uuid: str |
| 292 | op_id: str |
| Mark Beierl | fd2324b | 2023-03-29 17:28:49 +0000 | [diff] [blame] | 293 | op_state: VimOperationState |
| Gulsum Atici | 654c377 | 2023-03-23 15:59:56 +0300 | [diff] [blame] | 294 | message: str |
| Mark Beierl | 30e0507 | 2023-03-28 18:04:47 +0000 | [diff] [blame] | 295 | |
| 296 | |
| 297 | @dataclass |
| 298 | class 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 Reinoso | 36a62b8 | 2023-03-31 11:22:42 +0000 | [diff] [blame] | 311 | |
| 312 | |
| 313 | @dataclass |
| 314 | class 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 Reinoso | 36a62b8 | 2023-03-31 11:22:42 +0000 | [diff] [blame] | 328 | @dataclass |
| 329 | class 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 Reinoso | 4ddf2c7 | 2023-04-12 15:57:25 +0000 | [diff] [blame] | 355 | class ModelInfo: |
| Patricia Reinoso | 36a62b8 | 2023-03-31 11:22:42 +0000 | [diff] [blame] | 356 | """ |
| Patricia Reinoso | 4ddf2c7 | 2023-04-12 15:57:25 +0000 | [diff] [blame] | 357 | Contains the information related to a model. |
| Patricia Reinoso | 36a62b8 | 2023-03-31 11:22:42 +0000 | [diff] [blame] | 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 |
| Patricia Reinoso | 4ddf2c7 | 2023-04-12 15:57:25 +0000 | [diff] [blame] | 366 | Name of the Juju model used to deploy charms. |
| Patricia Reinoso | 36a62b8 | 2023-03-31 11:22:42 +0000 | [diff] [blame] | 367 | """ |
| 368 | |
| 369 | vim_uuid: str |
| 370 | model_name: str |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 371 | |
| 372 | |
| 373 | @dataclass |
| Mark Beierl | eebe8f5 | 2023-04-11 21:01:22 +0000 | [diff] [blame] | 374 | class 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 Beierl | e65a9db | 2023-04-18 14:33:05 +0000 | [diff] [blame] | 403 | class ChangeVnfStateInput: |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 404 | """ |
| Gulsum Atici | 56e41a5 | 2023-04-07 00:04:28 +0300 | [diff] [blame] | 405 | Input dataclass for changing VNF State. |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 406 | |
| 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 Faccin | 42c4ba2 | 2023-04-14 10:24:38 +0200 | [diff] [blame] | 413 | state : VnfState |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 414 | A representation of the VNF state (STOPPED or STARTED). |
| 415 | """ |
| 416 | |
| 417 | vnfr_uuid: str |
| 418 | state: VnfState |
| 419 | |
| 420 | |
| 421 | @dataclass |
| Dario Faccin | 42c4ba2 | 2023-04-14 10:24:38 +0200 | [diff] [blame] | 422 | class ChangeVnfInstantiationStateInput: |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 423 | """ |
| Gulsum Atici | 56e41a5 | 2023-04-07 00:04:28 +0300 | [diff] [blame] | 424 | Input dataclass for changing VNF Instantiation State. |
| 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 | |
| Dario Faccin | 42c4ba2 | 2023-04-14 10:24:38 +0200 | [diff] [blame] | 432 | state : VnfInstantiationState |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 433 | 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 |
| 442 | class GetTaskQueueInput: |
| 443 | """ |
| Gulsum Atici | 56e41a5 | 2023-04-07 00:04:28 +0300 | [diff] [blame] | 444 | Input dataclass for get task queue activity. |
| Gulsum Atici | 2f081e4 | 2023-04-06 13:41:36 +0300 | [diff] [blame] | 445 | |
| 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 |
| 458 | class 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 Atici | 56e41a5 | 2023-04-07 00:04:28 +0300 | [diff] [blame] | 469 | |
| 470 | |
| 471 | @dataclass |
| 472 | class 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 |
| 487 | class 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 |