-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathget_link_info.py
More file actions
26 lines (19 loc) · 861 Bytes
/
Copy pathget_link_info.py
File metadata and controls
26 lines (19 loc) · 861 Bytes
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
'''
Created on Aug 12, 2016
@author: azaringh
'''
import requests
requests.packages.urllib3.disable_warnings()
import json
url = "https://10.10.2.29:8443/oauth2/token"
payload = {'grant_type': 'password', 'username': 'some_name', 'password': 'some_password'}
response = requests.post (url, data=payload, auth=('some_name','some_password'), verify=False)
json_data = json.loads(response.text)
authHeader= {"Authorization":"{token_type} {access_token}".format(**json_data)}
r = requests.get('https://10.10.2.29:8443/NorthStar/API/v1/tenant/1/topology/1/links/', headers=authHeader, verify=False)
print "r is:", r
print "r.json is:", r.json() # r.json() returns a python dict
for link in r.json():
if link['name'] == 'L10.210.11.1_10.210.11.2':
print 'A node:', link['endA']['node']['name']
print 'Z node:', link['endZ']['node']['name']