Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ef3c162

Browse files
authored
Merge pull request solarwinds#13 from solarwinds/feature/add-u
Add bulkupdate method to SwisClient
2 parents 91d51c4 + 8ca535f commit ef3c162

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

orionsdk/swisclient.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ def read(self, uri):
3939
def update(self, uri, **properties):
4040
self._req("POST", uri, properties)
4141

42+
def bulkupdate(self, uris, **properties):
43+
self._req("POST", "BulkUpdate",
44+
{'uris': uris, 'properties': properties})
45+
4246
def delete(self, uri):
4347
self._req("DELETE", uri)
4448

samples/bulk_update.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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 N.CustomProperties.Uri FROM Orion.Nodes N")
17+
18+
# extract just the Uris from the results
19+
uris = [row['Uri'] for row in results['results']]
20+
21+
# submit the request
22+
swis.bulkupdate(uris, City='Austin', DeviceType='Router', Department='Billing')

0 commit comments

Comments
 (0)