-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaugment_attributes.py
More file actions
55 lines (42 loc) · 1.32 KB
/
augment_attributes.py
File metadata and controls
55 lines (42 loc) · 1.32 KB
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
49
50
51
52
53
54
import requests
import json
import time
import urllib.parse
requests.packages.urllib3.disable_warnings()
###################
# CONFIGURATION ->
###################
# URL to your Hyperglance Server
HYPERGLANCE_URL = "https://10.0.0.1"
# Unique Hyperglance API name/key pair
# Generate yours here: https://hyperglanceIP/#/admin/hgapi
API_KEY = ('my-api-user', '77415974-1b16-4ee8-af98-6be979611158')
# The ID of a Hyperglance resource (get this from the URL on the Diagram page or from ./diagram-to-json.py)
node_UID = "AcmeApp|example topology|NODE|network|node3"
# JSON for attaching custom attributes to a Hyperglance resource
JSON = {
"attributes": [
{
"UID": node_UID,
"attributes": [
{ "name": "Contact E-Mail", "value": "jon@example.com" }
]
}
]
}
#####################
# EXECUTION START ->
#####################
# Post JSON to Hyperglance
print('Augmenting All')
r = requests.put(HYPERGLANCE_URL + '/hgapi/augment', json=JSON, auth=API_KEY, verify=False)
# Check that everything went okay
if r.status_code != 200:
print('Error calling API: ' + str(r.status_code))
print(r.text)
quit()
if not (r.text == 'Augmentation Successful!'):
print('Error adding account to Hyperglance:')
print(json.dumps(r.json(), indent=2))
quit()
print(r.text)