File tree Expand file tree Collapse file tree 4 files changed +47
-0
lines changed
generic-orchestration-samples/Basic Samples/sample_setup_health_check Expand file tree Collapse file tree 4 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 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 ()
Original file line number Diff line number Diff line change 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+
Original file line number Diff line number Diff line change 1+ cloudshell-orch-core >= 3.4.0.0 ,< 3.5.0.0
Original file line number Diff line number Diff line change 1+ 1.0.0
You can’t perform that action at this time.
0 commit comments