From: Gulsum Atici Date: Thu, 23 Mar 2023 12:59:56 +0000 (+0300) Subject: Updating VimCreateInput and UpdateVimStatusInput Dataclass X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=654c377eb49aff6b6c11340f91b69ee45da7fbc3;p=osm%2Fcommon.git Updating VimCreateInput and UpdateVimStatusInput Dataclass Change-Id: I2e0e0ebb943dbdf0a5ae7b33b36fda93b999d9d8 Signed-off-by: Gulsum Atici Signed-off-by: Mark Beierl --- diff --git a/osm_common/dataclasses/temporal_dataclasses.py b/osm_common/dataclasses/temporal_dataclasses.py index b5718b3..de04186 100644 --- a/osm_common/dataclasses/temporal_dataclasses.py +++ b/osm_common/dataclasses/temporal_dataclasses.py @@ -21,8 +21,24 @@ from dataclasses import dataclass @dataclass -class VimCreateInput: +class VimOperationInput: + """ + Input dataclass for workflows that perform operations + (create, update, delete) on VIMs. + + Attributes: + ----------- + vim_uuid : str + The UUID of the VIM account as stored in the OSM vim + collection in Mongo + + op_id: str + The operation (task) id for this workflow. This is used + by the workflow at the end to update the status of the + operation in Mongo vim collection. + """ vim_uuid: str + op_id: str # Activity Dataclasses @@ -30,12 +46,69 @@ class VimCreateInput: @dataclass class TestVimConnectivityInput: + """ + Input dataclass for the Test Vim Connectivity Ativity + + Attributes: + ----------- + vim_uuid : str + The UUID of the VIM account as stored in the OSM vim + collection in Mongo + """ + vim_uuid: str + + +@dataclass +class UpdateVimStateInput: + """ + Input dataclass for updating VIM state in the DB - """Docstring for why we use this""" + Attributes: + ----------- + vim_uuid : str + The UUID of the VIM account as stored in the OSM vim + collection in Mongo + operational_state : str + A representation of the operational state (ENABLED or ERROR) + of the VIM. + + message : str + Human readable message providing additional details to the + operational state, such as the error message associated + with the ERROR operational_state. + """ vim_uuid: str + operational_state: str + message: str @dataclass -class UpdateVimStatusInput: - db_update_info: dict +class UpdateVimOperationStateInput: + """ + Input dataclass for updating VIM Operations in the Mongo VIM + collection. + + Attributes: + ----------- + vim_uuid : str + The UUID of the VIM account as stored in the OSM vim + collection in Mongo + + op_id: str + The operation (task) id for this workflow. This is used + to update the status of the operation in Mongo vim collection. + + op_state : str + A representation of the state of the specified operation id, + such as COMPLETED, or FAILED. + + message : str + Human readable message providing additional details to the + operation state, such as the error message explaining why + the operation failed. + """ + vim_uuid: str + op_id: str + op_state: str + message: str diff --git a/osm_common/temporal_constants.py b/osm_common/temporal_constants.py index 7290390..64569ff 100644 --- a/osm_common/temporal_constants.py +++ b/osm_common/temporal_constants.py @@ -19,7 +19,8 @@ LCM_TASK_QUEUE = "lcm-task-queue" # Activities ACTIVITY_TEST_VIM_CONNECTIVITY = "test-vim-connectivity" -ACTIVITY_UPDATE_VIM_STATUS = "update-vim-status" +ACTIVITY_UPDATE_VIM_OPERATION_STATE = "update_operation_state" +ACTIVITY_UPDATE_VIM_STATE = "update-vim-state" # Workflows WORKFLOW_VIM_CREATE = "vim-create" diff --git a/osm_common/temporal_exceptions.py b/osm_common/temporal_exceptions.py index 275bc45..df730a4 100644 --- a/osm_common/temporal_exceptions.py +++ b/osm_common/temporal_exceptions.py @@ -13,29 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -from functools import wraps - from temporalio.exceptions import ApplicationError -class RetryableException(ApplicationError): +class NonRetryableException(ApplicationError): def __init__(self, message): - super().__init__(message, non_retryable=False) - + super().__init__(message, non_retryable=True) -def wrap_exceptions(error_message="Unhandled exception"): - def Inner(func): - @wraps(func) - async def wrapper(*args, **kwargs): - try: - return await func(*args, **kwargs) - except Exception as err: - if isinstance(err, RetryableException): - raise err - raise ApplicationError( - f"{error_message}: {str(err)}", non_retryable=True - ) from err - return wrapper - - return Inner +class TimeOutError(ApplicationError): + def __init__(self, message): + super().__init__(message)