Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discovery - Interface Selection (PowerShell) #218

Open
packetmagic opened this issue Mar 5, 2020 · 3 comments
Open

Discovery - Interface Selection (PowerShell) #218

packetmagic opened this issue Mar 5, 2020 · 3 comments

Comments

@packetmagic
Copy link

Setting the InterfacesDiscoveryPluginContext doesn't appear to actually do anything. The discovery works but does not select interfaces based on the option set in InterfacesDiscoveryPluginContext.

When I edit the discovery in the GUI the interface selection settings do not match those set in the code.

Running 2019.4

$InterfacesPluginConfigurationContext = ([xml]"
<InterfacesDiscoveryPluginContext xmlns='http://schemas.solarwinds.com/2008/Interfaces'
                                  xmlns:a='http://schemas.microsoft.com/2003/10/Serialization/Arrays'>
    <AutoImportStatus>
        <a:string>Up</a:string>
    </AutoImportStatus>
    <AutoImportVirtualTypes>
        <a:string>Virtual</a:string>
        <a:string>Physical</a:string>
    </AutoImportVirtualTypes>
    <AutoImportVlanPortTypes>
        <a:string>Trunk</a:string>
    </AutoImportVlanPortTypes>
    <UseDefaults>false</UseDefaults>
</InterfacesDiscoveryPluginContext>
").DocumentElement

 $InterfacesPluginConfiguration = Invoke-SwisVerb $swis Orion.NPM.Interfaces CreateInterfacesPluginConfiguration @($InterfacesPluginConfigurationContext)

$StartDiscoveryContext = ([xml]"
<StartDiscoveryContext xmlns='http://schemas.solarwinds.com/2012/Orion/Core' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'>
	<Name>Script Discovery $([DateTime]::Now)</Name>
	<EngineId>$engindId</EngineId>
	<JobTimeoutSeconds>3600</JobTimeoutSeconds>
	<SearchTimeoutMiliseconds>2000</SearchTimeoutMiliseconds>
	<SnmpTimeoutMiliseconds>2000</SnmpTimeoutMiliseconds>
	<SnmpRetries>1</SnmpRetries>
	<RepeatIntervalMiliseconds>1500</RepeatIntervalMiliseconds>
	<SnmpPort>161</SnmpPort>
	<HopCount>0</HopCount>
	<PreferredSnmpVersion>SNMP2c</PreferredSnmpVersion>
	<DisableIcmp>true</DisableIcmp>
	<AllowDuplicateNodes>false</AllowDuplicateNodes>
	<IsAutoImport>true</IsAutoImport>
	<IsHidden>$DeleteProfileAfterDiscoveryCompletes</IsHidden>
	<PluginConfigurations>
		<PluginConfiguration>
			<PluginConfigurationItem>$($CorePluginConfiguration.InnerXml)</PluginConfigurationItem>
			<PluginConfigurationItem>$($InterfacesPluginConfiguration.InnerXml)</PluginConfigurationItem>
		</PluginConfiguration>
	</PluginConfigurations>
</StartDiscoveryContext>
").DocumentElement
@packetmagic packetmagic changed the title Discovery - Interface Selection Discovery - Interface Selection (PowerShell) Mar 5, 2020
@cberg2048
Copy link

cberg2048 commented Mar 6, 2020

I am experiencing the same issue in Python.

`
def createDiscovery(network, networks, number):
orion_engine_id = 2 # Designate a specific engine to complete discovery
snmpDiscoveryCreds = getCreds()
# Select current subnet for discovery
district = networks[network][2]
subnet = list(networks[network])

# If CIDR
if networks[network][3]:
    sub = {
        'SubnetIP'   :  networks[network][0],
        'SubnetMask' :  networks[network][1]   
    }
    corePluginContext = {
    'Subnets'                       :   [sub],
    'Credentials'                   :   snmpDiscoveryCreds,
    'WmiRetriesCount'               :   0,
    'WmiRetryIntervalMiliseconds'   :   1000,
    'IsDiscoveryForVimEnabled'      :   False
    }
# If range
else:
    iprange = {
        'StartAddress'   :  networks[network][0],
        'EndAddress' :  networks[network][1]   
    }
    corePluginContext = {
    'IpRanges'                      :   [iprange],
    'Credentials'                   :   snmpDiscoveryCreds,
    'WmiRetriesCount'               :   0,
    'WmiRetryIntervalMiliseconds'   :   1000,
    'IsDiscoveryForVimEnabled'      :   False
    }

interfacePluginContext = {
'AutoImportStatus': ['Up'] # Also available: Down, Shutdown
}

# Create core PluginConfigurationItem for Orion
corePluginConfig = swis.invoke('Orion.Discovery', 'CreateCorePluginConfiguration', corePluginContext)

# Create interface PluginConfigurationItem for Orion
interfacePluginConfig = swis.invoke('Orion.NPM.Interfaces', 'CreateInterfacesPluginConfiguration', interfacePluginContext)

# Assign name to profile
if number < 10:
    name = '00'+ str(number) +' - ' + district + ' - ' + network
elif number < 100:
    name = '0'+ str(number) +' - ' + district + ' - ' + network
else:
    name = str(number) +' - ' + district + ' - ' + network
print(name)
# Generate profile
discoveryProfile = {
    'Name': name,
    'EngineID': orion_engine_id,
    'JobTimeoutSeconds': 28800,
    'SearchTimeoutMiliseconds': 5000,
    'SnmpTimeoutMiliseconds': 5000,
    'SnmpRetries': 2,
    'RepeatIntervalMiliseconds': 1800,
    'SnmpPort': 161,
    'HopCount': 0,
    'PreferredSnmpVersion': 'SNMP2c',
    'DisableIcmp': True,
    'AllowDuplicateNodes': False,
    'IsAutoImport': True,
    'IsHidden': False,
    'PluginConfigurations': [{'PluginConfigurationItem': corePluginConfig}, {'PluginConfigurationItem': interfacePluginConfig}]
}
return discoveryProfile`

@markatdxb
Copy link

Apparently this is a bug introduced in 2019.4 version. We used this feature and worked well in 2019.2

@bonickle
Copy link

I know this is old but I working on a discovery script for solarwinds and was stuck on this same issue all day. The command actually works fine, I discovered me, you and bunch of other people were just setting up the xml wrong. If you want to pass multiple plugin configurations it needs to look like the following:

     <PluginConfigurations>
	<PluginConfiguration>
		<PluginConfigurationItem>$($CorePluginConfiguration.InnerXml)</PluginConfigurationItem>
	</PluginConfiguration>
	<PluginConfiguration>
		<PluginConfigurationItem>$($InterfacesPluginConfiguration.InnerXml)</PluginConfigurationItem>
	</PluginConfiguration>
</PluginConfigurations>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants