1 #######################################################################################
2 # Copyright ETSI Contributors and Others.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #######################################################################################
18 from dataclasses
import dataclass
20 from osm_common
.dbbase
import DbBase
21 from osm_common
.temporal
.activities
.base
import BaseActivity
22 from osm_common
.temporal
.dataclasses_common
import CharmInfo
, VduComputeConstraints
25 class TestVimConnectivity(BaseActivity
):
26 """Validates the credentials by attempting to connect to the given Juju Controller.
29 Juju Controller: Connect only
32 ApplicationError If any of password, cacert, cloud_credentials is invalid
33 or Juju controller is not reachable
36 This activity should complete relatively quickly (in a few seconds).
37 However, it would be reasonable to wait more than 72 seconds (network timeout)
38 incase there are network issues.
40 This activity will not report a heartbeat due to its
43 It is recommended, although not necessary to implement a
44 back-off strategy for this activity, as it will naturally block
45 and wait on each connection attempt.
51 Input dataclass for the Test Vim Connectivity Ativity
56 The UUID of the VIM account as stored in the OSM vim
62 def __init__(self
, juju_controller
):
64 self
.juju_controller
= juju_controller
66 async def __call__(self
, activity_input
: Input
) -> None:
67 raise NotImplementedError()
70 class CreateModel(BaseActivity
):
71 """Connects to Juju Controller. Creates a new model.
75 Juju Controller: Connect and create model.
78 ApplicationError If Juju controller is not reachable.
79 If the model already exists.
82 This activity should complete relatively quickly (in a few seconds).
83 However, it would be reasonable to wait more than 72 seconds (network timeout)
84 incase there are network issues.
86 This activity will not report a heartbeat due to its
89 It is recommended, although not necessary to implement a
90 back-off strategy for this activity, as it will naturally block
91 and wait on each connection attempt.
97 Contains the information related to a model.
102 The UUID of the VIM as stored in the OSM vim_accounts
106 Name of the Juju model used to deploy charms.
112 def __init__(self
, db
: DbBase
, juju_controller
):
115 self
.juju_controller
= juju_controller
117 async def __call__(self
, activity_input
: Input
) -> None:
118 raise NotImplementedError()
121 class DeployCharm(BaseActivity
):
125 Juju Controller: Connect and deploy charm
128 ApplicationError If Juju controller is not reachable
129 If application already exists
132 This activity should complete relatively quickly (in a few seconds).
133 However, it would be reasonable to wait more than 72 seconds (network timeout)
134 incase there are network issues.
136 This activity will not report a heartbeat due to its
137 short-running nature.
139 It is recommended, although not necessary to implement a
140 back-off strategy for this activity, as it will naturally block
141 and wait on each connection attempt.
147 Input dataclass for workflow that instantiates a VDU.
153 charm_info : CharmInfo
155 constraints: VduComputeConstraints
157 cloud: VIM cloud type
159 config: Config details of application
164 charm_info
: CharmInfo
165 constraints
: VduComputeConstraints
169 def __init__(self
, juju_controller
):
171 self
.juju_controller
= juju_controller
173 async def __call__(self
, activity_input
: Input
) -> None:
174 raise NotImplementedError()
177 class CheckCharmStatus(BaseActivity
):
178 """Checks the ready status of the charm. This activity will block until the status of
179 the application is either "active" or "blocked". Additionally, it also blocks until
180 the workload status of each of its units is also either "active" or "blocked".
183 Juju Controller: Connect to controller and check charm status.
186 ApplicationError If any of password, cacert, cloud_credentials is invalid
187 or Juju controller is not reachable
190 This activity will continue indefinitely until the specified charm deployment
191 has reached a ready state. Heartbeats are performed to ensure this activity
194 A start-to-close of something reasonable (such as 5 minutes) should be implemented
195 at the workflow level and such a timeout shall trigger workflow failure logic.
201 Input dataclass for checking on a specific charm's deployment
207 The UUID of the VIM as stored in the OSM vim_accounts
211 Name of the model to create in Juju.
213 application_name : str
214 Name of the application that the state is going to be
217 poll_interval : int (optional)
218 Time, in seconds, to wait between status checks.
223 application_name
: str
224 poll_interval
: int = 1
226 def __init__(self
, juju_controller
):
228 self
.juju_controller
= juju_controller
230 async def __call__(self
, activity_input
: Input
) -> None:
231 raise NotImplementedError()
234 class RemoveCharm(BaseActivity
):
235 """Removes the given charm from the given model.
238 Juju Controller: Connect to controller and remove charm.
241 ApplicationError If any of password, cacert, cloud_credentials is invalid
242 or Juju controller is not reachable
245 This activity should complete relatively quickly (in a few seconds).
246 However, it would be reasonable to wait more than 72 seconds (network timeout)
247 incase there are network issues.
249 This activity will not report a heartbeat due to its
250 short-running nature.
252 It is recommended, although not necessary to implement a
253 back-off strategy for this activity, as it will naturally block
254 and wait on each connection attempt.
260 Input dataclass for removing a specific charm
265 The UUID of the VIM as stored in the OSM vim_accounts
269 Name of the model in Juju where the charm is deployed.
271 application_name : str
272 Name of the application to be removed.
275 If application has to be forcefully removed.
281 application_name
: str
284 def __init__(self
, juju_controller
):
286 self
.juju_controller
= juju_controller
288 async def __call__(self
, activity_input
: Input
) -> None:
289 raise NotImplementedError()
292 class CheckCharmIsRemoved(BaseActivity
):
293 """Checks the removal of the charm. This activity will block until the application
294 is not present in the specified model.
297 Juju Controller: Connect to controller and check charm status.
300 ApplicationError If any of password, cacert, cloud_credentials is invalid
301 or Juju controller is not reachable
304 This activity will continue indefinitely until the specified charm is removed.
305 Heartbeats are performed to ensure this activity does not time out.
307 A start-to-close of something reasonable (such as 5 minutes) should be implemented
308 at the workflow level and such a timeout shall trigger workflow failure logic.
314 Input dataclass for checking on a specific charm's removal
320 The UUID of the VIM as stored in the OSM vim_accounts
324 Name of the model in Juju where the charm is deployed.
326 application_name : str
327 Name of the application for which the removal is going
330 poll_interval : int (optional)
331 Time, in seconds, to wait between status checks.
336 application_name
: str
337 poll_interval
: int = 1
339 def __init__(self
, juju_controller
):
341 self
.juju_controller
= juju_controller
343 async def __call__(self
, activity_input
: Input
) -> None:
344 raise NotImplementedError()
347 class RemoveModel(BaseActivity
):
348 """Removes the given model from the given controller.
351 Juju Controller: Connect to controller and remove model.
354 ApplicationError If any of password, cacert, cloud_credentials is invalid
355 or Juju controller is not reachable
358 This activity should complete relatively quickly (in a few seconds).
359 However, it would be reasonable to wait more than 72 seconds (network timeout)
360 incase there are network issues.
362 This activity will not report a heartbeat due to its
363 short-running nature.
365 It is recommended, although not necessary to implement a
366 back-off strategy for this activity, as it will naturally block
367 and wait on each connection attempt.
373 Input dataclass for removing a specific model
378 The UUID of the VIM as stored in the OSM vim_accounts
382 Name of the model in Juju to be removed.
385 If model has to be forcefully removed.
393 def __init__(self
, juju_controller
):
395 self
.juju_controller
= juju_controller
397 async def __call__(self
, activity_input
: Input
) -> None:
398 raise NotImplementedError()
401 class CheckModelIsRemoved(BaseActivity
):
402 """Checks the removal of the model. This activity will block until the model
403 is not present in the specified controller.
406 Juju Controller: Connect to controller and check model removal status.
409 ApplicationError If any of password, cacert, cloud_credentials is invalid
410 or Juju controller is not reachable
413 This activity will continue indefinitely until the specified model is removed.
414 Heartbeats are performed to ensure this activity does not time out.
416 A start-to-close of something reasonable (such as 5 minutes) should be implemented
417 at the workflow level and such a timeout shall trigger workflow failure logic.
423 Input dataclass for checking on a specific model's removal
429 The UUID of the VIM as stored in the OSM vim_accounts
433 Name of the model in Juju for which the removal is going
436 poll_interval : int (optional)
437 Time, in seconds, to wait between status checks.
442 poll_interval
: int = 1
444 def __init__(self
, juju_controller
):
446 self
.juju_controller
= juju_controller
448 async def __call__(self
, activity_input
: Input
) -> None:
449 raise NotImplementedError()
452 class ResolveCharmErrors(BaseActivity
):
453 """Mark the errors as resolved in all units for the given charm in the given model.
456 Juju Controller: Connect to controller and mark charm errors as resolved.
459 ApplicationError If any of password, cacert, cloud_credentials is invalid
460 or Juju controller is not reachable
463 This activity will continue indefinitely until the error of specific application
464 is resolved. Heartbeats are performed to ensure this activity does not time out.
466 A start-to-close of something reasonable (such as 2 minutes) should be implemented
467 at the workflow level and such a timeout shall trigger workflow failure logic.
474 Input dataclass for marking errors as resolved on all units of a specific charm
479 The UUID of the VIM as stored in the OSM vim_accounts
483 Name of the model in Juju where the charm is deployed.
485 application_name : str
486 Name of the application for which unit errors have to be resolved.
488 poll_interval : int (optional)
489 Time, in seconds, to wait between application status checks to see if error resolved or not.
495 application_name
: str
496 poll_interval
: int = 1
498 def __init__(self
, juju_controller
):
500 self
.juju_controller
= juju_controller
502 async def __call__(self
, activity_input
: Input
) -> None:
503 raise NotImplementedError()