Skip to content

Commit 16cfedc

Browse files
committed
adding everything
1 parent 5f8eb21 commit 16cfedc

File tree

474 files changed

+19477
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

474 files changed

+19477
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.idea/
2+
DEBUG/
3+
quali_api_sanity_exe/
4+
*.zip
5+
Orchestration-Templates/

automation_api_scripts/__init__.py

Whitespace-only changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from cloudshell.api.cloudshell_api import CloudShellAPISession
2+
3+
user = "admin"
4+
password = "admin"
5+
server = "localhost"
6+
domain = "Global"
7+
8+
api = CloudShellAPISession(host=server, username=user, password=password, domain=domain)
9+
10+
res_id = "3bac3765-ba86-4ad3-819b-3a2127c1cbef"
11+
blueprint_name = "L1 connectivity - 9.2 Ogura Test"
12+
13+
res = api.ActivateTopology(reservationId=res_id, topologyFullPath=blueprint_name)
14+
pass
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from cloudshell.api.cloudshell_api import CloudShellAPISession, ResourceInfoDto
2+
3+
user = "admin"
4+
password = "admin"
5+
server = "localhost"
6+
domain = "Training"
7+
res_id = "775dc625-28a4-4b4d-b07d-58802ca662ca"
8+
9+
api = CloudShellAPISession(host=server, username=user, password=password, domain=domain)
10+
11+
12+
api.CreateResources()
13+
14+
res = api.AddPermittedUsersToReservation(reservationId=res_id, usernames=["student A"])
15+
16+
pass
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from cloudshell.api.cloudshell_api import CloudShellAPISession
2+
import timeit
3+
4+
user = "admin"
5+
password = "admin"
6+
server = "localhost"
7+
domain = "Global"
8+
9+
TARGET_RESOURCE_NAME = "tent-switch-test"
10+
11+
api = CloudShellAPISession(host=server, username=user, password=password, domain=domain)
12+
13+
print("starting autoload...")
14+
start_time = timeit.default_timer()
15+
res = api.AutoLoad(resourceFullPath=TARGET_RESOURCE_NAME)
16+
elapsed = timeit.default_timer() - start_time
17+
18+
print("autoload response: {}".format(res))
19+
print("autoload time: {}".format(elapsed))
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from cloudshell.api.cloudshell_api import InputNameValue, CloudShellAPISession, AppConfiguration, ConfigParam
2+
3+
session = CloudShellAPISession("localhost", "admin", "admin", "Global")
4+
res_id = "260b3f80-14bd-4cc2-975c-6ab21a12ac28"
5+
6+
res_details = session.GetReservationDetails(res_id).ReservationDescription
7+
x = session.GetAppsDetailsInReservation(res_id, ["Linux Ubuntu Tiny"])
8+
params = [ConfigParam("key", "value")]
9+
app_configs = [AppConfiguration(AppName="asdf", ConfigParams=params)]
10+
11+
session.ConfigureApps(reservationId=res_id,
12+
appConfigurations=app_configs)
13+
14+
res_details_after_config = session.GetReservationDetails(res_id).ReservationDescription
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from cloudshell.api.cloudshell_api import CloudShellAPISession
2+
3+
user = "admin"
4+
password = "admin"
5+
server = "localhost"
6+
7+
api = CloudShellAPISession(host=server, username=user, password=password, domain="Training")
8+
9+
res = api.CreateImmediateReservation(reservationName="lolol",
10+
owner="end_user",
11+
durationInMinutes=60)
12+
res_id = res.Reservation.Id
13+
res = api.AddPermittedUsersToReservation(reservationId=res_id,
14+
usernames=["Student A"])
15+
pass
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from cloudshell.api.cloudshell_api import CloudShellAPISession
2+
3+
user = "admin"
4+
password = "admin"
5+
server = "localhost"
6+
7+
api = CloudShellAPISession(host=server, username=user, password=password, domain="Global")
8+
9+
all_bps = api.GetTopologiesByCategory().Topologies
10+
11+
12+
def is_bp_garbage(curr_bp):
13+
"""
14+
filter for accdidentally made bps. Those that have template in their name but are not actually the template
15+
:param curr_bp:
16+
:return:
17+
"""
18+
bp_details = api.GetTopologyDetails(curr_bp)
19+
if "CloudShell Sandbox Template" in bp_details.Name and bp_details.Type == "Regular":
20+
return True
21+
else:
22+
return False
23+
24+
25+
bps_to_delete = [bp for bp in all_bps if is_bp_garbage(bp)]
26+
for bp in bps_to_delete:
27+
api.DeleteTopology(bp)
28+
29+
pass
30+
31+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from cloudshell.api.cloudshell_api import CloudShellAPISession
2+
3+
user = "admin"
4+
password = "admin"
5+
server = "localhost"
6+
7+
api = CloudShellAPISession(host=server, username=user, password=password, domain="Global")
8+
9+
keeper_categories = ["Swisscom", "SQC", "Mobile Center Demo", "vodaphone bracknell"]
10+
keepers = []
11+
12+
for category in keeper_categories:
13+
bps = api.GetTopologiesByCategory(category).Topologies
14+
keepers.extend(bps)
15+
16+
all_bps = api.GetTopologiesByCategory().Topologies
17+
18+
keepers_set = set(keepers)
19+
all_bps_set = set(all_bps)
20+
21+
throw_aways = list(all_bps_set - keepers_set)
22+
23+
for bp in throw_aways:
24+
api.DeleteTopology(bp)
25+
26+
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
"""
2+
Find all apps in "Deployed Apps" Folder and delete resource if not currently in Reservation
3+
This script currently supports V-CENTER cloud provider
4+
Script must have direct connectivity to:
5+
- Quali Application Server
6+
- vCenter Server
7+
"""
8+
from cloudshell.api.cloudshell_api import CloudShellAPISession
9+
import time
10+
import os
11+
12+
user = "admin"
13+
password = "admin"
14+
server = "localhost"
15+
16+
def ping_vcenter_server(server_ip):
17+
pass
18+
19+
api = CloudShellAPISession(host=server, username=user, password=password, domain="Global")
20+
cloud_provider_details = api.GetResourceDetails(resourceFullPath="my vCenter")
21+
all_app_resources = api.FindResources(resourceFamily="Generic App Family").Resources
22+
deployed_app_folder_resources = [resource for resource in all_app_resources
23+
if "Deployed Apps" in resource.FullPath]
24+
if not deployed_app_folder_resources:
25+
print("No deployed app resources. Ending Script.")
26+
exit(0)
27+
28+
un_reserved_deployed_apps = [resource for resource in deployed_app_folder_resources
29+
if resource.ReservedStatus == "Not In Reservations"]
30+
31+
if not un_reserved_deployed_apps:
32+
print("No UNRESERVED deployed app resources. Ending Script.")
33+
exit(0)
34+
35+
failed_deletions = []
36+
successful_deletions = []
37+
for resource in un_reserved_deployed_apps:
38+
try:
39+
print("Deleting deployed app resource: '{}'...".format(resource.Name))
40+
response = api.DeleteResource(resourceFullPath=resource.Name)
41+
pass
42+
except Exception as e:
43+
print("FAILED deletion '{}': Exception: {}".format(resource.Name, str(e)))
44+
print("=============")
45+
failed_deletions.append(resource.Name)
46+
else:
47+
if 'Success="true"' in response:
48+
print("SUCCESSFUL deletion: '{}'".format(resource.Name))
49+
print("=============")
50+
successful_deletions.append(resource.Name)
51+
else:
52+
print("FAILED deletion '{}'. Response: {}".format(resource.Name, response))
53+
print("=============")
54+
failed_deletions.append(resource.Name)
55+
56+
if failed_deletions:
57+
if successful_deletions:
58+
print("Following apps deleted SUCCESSFULLY: {}".format(successful_deletions))
59+
print("Following app resource deletion FAILED: {}".format(failed_deletions))
60+
print("=============")
61+
time.sleep(1) # just so exception appears after print statements
62+
raise Exception("There were failed app resource deletions in this operation.")
63+
64+
print("ALL Un-reserved deployed apps deleted SUCCESSFULLY: {}".format(successful_deletions))
65+
print("=============")
66+

0 commit comments

Comments
 (0)