Skip to content

Commit 8fcc853

Browse files
committed
added simple health check setup
1 parent 1da3dc8 commit 8fcc853

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from cloudshell.workflow.orchestration.sandbox import Sandbox
2+
from cloudshell.workflow.orchestration.setup.default_setup_orchestrator import DefaultSetupWorkflow
3+
from health_check_dut import run_health_check
4+
5+
sandbox = Sandbox()
6+
7+
DefaultSetupWorkflow().register(sandbox)
8+
sandbox.workflow.on_configuration_ended(run_health_check, None)
9+
sandbox.execute_setup()
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from cloudshell.workflow.orchestration.sandbox import Sandbox
2+
3+
4+
TARGET_MODEL = "Putshell"
5+
6+
7+
def run_health_check(sandbox, components=None):
8+
"""
9+
10+
:param Sandbox sandbox:
11+
:param components:
12+
:return:
13+
"""
14+
api = sandbox.automation_api
15+
sb_id = sandbox.id
16+
logger = sandbox.logger
17+
18+
sandbox_details = api.GetReservationDetails(reservationId=sb_id, disableCache=True).ReservationDescription
19+
resources = sandbox_details.Resources
20+
dut_resource_search = [x for x in resources if x.ResourceModelName == TARGET_MODEL]
21+
if not dut_resource_search:
22+
raise ValueError(f"Could not find resource of model {TARGET_MODEL} in sandbox")
23+
24+
for resource in dut_resource_search:
25+
api.WriteMessageToReservationOutput(sb_id, f"starting health check for {resource.Name}")
26+
api.ExecuteCommand(reservationId=sb_id,
27+
targetName=resource.Name,
28+
targetType="Resource",
29+
commandName="health_check",
30+
printOutput=True)
31+
32+
done_message = "health checking done"
33+
api.WriteMessageToReservationOutput(sb_id, done_message)
34+
logger.info(done_message)
35+
36+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cloudshell-orch-core>=3.4.0.0,<3.5.0.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.0

0 commit comments

Comments
 (0)