Skip to content

Commit 726c96c

Browse files
committed
save all
1 parent c62b6a1 commit 726c96c

File tree

9 files changed

+48
-71
lines changed

9 files changed

+48
-71
lines changed

automation_api_scripts/create_users.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@
55
server = "localhost"
66
domain = "Global"
77

8-
TOTAL_RESOURCES = 1000
9-
108
api = CloudShellAPISession(host=server, username=user, password=password, domain=domain)
119

12-
print("building resources...")
13-
for i in range(TOTAL_RESOURCES):
14-
print("resource" + str(i + 1))
15-
api.CreateResource(resourceModel="Generic Dut",
16-
resourceName="generic_dummy_b_{}".format(str(i + 1)),
17-
resourceAddress="{0}.{0}.{0}.{0}".format(str(i)),
18-
folderFullPath="dummy resources 2")
10+
USER_COUNT = 5
11+
12+
# print("adding users...")
13+
# for i in range(USER_COUNT):
14+
# api.AddNewUser(username="{}-user".format(i+1),
15+
# password="1111",
16+
# email="test@test.com",
17+
# isActive=True)
18+
19+
print("deleting users...")
20+
for i in range(USER_COUNT):
21+
api.DeleteUser(username="{}-user".format(i+1))
1922

2023
print("done")

automation_api_scripts/save_sandbox.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
user = "admin"
44
password = "admin"
55
server = "localhost"
6+
sandbox_id = "2012cd78-1325-4db8-9dfb-6801e84ea969"
7+
saved_sandbox_name = "test from python"
8+
saved_sandbox_description = "sample description"
69
domain = "Global"
710

811
api = CloudShellAPISession(host=server, username=user, password=password, domain=domain)
912

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
13+
saved_id = api.SaveSandbox(reservationId=sandbox_id,
14+
savedSandboxName=saved_sandbox_name,
15+
savedSandboxDescription=saved_sandbox_description).SavedSandboxId
16+
print(saved_id)
17+
pass

quali_api/enqueue_suite_flow.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
suite_id = api.enqueue_suite(suite_data=suite_data_dict)
1010
suite_details = api.get_suite_details(suite_id)
1111

12-
print "suite id: " + suite_id
13-
print "===== suite details ====="
14-
print suite_details
12+
print("suite id: " + suite_id)
13+
print("===== suite details =====")
14+
print(suite_details)
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
from quali_api_wrapper import QualiAPISession
22
import json
33

4-
with open('suite_data.json') as handle:
4+
with open('suite_data_hello_world.json') as handle:
55
suite_data_dict = json.loads(handle.read())
66

77
api = QualiAPISession(host="localhost", username="admin", password="admin")
88

9-
suite_id = api.enqueue_suite(suite_data=suite_data_dict)
10-
suite_details = api.get_suite_details(suite_id)
9+
for i in range(5):
10+
print("starting suite number: #{}".format(i+1))
11+
suite_id = api.enqueue_suite(suite_data=suite_data_dict)
12+
suite_details = api.get_suite_details(suite_id)
1113

12-
print("suite id: " + suite_id)
13-
print("===== suite details =====")
14-
print(suite_details)
14+
print("suite id: " + suite_id)
15+
print("===== suite details =====")
16+
print(suite_details)
17+
print("All suites queued up")

quali_api/quali_api_wrapper.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ def enqueue_suite(self, suite_data):
175175
if 200 <= enqueue_suite_result.status_code < 300:
176176
return enqueue_suite_result.json()
177177
else:
178-
return enqueue_suite_result.content
178+
raise Exception("Failed api call. Response: {}, {}".format(enqueue_suite_result.status_code,
179+
enqueue_suite_result.text))
179180

180181
def get_suite_details(self, suite_id):
181182
get_details_result = requests.get(self._api_base_url + "/Scheduling/Suites/{}".format(suite_id),

quali_api/suite_data.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"SuiteTemplateName": "Demo Suite",
2+
"SuiteTemplateName": "uat demo",
33
"SuiteName": "Quali API Suite",
44
"Description": "this is a suite ran through API",
55
"Type": "TestShell",

quali_api/suite_data_hello_world.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"EndReservationOnEnd": true,
1010
"JobsDetails": [
1111
{
12-
"Name": "First Job Sample",
12+
"Name": "first job form api",
1313
"Description": "sample description",
1414
"ExecutionServers": [],
1515
"LoggingProfile": "All",
@@ -18,18 +18,13 @@
1818
"StopOnError": false,
1919
"Tests": [
2020
{
21-
"TestPath": "TestShell\\Tests\\Shared\\Demo\\input_demo",
21+
"TestPath": "TestShell\\Tests\\Shared\\hello world",
2222
"State": null,
2323
"StartTime": null,
2424
"EndTime": null,
2525
"Result": null,
2626
"ReportId": null,
27-
"Parameters": [
28-
{
29-
"ParameterName": "input_1",
30-
"ParameterValue": "hello there I'm input 1"
31-
}
32-
],
27+
"Parameters": [],
3328
"EstimatedDuration": null
3429
}
3530
],

quali_api/suite_data_no_job_data.json

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,6 @@
77
"EmailNotifications": "ErrorsOnly",
88
"RemoveJobsFromQueueAfter": -1,
99
"EndReservationOnEnd": true,
10-
"JobsDetails": [
11-
{
12-
"Name": "First Job Sample",
13-
"Description": "sample description",
14-
"ExecutionServers": [],
15-
"LoggingProfile": "All",
16-
"EstimatedDuration": 2,
17-
"StopOnFail": false,
18-
"StopOnError": false,
19-
"Tests": [
20-
{
21-
"TestPath": "TestShell\\Tests\\Shared\\Demo\\input_demo",
22-
"State": null,
23-
"StartTime": null,
24-
"EndTime": null,
25-
"Result": null,
26-
"ReportId": null,
27-
"Parameters": [
28-
{
29-
"ParameterName": "input_1",
30-
"ParameterValue": "hello there I'm input 1"
31-
}
32-
],
33-
"EstimatedDuration": null
34-
}
35-
],
36-
"Topology": null,
37-
"DurationTimeBuffer": 0,
38-
"EmailNotifications": null,
39-
"Type": "TestShell"
40-
}
41-
],
10+
"JobsDetails": [],
4211
"ExistingReservationId": null
4312
}

sandbox_rest_samples/sb_rest/sandbox_rest_api.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def _get_auth_headers(server, user_name, password, domain):
3838
if login_res.status_code in [200, 202]:
3939
login_token = login_res.text[1:-1]
4040
else:
41-
print "login response code: " + str(login_res.status_code)
42-
print "login response" + login_res.text
41+
print("login response code: " + str(login_res.status_code))
42+
print("login response" + login_res.text)
4343
raise Exception("Sandbox API authentication Failed")
4444

4545
auth_headers = {
@@ -195,8 +195,11 @@ def get_sandboxes(self, show_historic=False):
195195
password = "admin"
196196
domain = "Global"
197197

198+
SANDBOX_COUNT = 5
199+
198200
sb_rest = SandboxRest(server, cs_user, password, domain)
199-
sandbox_info = sb_rest.get_sandboxes()
200-
info_json = json.dumps(sandbox_info, indent=2)
201-
print(info_json)
202-
pass
201+
for i in range(SANDBOX_COUNT):
202+
res = sb_rest.start_blueprint("rest api test", "test {}".format(i + 1))
203+
info_json = json.dumps(res, indent=2)
204+
print(info_json)
205+
pass

0 commit comments

Comments
 (0)