Skip to content

Commit f910f4f

Browse files
committed
adding sample of print active sandboxes
1 parent 22ecced commit f910f4f

File tree

16 files changed

+102
-10
lines changed

16 files changed

+102
-10
lines changed

automation_api_scripts/find_sandboxes_with_services.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
api = CloudShellAPISession(host=server, username=user, password=password, domain=domain)
1313
sandboxes = api.GetCurrentReservations()
14-
x = "lol"
14+
x = "lol.txt"
1515

1616
def is_resource_list_in_blueprint(api, blueprint_name, target_service_names):
1717
"""
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import json
2+
from collections import OrderedDict
3+
from cloudshell.api.cloudshell_api import CloudShellAPISession
4+
5+
user = "admin"
6+
password = "admin"
7+
server = "localhost"
8+
domain = "Global"
9+
10+
api = CloudShellAPISession(host=server, username=user, password=password, domain=domain)
11+
12+
# Get all active sandboxes
13+
active_sandboxes = api.GetCurrentReservations().Reservations
14+
15+
if not active_sandboxes:
16+
print("No currently active sandboxes")
17+
exit(0)
18+
19+
print("Active sandboxes")
20+
for sandbox in active_sandboxes:
21+
target_keys = [
22+
("id", sandbox.Id),
23+
("name", sandbox.Name),
24+
("owner", sandbox.Owner),
25+
("status", sandbox.Status),
26+
("start_time", sandbox.StartTime),
27+
("end_time", sandbox.EndTime),
28+
("source_blueprint", sandbox.Topologies[0]),
29+
]
30+
curr_dict = OrderedDict(target_keys)
31+
print(json.dumps(curr_dict, indent=4))

cloudshell-cli-samples/action_map_sample.py

Whitespace-only changes.

generic-orchestration-samples/power_scripts/power_off_all_apps_blueprint/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
SCRIPT_FLOW = "default"
1010

1111
sandbox = Sandbox()
12+
sandbox.connectivityContextDetails.admin_user
1213

1314
if SCRIPT_FLOW == "default":
1415
first_module_flow(sandbox=sandbox, components=None)

generic-orchestration-samples/setup-with_error/first_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ def first_module_flow(sandbox, components=None):
1515
api = sandbox.automation_api
1616
res_id = sandbox.id
1717
warn_print(api, sandbox.id, "=== Hello from sandbox! ===")
18-
raise Exception("I'm an Error lol")
18+
raise Exception("I'm an Error lol.txt")
1919

2020

generic-orchestration-samples/setup_send_mail/setup_ended_html_template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def get_email_template(sb_name, res_id, current_time, training_portal_link, sb_o
185185
if __name__ == "__main__":
186186
x = get_email_template(sb_name="my sandbox",
187187
res_id="xxxxxDDDDDaaaaa",
188-
current_time="lol o'clock",
188+
current_time="lol.txt o'clock",
189189
training_portal_link="my link to portal",
190190
sb_owner="natti",
191191
start_time="now",

generic-orchestration-samples/show_sandbox_data/__main__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77

88

99
def print_sandbox_data_keys(api: CloudShellAPISession, res_id: str):
10-
data = api.GetSandboxData(res_id)
10+
sandbox_data_key_values = api.GetSandboxData(res_id).SandboxDataKeyValues
11+
if not sandbox_data_key_values:
12+
api.WriteMessageToReservationOutput(res_id, "No Sandbox Data found")
13+
return
14+
1115
api.WriteMessageToReservationOutput(res_id, "=== All Sandbox Keys ===")
12-
for data in data.SandboxDataKeyValues:
16+
for data in sandbox_data_key_values:
1317

1418
# pretty print the JSON if valid
1519
try:

packaging-api-samples/create_blueprint.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# instructions="", categories="", diagram_zoom="0")
2222

2323
topology_name = p.get_topology_names()[0]
24+
2425
# p.change_topology_name_and_alias(topology_name=names[0], new_name="new blueprint name")
2526
# names_new = p.get_topology_names()
2627

packaging-api-samples/packaging_api_demo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# Load the package and prepare for edit
1717
p.load(package_path)
1818

19+
1920
# Edit the package: f.e add new family
2021
# p.add_topology(topology_name="temp_blueprint", is_public="True", image_file_path="", default_duration="15",
2122
# instructions="", categories="", diagram_zoom="0")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
credentials.py

0 commit comments

Comments
 (0)