I need some help with my python script to add nodes and interfaces during a discovery. The discovery completes however the items in the AutoImportExpressionFilter do not apply fully in the console. The values are correct however the Prop: and Op: sections to not seem to update correctly and remain as the defaults (Interface Type and 'Contains any keywords'). Is there something wrong with the syntax that I have? Any help would be much appreciated!
from __future__ import print_function
import re
import requests
from orionsdk import SwisClient
def main():
npm_server = '<<SERVER_NAME>>'
username = '<<SUPER SECRET USERNAME>>'
password = '<<SUPER SECRET PASSWORD>>'
target_node_ip = '10.99.249.13'
target_node_ip2 = '10.99.249.12'
snmpv3_credential_id = 7
orion_engine_id = 1
swis = SwisClient(npm_server, username, password)
print("Add an SNMP v3 node:")
corePluginContext = {
'BulkList': [{'Address': target_node_ip}],
'Credentials': [
{
'CredentialID': snmpv3_credential_id,
'Order': 1
}
],
'WmiRetriesCount': 0,
'WmiRetryIntervalMiliseconds': 1000
}
corePluginConfig = swis.invoke('Orion.Discovery', 'CreateCorePluginConfiguration', corePluginContext)
interfacesPluginContext = {
'AutoImportStatus': ['Up'], # Also available: Down, Shutdown, Up
'AutoImportVlanPortTypes': ['Trunk', 'Access', 'Unknown'],
'AutoImportVirtualTypes': ['Physical', 'Virtual'], # Also available: Unknown
'AutoImportExpressionFilter':
[{'Prop': 'Descr', 'Op': '!Any', 'Val': 'null'},
{'Prop': 'Descr', 'Op': '!Any', 'Val': 'vlan'},
{'Prop': 'Descr', 'Op': '!Any', 'Val': 'loopback'},
{'Prop': 'Alias', 'Op': '!Regex', 'Val': '^$'},
{'Prop': 'Name', 'Op': '!Regex', 'Val': '^t1'}]
}
interfacesPluginConfig = swis.invoke('Orion.NPM.Interfaces', 'CreateInterfacesPluginConfiguration', interfacesPluginContext)
discoveryProfile = {
'Name': 'Python Auto Import',
'EngineID': orion_engine_id,
'JobTimeoutSeconds': 3600,
'SearchTimeoutMiliseconds': 5000,
'SnmpTimeoutMiliseconds': 5000,
'SnmpRetries': 2,
'RepeatIntervalMiliseconds': 1800,
'SnmpPort': 161,
'HopCount': 0,
'PreferredSnmpVersion': 'SNMP3',
'DisableIcmp': True,
'AllowDuplicateNodes': False,
'IsAutoImport': True,
'IsHidden': False,
'PluginConfigurations': [
{'PluginConfigurationItem': corePluginConfig},
{'PluginConfigurationItem': interfacesPluginConfig}, # Add your interfaces plugin config here
]
}
print("Running discovery...")
result = swis.invoke('Orion.Discovery', 'StartDiscovery', discoveryProfile)
print("Returned discovery profile id {}".format(result))
requests.packages.urllib3.disable_warnings()
main()