File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
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 )
You can’t perform that action at this time.
0 commit comments