X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=o2dms%2Fdomain%2Fdms.py;fp=o2dms%2Fdomain%2Fdms.py;h=d3d908ea71a7eca91c7232c02e39685bf502a8fd;hb=defe8209b3628593c186487857fe02586d7e1503;hp=2a8c144d5ac289a95a34274d015faeb76ffc6641;hpb=1c5999c04742b704a3b78fe9acecba09d41f0d11;p=pti%2Fo2.git diff --git a/o2dms/domain/dms.py b/o2dms/domain/dms.py index 2a8c144..d3d908e 100644 --- a/o2dms/domain/dms.py +++ b/o2dms/domain/dms.py @@ -1,93 +1,93 @@ -# Copyright (C) 2021 Wind River Systems, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from __future__ import annotations -# from os import stat -import json -from o2dms.domain import events -from o2dms.domain.states import NfDeploymentState - -from o2common.domain.base import AgRoot, Serializer - - -class NfDeploymentDesc(AgRoot, Serializer): - def __init__(self, id: str, name: str, dmsId: str, description: str = '', - inputParams: str = '', outputParams: str = '', - artifactRepoUrl: str = '', artifactName: str = '') -> None: - super().__init__() - self.id = id - self.version_number = 0 - self.deploymentManagerId = dmsId - self.name = name - self.description = description - self.artifactRepoUrl = artifactRepoUrl - self.artifactName = artifactName - self.status = 0 - - if type(inputParams) is str: - inputParams = json.loads(inputParams) - self.inputParams = json.dumps(inputParams) - - if type(outputParams) is str: - outputParams = json.loads(outputParams) - self.outputParams = json.dumps(outputParams) - - # self.extensions = [] - - -class NfDeployment(AgRoot, Serializer): - def __init__(self, id: str, name: str, dmsId: str, description: str = '', - descriptorId: str = '', parentId: str = '',) -> None: - super().__init__() - self.id = id - self.version_number = 0 - self.deploymentManagerId = dmsId - self.name = name - self.description = description - self.descriptorId = descriptorId - self.parentDeploymentId = parentId - self.status = NfDeploymentState.Initial - - def transit_state(self, state: NfDeploymentState): - if (self.status != state): - self._append_event(self.status, state) - # self.status = state - - def set_state(self, state: NfDeploymentState): - if (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, Serializer): - def __init__(self, id: str, name: str, dmsId: str, description: str = '', - descriptorId: str = '', nfDeploymentId: str = '', - vresourceType: int = 0,) -> None: - super().__init__() - self.id = id - self.version_number = 0 - self.deploymentManagerId = dmsId - self.name = name - self.description = description - self.descriptorId = descriptorId - self.nfDeploymentId = nfDeploymentId - self.vresourceType = vresourceType - self.status = 0 - self.metadata = [] +# Copyright (C) 2021 Wind River Systems, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import annotations +# from os import stat +import json +from o2dms.domain import events +from o2dms.domain.states import NfDeploymentState + +from o2common.domain.base import AgRoot, Serializer + + +class NfDeploymentDesc(AgRoot, Serializer): + def __init__(self, id: str, name: str, dmsId: str, description: str = '', + inputParams: str = '', outputParams: str = '', + artifactRepoUrl: str = '', artifactName: str = '') -> None: + super().__init__() + self.id = id + self.version_number = 0 + self.deploymentManagerId = dmsId + self.name = name + self.description = description + self.artifactRepoUrl = artifactRepoUrl + self.artifactName = artifactName + self.status = 0 + + if type(inputParams) is str: + inputParams = json.loads(inputParams) + self.inputParams = json.dumps(inputParams) + + if type(outputParams) is str: + outputParams = json.loads(outputParams) + self.outputParams = json.dumps(outputParams) + + # self.extensions = [] + + +class NfDeployment(AgRoot, Serializer): + def __init__(self, id: str, name: str, dmsId: str, description: str = '', + descriptorId: str = '', parentId: str = '',) -> None: + super().__init__() + self.id = id + self.version_number = 0 + self.deploymentManagerId = dmsId + self.name = name + self.description = description + self.descriptorId = descriptorId + self.parentDeploymentId = parentId + self.status = NfDeploymentState.Initial + + def transit_state(self, state: NfDeploymentState): + if (self.status != state): + self._append_event(self.status, state) + # self.status = state + + def set_state(self, state: NfDeploymentState): + if (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, Serializer): + def __init__(self, id: str, name: str, dmsId: str, description: str = '', + descriptorId: str = '', nfDeploymentId: str = '', + vresourceType: int = 0,) -> None: + super().__init__() + self.id = id + self.version_number = 0 + self.deploymentManagerId = dmsId + self.name = name + self.description = description + self.descriptorId = descriptorId + self.nfDeploymentId = nfDeploymentId + self.vresourceType = vresourceType + self.status = 0 + self.metadata = []