Skip to content

Commit c19b56a

Browse files
committed
added include / exclude sample
1 parent fd2af1a commit c19b56a

7 files changed

Lines changed: 67 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from cloudshell.api.cloudshell_api import CloudShellAPISession
2+
from typing import List
3+
4+
5+
def exclude_ports(api: CloudShellAPISession, target_ports: List[str]):
6+
api.ExcludeResources(target_ports)
7+
8+
9+
def include_ports(api: CloudShellAPISession, target_ports: List[str]):
10+
api.IncludeResources(target_ports)
11+
12+
13+
if __name__ == "__main__":
14+
api = CloudShellAPISession("localhost", "admin", "admin", "Global")
15+
TARGET_PORTS = ["cl-app-polatis/Port 001", "cl-app-polatis/Port 002"]
16+
# exclude_ports(api, TARGET_PORTS)
17+
include_ports(api, TARGET_PORTS)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from cloudshell.workflow.orchestration.sandbox import Sandbox
2+
from cloudshell.workflow.orchestration.setup.default_setup_orchestrator import DefaultSetupWorkflow
3+
from tenacity import retry, stop_after_attempt, wait_fixed
4+
from cloudshell.helpers.sandbox_reporter.reporter import SandboxReporter
5+
6+
sandbox = Sandbox()
7+
8+
DefaultSetupWorkflow().register(sandbox)
9+
reporter = SandboxReporter(api=sandbox.automation_api,
10+
reservation_id=sandbox.id,
11+
logger=sandbox.logger)
12+
13+
14+
@retry(stop=(stop_after_attempt(5)), wait=wait_fixed(30))
15+
def execute_setup_with_retries():
16+
reporter.warning("Beginning setup")
17+
raise Exception("woops")
18+
sandbox.execute_setup()
19+
20+
21+
execute_setup_with_retries()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cloudshell-orch-core>=4.0.0.0,<4.1.0.0
2+
tenacity
3+
cloudshell-sandbox-reporter
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4.1.0.258
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from cloudshell.workflow.orchestration.sandbox import Sandbox
2+
from cloudshell.workflow.orchestration.teardown.default_teardown_orchestrator import DefaultTeardownWorkflow
3+
from tenacity import retry, stop_after_attempt, wait_fixed
4+
from cloudshell.helpers.sandbox_reporter.reporter import SandboxReporter
5+
6+
sandbox = Sandbox()
7+
8+
DefaultTeardownWorkflow().register(sandbox)
9+
reporter = SandboxReporter(api=sandbox.automation_api,
10+
reservation_id=sandbox.id,
11+
logger=sandbox.logger)
12+
13+
14+
@retry(stop=(stop_after_attempt(5)), wait=wait_fixed(30))
15+
def execute_teardown_with_retries():
16+
reporter.warning("Beginning teardown")
17+
raise Exception("woops")
18+
sandbox.execute_teardown()
19+
20+
21+
execute_teardown_with_retries()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cloudshell-orch-core>=4.0.0.0,<4.1.0.0
2+
tenacity
3+
cloudshell-sandbox-reporter
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4.1.0.258

0 commit comments

Comments
 (0)