OSMENG-992 - Implement create model activity
[osm/common.git] / osm_common / dataclasses / temporal_dataclasses.py
index de04186..a0e3d19 100644 (file)
 #######################################################################################
 
 from dataclasses import dataclass
 #######################################################################################
 
 from dataclasses import dataclass
+from enum import auto, IntEnum
 
 
+
+#######################################################################################
+# Defining States
+class VimState(IntEnum):
+    PROCESSING = auto()
+    ENABLED = auto()
+    ERROR = auto()
+
+
+class VimOperationState(IntEnum):
+    COMPLETED = auto()
+    FAILED = auto()
+
+
+class NsState(IntEnum):
+    PROCESSING = auto()
+    INSTANTIATED = auto()
+    ERROR = auto()
+
+
+class VnfLcmOperationState(IntEnum):
+    PROCESSING = auto()
+    COMPLETED = auto()
+    FAILED = auto()
+
+
+class VnfInstantiationState(IntEnum):
+    NOT_INSTANTIATED = auto()
+    INSTANTIATED = auto()
+
+
+class VnfState(IntEnum):
+    STOPPED = auto()
+    STARTED = auto()
+
+
+class LcmOperationState(IntEnum):
+    PROCESSING = auto()
+    COMPLETED = auto()
+    FAILED = auto()
+
+
+#######################################################################################
 # Workflow Dataclasses
 
 
 # Workflow Dataclasses
 
 
@@ -37,13 +81,159 @@ class VimOperationInput:
         by the workflow at the end to update the status of the
         operation in Mongo vim collection.
     """
         by the workflow at the end to update the status of the
         operation in Mongo vim collection.
     """
+
     vim_uuid: str
     op_id: str
 
 
     vim_uuid: str
     op_id: str
 
 
+@dataclass
+class NsLcmOperationInput:
+    """
+    Input dataclass for workflows that run as LCM operations.
+
+    Attributes:
+    -----------
+
+    nslcmop: dict
+        A dictionary representing the nslcmop record from the
+        database.
+    """
+
+    nslcmop: dict
+
+
+@dataclass
+class NsInstantiateInput:
+    """
+    Input dataclass for workflow that instantiate NS.
+
+    Attributes:
+    -----------
+    ns_uuid : str
+        The UUID of the NS as stored in the OSM nsr
+        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.
+    """
+
+    ns_uuid: str
+    op_id: str
+
+
+@dataclass
+class CharmInfo:
+    """
+    Input dataclass for
+
+    Attributes:
+    -----------
+    app_name : str
+
+    channel: str
+
+    entity_url: str
+    """
+
+    app_name: str
+    channel: str
+    entity_url: str
+
+
+@dataclass
+class VduInstantiateInput:
+    """
+    Input dataclass for workflow that instantiates a VDU.
+
+    vim_uuid: str
+
+    model_name: str
+
+    charm_info : CharmInfo
+
+    """
+
+    vim_uuid: str
+    model_name: str
+    charm_info: CharmInfo
+
+
+@dataclass
+class VnfInstantiateInput:
+    """
+    Input dataclass for workflow that instantiates a VNF.
+
+    Attributes:
+    -----------
+    vnfr_uuid : str
+        The UUID of the VNF which is stored in the OSM vnfrs
+        collection in Mongo.
+
+    """
+
+    vnfr_uuid: str
+
+
+@dataclass
+class PrepareVnfInput:
+    """
+    Input dataclass for workflow that instantiates a VNF.
+
+    Attributes:
+    -----------
+    vnfr_uuid : str
+        The UUID of the VNF which is stored in the OSM vnfrs
+        collection in Mongo.
+
+    """
+
+    vnfr_uuid: str
+
+
+#######################################################################################
 # Activity Dataclasses
 
 
 # Activity Dataclasses
 
 
+@dataclass
+class UpdateLcmOperationStateInput:
+    """
+    Input dataclass for updating LCM Operations in the Mongo nslcmops
+    collection.  The following attributes will be updated automatically
+      - statusEnteredTime
+      - _admin.modified
+
+    Attributes:
+    -----------
+    op_id: str
+        The operation (task) id for this activity.  This is the key
+        to the record in nslcmops collection that will be updated.
+
+    op_state : LcmOperationState
+        A representation of the state of the specified operation id,
+        such as PROCESSING, COMPLETED, or FAILED.
+
+    stage: str
+        Human readable checkpoint message, intended only to give the
+        user feedback.
+
+    error_message: str
+        Human readable error message if any failure occurred.
+
+    detailed_status : str
+        Human readable message providing additional details to the
+        operation state, such as the error message explaining why
+        the operation failed.
+    """
+
+    op_id: str
+    op_state: LcmOperationState
+    stage: str
+    error_message: str
+    detailed_status: str
+
+
 @dataclass
 class TestVimConnectivityInput:
     """
 @dataclass
 class TestVimConnectivityInput:
     """
@@ -55,6 +245,7 @@ class TestVimConnectivityInput:
         The UUID of the VIM account as stored in the OSM vim
         collection in Mongo
     """
         The UUID of the VIM account as stored in the OSM vim
         collection in Mongo
     """
+
     vim_uuid: str
 
 
     vim_uuid: str
 
 
@@ -69,7 +260,7 @@ class UpdateVimStateInput:
         The UUID of the VIM account as stored in the OSM vim
         collection in Mongo
 
         The UUID of the VIM account as stored in the OSM vim
         collection in Mongo
 
-    operational_state : str
+    operational_state : VimState
         A representation of the operational state (ENABLED or ERROR)
         of the VIM.
 
         A representation of the operational state (ENABLED or ERROR)
         of the VIM.
 
@@ -78,8 +269,9 @@ class UpdateVimStateInput:
         operational state, such as the error message associated
         with the ERROR operational_state.
     """
         operational state, such as the error message associated
         with the ERROR operational_state.
     """
+
     vim_uuid: str
     vim_uuid: str
-    operational_state: str
+    operational_state: VimState
     message: str
 
 
     message: str
 
 
@@ -99,7 +291,7 @@ class UpdateVimOperationStateInput:
         The operation (task) id for this workflow.  This is used
         to update the status of the operation in Mongo vim collection.
 
         The operation (task) id for this workflow.  This is used
         to update the status of the operation in Mongo vim collection.
 
-    op_state : str
+    op_state : VimOperationState
         A representation of the state of the specified operation id,
         such as COMPLETED, or FAILED.
 
         A representation of the state of the specified operation id,
         such as COMPLETED, or FAILED.
 
@@ -108,7 +300,153 @@ class UpdateVimOperationStateInput:
         operation state, such as the error message explaining why
         the operation failed.
     """
         operation state, such as the error message explaining why
         the operation failed.
     """
+
     vim_uuid: str
     op_id: str
     vim_uuid: str
     op_id: str
-    op_state: str
+    op_state: VimOperationState
     message: str
     message: str
+
+
+@dataclass
+class DeleteVimInput:
+    """
+    Input dataclass for deleting vim record from the database
+
+    Attributes:
+    -----------
+    vim_uuid : str
+        The UUID of the VIM account as stored in the OSM vim
+        collection in Mongo
+
+    """
+
+    vim_uuid: str
+
+
+@dataclass
+class DeployNsInput:
+    """
+    Input dataclass for
+
+    Attributes:
+    -----------
+    ns_uuid : str
+        The UUID of the NS as stored in the OSM nsr
+        collection in Mongo
+    """
+
+    ns_uuid: str
+
+
+@dataclass
+class UpdateNsStateInput:
+    """
+    Input dataclass for updating NS state in the DB
+
+    Attributes:
+    -----------
+    ns_uuid : str
+        The UUID of the NS as stored in the OSM ns
+        collection in Mongo
+
+    operational_state : NsState
+        A representation of the operational state (ENABLED or ERROR)
+        of the NS.
+
+    message : str
+        Human readable message providing additional details to the
+        operational state, such as the error message associated
+        with the ERROR operational_state.
+    """
+
+    ns_uuid: str
+    state: NsState
+    message: str
+
+
+@dataclass
+class ModelInfo:
+    """
+    Contains the information related to a model.
+
+    Attributes:
+    -----------
+    vim_uuid : str
+        The UUID of the VIM as stored in the OSM vim_accounts
+        collection in Mongo.
+
+    model_name : str
+        Name of the Juju model used to deploy charms.
+    """
+
+    vim_uuid: str
+    model_name: str
+
+
+@dataclass
+class ChangeNFStateInput:
+    """
+    Input dataclass for creating a Juju Model.
+
+    Attributes:
+    -----------
+    vnfr_uuid : str
+        The UUID of the VNF which is stored in the OSM vnfrs
+        collection in Mongo.
+
+    nf_state : VnfState
+        A representation of the VNF state (STOPPED or STARTED).
+    """
+
+    vnfr_uuid: str
+    state: VnfState
+
+
+@dataclass
+class ChangeNFInstantiationStateInput:
+    """
+    Input dataclass for creating a Juju Model.
+
+    Attributes:
+    -----------
+    vnfr_uuid : str
+        The UUID of the VNF which is stored in the OSM vnfrs
+        collection in Mongo.
+
+    nf_instantiation_state : VnfInstantiationState
+        A representation of the VNF instantiation state (NOT_INSTANTIATED or INSTANTIATED).
+
+    """
+
+    vnfr_uuid: str
+    state: VnfInstantiationState
+
+
+@dataclass
+class GetTaskQueueInput:
+    """
+    Input dataclass for creating a Juju Model.
+
+    Attributes:
+    -----------
+    vnfr_uuid : str
+        The UUID of the VNF which is stored in the OSM vnfrs
+        collection in Mongo.
+
+    """
+
+    vnfr_uuid: str
+
+
+@dataclass
+class GetTaskQueueOutput:
+    """
+    Output dataclass for get task queue activity.
+
+    Attributes:
+    -----------
+    task_queue : str
+        Name of the queue which is used to Deploy VNF.
+    """
+
+    task_queue: str