Skip to content

Commit 56947f6

Browse files
committed
Add sample for running discovery of one SNMPv3 node
1 parent 24de7fe commit 56947f6

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

samples/discover_one_node.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
from __future__ import print_function
2+
import re
3+
import requests
4+
from orionsdk import SwisClient
5+
6+
def main():
7+
npm_server = 'localhost'
8+
username = 'admin'
9+
password = ''
10+
target_node_ip = '1.2.3.4'
11+
snmpv3_credential_id = 3
12+
orion_engine_id = 1
13+
14+
swis = SwisClient(npm_server, username, password)
15+
print("Add an SNMP v3 node:")
16+
17+
corePluginContext = {
18+
'BulkList': [{'Address': target_node_ip}],
19+
'Credentials': [
20+
{
21+
'CredentialID': snmpv3_credential_id,
22+
'Order': 1
23+
}
24+
],
25+
'WmiRetriesCount': 0,
26+
'WmiRetryIntervalMiliseconds': 1000
27+
}
28+
29+
corePluginConfig = swis.invoke('Orion.Discovery', 'CreateCorePluginConfiguration', corePluginContext)
30+
31+
discoveryProfile = {
32+
'Name': 'discover_one_node.py',
33+
'EngineID': orion_engine_id,
34+
'JobTimeoutSeconds': 3600,
35+
'SearchTimeoutMiliseconds': 5000,
36+
'SnmpTimeoutMiliseconds': 5000,
37+
'SnmpRetries': 2,
38+
'RepeatIntervalMiliseconds': 1800,
39+
'SnmpPort': 161,
40+
'HopCount': 0,
41+
'PreferredSnmpVersion': 'SNMP2c',
42+
'DisableIcmp': False,
43+
'AllowDuplicateNodes': False,
44+
'IsAutoImport': True,
45+
'IsHidden': True,
46+
'PluginConfigurations': [{'PluginConfigurationItem': corePluginConfig}]
47+
}
48+
49+
print("Running discovery...")
50+
result = swis.invoke('Orion.Discovery', 'StartDiscovery', discoveryProfile)
51+
print("Returned discovery profile id {}".format(result))
52+
53+
requests.packages.urllib3.disable_warnings()
54+
55+
if __name__ == '__main__':
56+
main()

0 commit comments

Comments
 (0)