Skip to content

Commit 4501160

Browse files
committed
Add bulk custom property example
1 parent 914d139 commit 4501160

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

samples/bulk_update.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import requests
2+
from orionsdk import SwisClient
3+
4+
npm_server = 'localhost'
5+
username = 'admin'
6+
password = ''
7+
8+
verify = False
9+
if not verify:
10+
from requests.packages.urllib3.exceptions import InsecureRequestWarning
11+
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
12+
13+
swis = SwisClient(npm_server, username, password)
14+
15+
# select the top 3 nodes from the inventory
16+
results = swis.query("SELECT TOP 3 Caption, URI FROM Orion.Nodes")
17+
nodes = results['results']
18+
19+
# build the body that will be passed to the query
20+
body = {"uris": [], "properties": {}}
21+
22+
# add the URIs with a '/CustomProperties' suffix to each
23+
for node in nodes:
24+
body["uris"].append(node["URI"] + "/CustomProperties")
25+
26+
# set as many custom properties as you like
27+
body["properties"]["City"] = "Austin"
28+
body["properties"]["DeviceType"] = "Router"
29+
body["properties"]["Department"] = "Billing"
30+
31+
# submit the request
32+
swis.bulkupdate(body)

0 commit comments

Comments
 (0)