X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_common%2Ftemporal%2Factivities%2Fpaas.py;h=945e4d22e62990286f5608cef2564dd97cbef4e4;hb=refs%2Fchanges%2F72%2F13672%2F2;hp=6a29247cef1c3004c3836ad97060e7ac5ce91ad0;hpb=d32ac8bf9d3bc22ba394ed5ac23af9aac09a21a8;p=osm%2Fcommon.git diff --git a/osm_common/temporal/activities/paas.py b/osm_common/temporal/activities/paas.py index 6a29247..945e4d2 100644 --- a/osm_common/temporal/activities/paas.py +++ b/osm_common/temporal/activities/paas.py @@ -235,7 +235,7 @@ class RemoveCharm(BaseActivity): """Removes the given charm from the given model. Collaborators: - Juju Controller: Connect to controller and check charm status. + Juju Controller: Connect to controller and remove charm. Raises (Retryable): ApplicationError If any of password, cacert, cloud_credentials is invalid @@ -257,8 +257,7 @@ class RemoveCharm(BaseActivity): @dataclass class Input: """ - Input dataclass for checking on a specific charm's removal - status + Input dataclass for removing a specific charm Attributes: ----------- @@ -325,13 +324,172 @@ class CheckCharmIsRemoved(BaseActivity): 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. + Name of the application for which the 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() + + +class RemoveModel(BaseActivity): + """Removes the given model from the given controller. + + Collaborators: + Juju Controller: Connect to controller and remove model. + + 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 removing a specific 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 model in Juju to be removed. + + force_remove : bool + If model has to be forcefully removed. + + """ + + vim_uuid: str + model_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 CheckModelIsRemoved(BaseActivity): + """Checks the removal of the model. This activity will block until the model + is not present in the specified controller. + + Collaborators: + Juju Controller: Connect to controller and check model removal 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 model 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 model'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 for which the removal is going + to be awaited. poll_interval : int (optional) Time, in seconds, to wait between status checks. """ + vim_uuid: str + model_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() + + +class ResolveCharmErrors(BaseActivity): + """Mark the errors as resolved in all units for the given charm in the given model. + + Collaborators: + Juju Controller: Connect to controller and mark charm errors as resolved. + + 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 error of specific application + is resolved. Heartbeats are performed to ensure this activity does not time out. + + A start-to-close of something reasonable (such as 2 minutes) should be implemented + at the workflow level and such a timeout shall trigger workflow failure logic. + + """ + + @dataclass + class Input: + """ + Input dataclass for marking errors as resolved on all units of a specific charm + + 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 for which unit errors have to be resolved. + + poll_interval : int (optional) + Time, in seconds, to wait between application status checks to see if error resolved or not. + + """ + vim_uuid: str model_name: str application_name: str