Skip to content

Commit 869ab4a

Browse files
author
srotti
committed
export and import alerts
Samples scripts added for export and import alerts.
1 parent 3060d63 commit 869ab4a

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

samples/export_alert.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+
5+
def main():
6+
npm_server = 'localhost'
7+
username = 'admin'
8+
password = ''
9+
AlertID = 1 #AlertID for which we export data in xml file.
10+
11+
swis = SwisClient(npm_server, username, password)
12+
results = swis.invoke('Orion.AlertConfigurations', 'Export', AlertID)
13+
print(results)
14+
15+
with open('out.xml', 'w') as f:
16+
f.write(results)
17+
18+
requests.packages.urllib3.disable_warnings()
19+
20+
21+
if __name__ == '__main__':
22+
main()

samples/import_alert.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import requests
2+
from orionsdk import SwisClient
3+
4+
5+
def main():
6+
npm_server = 'localhost'
7+
username = 'admin'
8+
password = ''
9+
importfile = 'out.xml' #file which contain AlertConfiguration in xml format.
10+
11+
swis = SwisClient(npm_server, username, password)
12+
13+
with open(importfile, 'r') as f:
14+
alert = f.read()
15+
16+
results = swis.invoke('Orion.AlertConfigurations', 'Import', alert)
17+
print(results)
18+
19+
requests.packages.urllib3.disable_warnings()
20+
21+
22+
if __name__ == '__main__':
23+
main()

0 commit comments

Comments
 (0)