|
| 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