-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlsp_rro_get.py
More file actions
31 lines (25 loc) · 988 Bytes
/
Copy pathlsp_rro_get.py
File metadata and controls
31 lines (25 loc) · 988 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
27
28
29
30
31
'''
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/te-lsps/', headers=authHeader, verify=False)
p = json.dumps(r.json())
lsp_list = json.loads(p)
# Find target LSP to use lspIndex
for lsp in lsp_list:
if lsp['name'] == 'GROUP_NINE_NY_SF_LSP4':
break
print json.dumps(lsp, indent=4, separators=(',', ': '))
print lsp['liveProperties']['rro']
count = 1
for nhop in lsp['liveProperties']['rro']:
print 'hop' + str(count) + ':', nhop['address']
count = count + 1