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 check charm status.
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 checking on a specific charm's removal
266 The UUID of the VIM as stored in the OSM vim_accounts
270 Name of the model in Juju where the charm is deployed.
272 application_name : str
273 Name of the application to be removed.
276 If application has to be forcefully removed.
282 application_name
: str
285 def __init__(self
, juju_controller
):
287 self
.juju_controller
= juju_controller
289 async def __call__(self
, activity_input
: Input
) -> None:
290 raise NotImplementedError()
293 class CheckCharmIsRemoved(BaseActivity
):
294 """Checks the removal of the charm. This activity will block until the application
295 is not present in the specified model.
298 Juju Controller: Connect to controller and check charm status.
301 ApplicationError If any of password, cacert, cloud_credentials is invalid
302 or Juju controller is not reachable
305 This activity will continue indefinitely until the specified charm is removed.
306 Heartbeats are performed to ensure this activity does not time out.
308 A start-to-close of something reasonable (such as 5 minutes) should be implemented
309 at the workflow level and such a timeout shall trigger workflow failure logic.
315 Input dataclass for checking on a specific charm's removal
321 The UUID of the VIM as stored in the OSM vim_accounts
325 Name of the model in Juju where the charm is deployed.
327 application_name : str
328 Name of the application whose removal is going to be
331 poll_interval : int (optional)
332 Time, in seconds, to wait between status checks.
337 application_name
: str
338 poll_interval
: int = 1
340 def __init__(self
, juju_controller
):
342 self
.juju_controller
= juju_controller
344 async def __call__(self
, activity_input
: Input
) -> None:
345 raise NotImplementedError()