1 # Copyright (C) 2021 Wind River Systems, Inc.
\r
3 # Licensed under the Apache License, Version 2.0 (the "License");
\r
4 # you may not use this file except in compliance with the License.
\r
5 # You may obtain a copy of the License at
\r
7 # http://www.apache.org/licenses/LICENSE-2.0
\r
9 # Unless required by applicable law or agreed to in writing, software
\r
10 # distributed under the License is distributed on an "AS IS" BASIS,
\r
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
12 # See the License for the specific language governing permissions and
\r
13 # limitations under the License.
\r
15 from __future__ import annotations
\r
16 # from os import stat
\r
17 from o2dms.domain import events
\r
18 from o2dms.domain.states import NfDeploymentState
\r
20 from o2common.domain.base import AgRoot, Serializer
\r
23 class NfDeploymentDesc(AgRoot, Serializer):
\r
24 def __init__(self, id: str, name: str, dmsId: str, description: str = '',
\r
25 inputParams: str = '', outputParams: str = '',
\r
26 artifactRepoUrl: str = '', artifactName: str = '') -> None:
\r
29 self.version_number = 0
\r
30 self.deploymentManagerId = dmsId
\r
32 self.description = description
\r
33 self.inputParams = inputParams
\r
34 self.outputParams = outputParams
\r
35 self.artifactRepoUrl = artifactRepoUrl
\r
36 self.artifactName = artifactName
\r
38 # self.extensions = []
\r
41 class NfDeployment(AgRoot, Serializer):
\r
42 def __init__(self, id: str, name: str, dmsId: str, description: str = '',
\r
43 descriptorId: str = '', parentId: str = '',) -> None:
\r
46 self.version_number = 0
\r
47 self.deploymentManagerId = dmsId
\r
49 self.description = description
\r
50 self.descriptorId = descriptorId
\r
51 self.parentDeploymentId = parentId
\r
52 self.status = NfDeploymentState.Initial
\r
54 def transit_state(self, state: NfDeploymentState):
\r
55 if (self.status != state):
\r
56 self._append_event(self.status, state)
\r
57 # self.status = state
\r
59 def set_state(self, state: NfDeploymentState):
\r
60 if (self.status != state):
\r
63 def _append_event(self, fromState, toState):
\r
64 if not hasattr(self, "events"):
\r
67 events.NfDeploymentStateChanged(
\r
68 NfDeploymentId=self.id, FromState=fromState, ToState=toState))
\r
71 class NfOCloudVResource(AgRoot, Serializer):
\r
72 def __init__(self, id: str, name: str, dmsId: str, description: str = '',
\r
73 descriptorId: str = '', nfDeploymentId: str = '',
\r
74 vresourceType: int = 0,) -> None:
\r
77 self.version_number = 0
\r
78 self.deploymentManagerId = dmsId
\r
80 self.description = description
\r
81 self.descriptorId = descriptorId
\r
82 self.nfDeploymentId = nfDeploymentId
\r
83 self.vresourceType = vresourceType
\r