OSMENG-992 - Implement create model activity
[osm/common.git] / osm_common / dataclasses / temporal_dataclasses.py
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
19 from enum import auto, IntEnum
20
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
63 #######################################################################################
64 # Workflow Dataclasses
65
66
67 @dataclass
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 """
84
85 vim_uuid: str
86 op_id: str
87
88
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
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
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 """
182 Input dataclass for workflow that instantiates a VNF.
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
195 #######################################################################################
196 # Activity Dataclasses
197
198
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
237 @dataclass
238 class TestVimConnectivityInput:
239 """
240 Input dataclass for the Test Vim Connectivity Ativity
241
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 """
248
249 vim_uuid: str
250
251
252 @dataclass
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
263 operational_state : VimState
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 """
272
273 vim_uuid: str
274 operational_state: VimState
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
294 op_state : VimOperationState
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 """
303
304 vim_uuid: str
305 op_id: str
306 op_state: VimOperationState
307 message: str
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
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
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
368 class ModelInfo:
369 """
370 Contains the information related to a model.
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
379 Name of the Juju model used to deploy charms.
380 """
381
382 vim_uuid: str
383 model_name: str
384
385
386 @dataclass
387 class ChangeNFStateInput:
388 """
389 Input dataclass for creating a Juju Model.
390
391 Attributes:
392 -----------
393 vnfr_uuid : str
394 The UUID of the VNF which is stored in the OSM vnfrs
395 collection in Mongo.
396
397 nf_state : VnfState
398 A representation of the VNF state (STOPPED or STARTED).
399 """
400
401 vnfr_uuid: str
402 state: VnfState
403
404
405 @dataclass
406 class ChangeNFInstantiationStateInput:
407 """
408 Input dataclass for creating a Juju Model.
409
410 Attributes:
411 -----------
412 vnfr_uuid : str
413 The UUID of the VNF which is stored in the OSM vnfrs
414 collection in Mongo.
415
416 nf_instantiation_state : VnfInstantiationState
417 A representation of the VNF instantiation state (NOT_INSTANTIATED or INSTANTIATED).
418
419 """
420
421 vnfr_uuid: str
422 state: VnfInstantiationState
423
424
425 @dataclass
426 class GetTaskQueueInput:
427 """
428 Input dataclass for creating a Juju Model.
429
430 Attributes:
431 -----------
432 vnfr_uuid : str
433 The UUID of the VNF which is stored in the OSM vnfrs
434 collection in Mongo.
435
436 """
437
438 vnfr_uuid: str
439
440
441 @dataclass
442 class GetTaskQueueOutput:
443 """
444 Output dataclass for get task queue activity.
445
446 Attributes:
447 -----------
448 task_queue : str
449 Name of the queue which is used to Deploy VNF.
450 """
451
452 task_queue: str