OSMENG-1096 OSMENG-1097: Delete application and check application is 04/13604/3
authorDario Faccin <dario.faccin@canonical.com>
Mon, 3 Jul 2023 07:19:34 +0000 (09:19 +0200)
committerDario Faccin <dario.faccin@canonical.com>
Wed, 5 Jul 2023 07:30:53 +0000 (09:30 +0200)
removed

Change-Id: I7c2395c74acb752747565c004ad28466722aea99
Signed-off-by: Dario Faccin <dario.faccin@canonical.com>
osm_common/temporal/activities/paas.py

index a037282..6a29247 100644 (file)
@@ -229,3 +229,117 @@ class CheckCharmStatus(BaseActivity):
 
     async def __call__(self, activity_input: Input) -> None:
         raise NotImplementedError()
+
+
+class RemoveCharm(BaseActivity):
+    """Removes the given charm from the given model.
+
+    Collaborators:
+        Juju Controller:    Connect to controller and check charm status.
+
+    Raises  (Retryable):
+        ApplicationError    If any of password, cacert, cloud_credentials is invalid
+                            or Juju controller is not reachable
+
+    Activity Lifecycle:
+        This activity should complete relatively quickly (in a few seconds).
+        However, it would be reasonable to wait more than 72 seconds (network timeout)
+        incase there are network issues.
+
+        This activity will not report a heartbeat due to its
+        short-running nature.
+
+        It is recommended, although not necessary to implement a
+        back-off strategy for this activity, as it will naturally block
+        and wait on each connection attempt.
+    """
+
+    @dataclass
+    class Input:
+        """
+        Input dataclass for checking on a specific charm's removal
+        status
+
+        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 model in Juju where the charm is deployed.
+
+        application_name : str
+            Name of the application to be removed.
+
+        force_remove : bool
+            If application has to be forcefully removed.
+
+        """
+
+        vim_uuid: str
+        model_name: str
+        application_name: str
+        force_remove: bool
+
+    def __init__(self, juju_controller):
+        super().__init__()
+        self.juju_controller = juju_controller
+
+    async def __call__(self, activity_input: Input) -> None:
+        raise NotImplementedError()
+
+
+class CheckCharmIsRemoved(BaseActivity):
+    """Checks the removal of the charm. This activity will block until the application
+    is not present in the specified model.
+
+    Collaborators:
+        Juju Controller:    Connect to controller and check charm status.
+
+    Raises  (Retryable):
+        ApplicationError    If any of password, cacert, cloud_credentials is invalid
+                            or Juju controller is not reachable
+
+    Activity Lifecycle:
+        This activity will continue indefinitely until the specified charm is removed.
+        Heartbeats are performed to ensure this activity does not time out.
+
+        A start-to-close of something reasonable (such as 5 minutes) should be implemented
+        at the workflow level and such a timeout shall trigger workflow failure logic.
+    """
+
+    @dataclass
+    class Input:
+        """
+        Input dataclass for checking on a specific charm's removal
+        status
+
+        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 model in Juju where the charm is deployed.
+
+        application_name : str
+            Name of the application whose removal is going to be
+            awaited.
+
+        poll_interval : int (optional)
+            Time, in seconds, to wait between status checks.
+        """
+
+        vim_uuid: str
+        model_name: str
+        application_name: str
+        poll_interval: int = 1
+
+    def __init__(self, juju_controller):
+        super().__init__()
+        self.juju_controller = juju_controller
+
+    async def __call__(self, activity_input: Input) -> None:
+        raise NotImplementedError()