-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab5_task1_create_snapshot_of_tenant.py
48 lines (39 loc) · 1.16 KB
/
lab5_task1_create_snapshot_of_tenant.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import requests
import json
from pprint import pprint
requests.packages.urllib3.disable_warnings()
USERNAME = "admin"
PASSWORD = "1234QWer"
URL = "https://192.168.10.1/"
# 1. Authentication
payload = {
'aaaUser': {
'attributes': {
'name': USERNAME,
'pwd': PASSWORD
}
}
}
auth = requests.post(f'{URL}api/aaaLogin.json', data=json.dumps(payload), verify=False)
COOKIES = auth.cookies
# create snapshot of tenant
DESCRIPTION = 'Lab4 end'
TARGET_TENANT = 'APILAB-GUI'
payload_task = {
'configExportP' : {
'attributes': {
'dn': 'uni/fabric/configexp-defaultOneTime',
'name': 'defaultOneTime',
'rn': 'configexp-defaultOneTime',
'snapshot': 'true',
'targetDn': f'uni/tn-{TARGET_TENANT}',
'adminSt': 'triggered',
'descr': DESCRIPTION,
'status': 'created,modified',
},
'children': []
}
}
result = requests.post(f'{URL}api/node/mo/uni/fabric/configexp-defaultOneTime.json', data=json.dumps(payload_task), verify = False, cookies=COOKIES)
print('Return code: {code}'.format(code=result.status_code))
pprint(result.content)