X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=o2dms%2Fdomain%2Fdms.py;h=3555e1ce712d7218ed7b894a5c03c55490778f35;hb=0daf5c4f160ec3fde4eb849fbd59ff75eff8e76c;hp=783231f3474e3bd336512662d62b7ced8328a676;hpb=5ad82f634e2f10aaeccf1d2420fafc63e2d0056e;p=pti%2Fo2.git diff --git a/o2dms/domain/dms.py b/o2dms/domain/dms.py index 783231f..3555e1c 100644 --- a/o2dms/domain/dms.py +++ b/o2dms/domain/dms.py @@ -13,14 +13,16 @@ # limitations under the License. from __future__ import annotations +from o2dms.domain import events +from o2dms.domain.states import NfDeploymentState -from o2common.domain.base import AgRoot +from o2common.domain.base import AgRoot, Serializer -class NfDeploymentDesc(AgRoot): +class NfDeploymentDesc(AgRoot, Serializer): def __init__(self, id: str, name: str, dmsId: str, description: str = '', inputParams: str = '', outputParams: str = '', - artifacturl: str = '') -> None: + artifactRepoUrl: str = '', artifactName: str = '') -> None: super().__init__() self.id = id self.version_number = 0 @@ -29,11 +31,13 @@ class NfDeploymentDesc(AgRoot): self.description = description self.inputParams = inputParams self.outputParams = outputParams - self.artifactUrl = artifacturl + self.artifactRepoUrl = artifactRepoUrl + self.artifactName = artifactName + self.status = 0 # self.extensions = [] -class NfDeployment(AgRoot): +class NfDeployment(AgRoot, Serializer): def __init__(self, id: str, name: str, dmsId: str, description: str = '', descriptorId: str = '', parentId: str = '',) -> None: super().__init__() @@ -44,10 +48,22 @@ class NfDeployment(AgRoot): self.description = description self.descriptorId = descriptorId self.parentDeploymentId = parentId - self.status = 0 + self.status = NfDeploymentState.Initial + + def transit_state(self, state: NfDeploymentState): + if (self.status != state): + self._append_event(self.status, state) + self.status = state + + def _append_event(self, fromState, toState): + if not hasattr(self, "events"): + self.events = [] + self.events.append( + events.NfDeploymentStateChanged( + NfDeploymentId=self.id, FromState=fromState, ToState=toState)) -class NfOCloudVResource(AgRoot): +class NfOCloudVResource(AgRoot, Serializer): def __init__(self, id: str, name: str, dmsId: str, description: str = '', descriptorId: str = '', nfDeploymentId: str = '', vresourceType: int = 0,) -> None: