14 Replies Latest reply on Apr 29, 2016 7:38 AM by jmiddleton

    Perl SDK - Start Discovery - PluginConfigurations

    wlipford

      How can I find what is the least amount of XML to pass to PluginConfigurations?

       

      Here is what I pass: and I get a bad_request error. Basically what I need to know is the bare min, I want to pass a IP address to StartDiscovery and then point it to an already existing Discovery Profile, do not want to create one.

       

        my $discoveryProfileXml = <<"END";

      <CorePluginConfigurationContext xmlns:i='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://schemas.solarwinds.com/2012/Orion/Core'>

               <BulkList>

               <string>$ipAddress</string>

               </BulkList>

              <IpRanges />

              <Subnets />

              <Credentials />

              <WmiRetriesCount>0</WmiRetriesCount>

              <WmiRetryIntervalMiliseconds>0</WmiRetryIntervalMiliseconds>

          </CorePluginConfigurationContext>

      END

       

      *****************************************

      my @pluginConfigurationItems = ({ PluginConfigurationItem => "$discoveryProfileXml" });

       

                  my %startDiscoveryConfiguration = (

                          Name => 'Production Profile 1' ,

                          EngineID => $engineID,

                          JobTimeoutSeconds => 3600,

                          SearchTimeoutMiliseconds => 2000,

                          SnmpTimeoutMiliseconds => 3000,

                      SnmpRetries => 1,

                      RepeatIntervalMiliseconds => 1800,

                      SnmpPort => 161,

                      HopCount => 0,

                      PreferredSnmpVersion => 'SNMP2c',

                      DisableIcmp => 0,

                      AllowDuplicateNodes => 1,

                      IsAutoImport => 1,

                      IsHidden => 0,

                      PluginConfigurations => \@pluginConfigurationItems

                  );

       

                  my @verbArguments = (\%startDiscoveryConfiguration);

                  my $SWServer = $self->{engineconfig}->{OrionConfig}->{"$Region"};

                  my $swhostname = $SWServer->{OrionServer}; # fill in a hostname

                  my $swport = $SWServer->{JSONPort};

                  my $swprotocol = $SWServer->{Protocol};

                  my $SWCredentials = $self->get_credentials($SWServer->{CredentialSetName});

                  my $username = $SWCredentials->{username};

                  my $password = $self->decrypt_password($SWCredentials->{password});

       

                  my $uri = "https://$swhostname:$swport/SolarWinds/InformationService/v3/Json/Invoke/Orion.Discovery/StartDiscovery";

                  my $rest = REST::Client->new();

                  $rest->getUseragent()->proxy(['https']);

                  $rest->getUseragent()->ssl_opts(verify_hostname => 0);

                  my $headers = {

                      Authorization => 'Basic ' . MIME::Base64::encode_base64($username . ':' . $password),

                      'Content-Type' => 'application/json'

                  };

                  my $json = JSON->new->allow_nonref->utf8;

                   my $json_text = $json->space_after->encode(\@verbArguments);

       

                  #print "$json_text\n";

                  my $response = $rest->POST($uri, $json_text, $headers);

                  print Dumper $response;

        • Re: Perl SDK - Start Discovery - PluginConfigurations
          tdanner

          > I want to pass a IP address to StartDiscovery and then point it to an already existing Discovery Profile, do not want to create one


          The problem is that this is not supported. What you want to do makes sense, but the API does not have a provision for editing an existing discovery profile or running and existing one with a different IP. You have to start from scratch.

            • Re: Perl SDK - Start Discovery - PluginConfigurations
              wlipford

              Ok, is this a future feature request?

               

              With that said, can you give me a perl example of start discovery process with using multiple SNMP community strings? My issue is that without knowing the XML input required / no required payload its difficult to generate.

               

              If I can't use an existing profile then I will need to generate one with 10 different strings to try when discovery is running.

                • Re: Perl SDK - Start Discovery - PluginConfigurations
                  wlipford

                  Can I get an example of a discovery profile that has multiple community strings and also one that uses SNMP v3. Can't find anything on Thwack or documents displaying this.

                    • Re: Perl SDK - Start Discovery - PluginConfigurations
                      tdanner

                      If you don't mind Python, here's a script. Translating to perl shouldn't be hard. This one imports the SwisClient.py module (source on github: OrionSDK/SwisClient.py at master · solarwinds/OrionSDK · GitHub).

                       

                      from SwisClient import SwisClient

                       

                       

                      swis = SwisClient('localhost', 'admin', '')
                      config = swis.invoke('Orion.Discovery', 'CreateCorePluginConfiguration',
                      {
                        'BulkList': [{'Address':'10.199.10.12'}],
                        #'IpRanges': [], # Optional
                        #'Subnets': None, # Optional
                        'Credentials': [
                          {'CredentialID':1, 'Order':1},
                          {'CredentialID':2, 'Order':2},
                        ],
                        'WmiRetriesCount': 1,
                        'WmiRetryIntervalMiliseconds': 1000
                      })
                      
                      disco = swis.invoke('Orion.Discovery', 'StartDiscovery',
                      {
                        'Name': 'SDKDiscovery',
                        'EngineId': 1,
                        'JobTimeoutSeconds': 3600,
                        'SearchTimeoutMiliseconds': 2000,
                        'SnmpTimeoutMiliseconds': 2000,
                        'SnmpRetries': 4,
                        'RepeatIntervalMiliseconds': 1800,
                        'SnmpPort': 161,
                        'HopCount': 0,
                        'PreferredSnmpVersion': 'SNMP2c',
                        'DisableIcmp': False,
                        'AllowDuplicateNodes': False,
                        'IsAutoImport': True,
                        'IsHidden': True,
                        'PluginConfigurations': [
                          {'PluginConfigurationItem': config}
                        ]
                      })
                      

                       

                      Credentials are included in the script by reference. The CredentialID values come from the Orion.Credential entity. This is the same set of credentials that is used to populate the credential pickers in the website. Unfortunately, we don't have an API for adding or changing them, but you can use the website to create the ones you need and then reference them from the script.

                      1 of 1 people found this helpful
                  • Re: Perl SDK - Start Discovery - PluginConfigurations
                    wlipford

                    Tim,

                     

                    If i have to create a discovery I want to build it like a system one, I am having trouble w/ the XML payload syntax. I want to be able to send 15 different SNMP Community strings to try. I saw this post -> Re: 10.4.1 - use of Orion.Discovery verbs

                     

                    That has multiple credentialsets, so I want same sorta thing with multiple community strings.

                     

                    What is the best method to determine a discovery has completed? I see references in the API to discovery progress but no examples, sometimes our discovery can take 5 mins or more.

                      • Re: Perl SDK - Start Discovery - PluginConfigurations
                        tdanner

                        Sorry it has taken me so long to reply to this thread. I'm working on an example script for you. Our existing examples for discovery are kind of all over the place - some perl, some powershell. I need a little more time to finish writing and testing a new one. I'll post it here when it is done.

                        • Re: Perl SDK - Start Discovery - PluginConfigurations
                          tdanner

                          When you call Orion.Discovery.StartDiscovery, the return value is the value of Orion.DiscoveryProfiles.ProfileID. You can query "SELECT ProfileID FROM Orion.DiscoveryProfiles WHERE ProfileID=123" (replacing 123 with the actual ProfileID for the current run) to see if it is still running. Assuming you have set IsHidden=true, the profile will disappear when it completes.

                           

                          Also when it completes, an entry for that ProfileID will appear in Orion.DiscoveryLogs. Entries in DiscoveryLogs have a BatchID. This BatchID can be used to filter Orion.DiscoveryLogItems and see what objects (nodes, interfaces, etc.) were imported by that discovery job.

                            • Re: Perl SDK - Start Discovery - PluginConfigurations
                              wlipford

                              I am on my final piece of the puzzle for my automation to give next week, the last piece is something I skipped over a few months back and had asked on Thwack which I believe you answered but in Python. I am not much a python guy but I have it a whirl to convert today. 

                               

                              Any way you can have a look and tell me what’s wrong?

                               

                               

                              YOUR PYTHON EXAMPLE:

                               

                              sub orion_automanage() - Modify

                               

                               

                                   swis = SwisClient('localhost', 'admin', '') 

                                  config = swis.invoke('Orion.Discovery', 'CreateCorePluginConfiguration', 

                                  { 

                                    'BulkList': [{'Address':'10.199.10.12'}], 

                                    #'IpRanges': [], # Optional 

                                    #'Subnets': None, # Optional 

                                    'Credentials': [ 

                                      {'CredentialID':1, 'Order':1}, 

                                      {'CredentialID':2, 'Order':2}, 

                                    ], 

                                    'WmiRetriesCount': 1, 

                                    'WmiRetryIntervalMiliseconds': 1000 

                                  }) 

                                   

                                  disco = swis.invoke('Orion.Discovery', 'StartDiscovery', 

                                  { 

                                    'Name': 'SDKDiscovery', 

                                    'EngineId': 1, 

                                    'JobTimeoutSeconds': 3600, 

                                    'SearchTimeoutMiliseconds': 2000, 

                                    'SnmpTimeoutMiliseconds': 2000, 

                                    'SnmpRetries': 4, 

                                    'RepeatIntervalMiliseconds': 1800, 

                                    'SnmpPort': 161, 

                                    'HopCount': 0, 

                                    'PreferredSnmpVersion': 'SNMP2c', 

                                    'DisableIcmp': False, 

                                    'AllowDuplicateNodes': False, 

                                    'IsAutoImport': True, 

                                    'IsHidden': True, 

                                    'PluginConfigurations': [ 

                                      {'PluginConfigurationItem': config} 

                                    ] 

                                  }) 

                               

                               

                               

                              MY ATTEMPT AT CONVERTING TO PERL:

                               

                               

                                    my %discoveryProfileXml = (

                              BulkList => [{ Address => $ipAddress}],

                              Credentials => [{ CredentialID => 1, Order => 1}],

                              WmiRetriesCount => 0,

                              WmiRetryIntervalMiliseconds => 0);

                               

                                      my $json_test = encode_json(\%discoveryProfileXml);

                               

                               

                                      my %startDiscoveryConfiguration = (

                              Name => 'Discovery API Profile' ,

                              EngineID => $engineID,

                              JobTimeoutSeconds => 3600,

                              SearchTimeoutMiliseconds => 4000,

                              SnmpTimeoutMiliseconds => 4000,

                              SnmpRetries => 3,

                              RepeatIntervalMiliseconds => 1800,

                              SnmpPort => 161,

                              HopCount => 0,

                              PreferredSnmpVersion => 'SNMP2c',

                              DisableIcmp => 0,

                              AllowDuplicateNodes => 1,

                              IsAutoImport => 1,

                              IsHidden => 1,

                              PluginConfigurations => { PluginConfigurationItem => $json_test }

                              );

                               

                              my @verbArguments = (\%startDiscoveryConfiguration);

                              my $SWServer = $self->{engineconfig}->{OrionConfig}->{"$Region"};

                              my $swhostname = $SWServer->{OrionServer}; # fill in a hostname

                              my $swport = $SWServer->{JSONPort};

                              my $swprotocol = $SWServer->{Protocol};

                              my $SWCredentials = $self->get_credentials($SWServer->{CredentialSetName});

                              my $username = $SWCredentials->{username};

                              my $password = $self->decrypt_password($SWCredentials->{password});

                               

                              my $uri = "https://$swhostname:$swport/SolarWinds/InformationService/v3/Json/Invoke/Orion.Discovery/StartDiscovery";

                              my $rest = REST::Client->new();

                              $rest->getUseragent()->proxy(['https']);

                              $rest->getUseragent()->ssl_opts(verify_hostname => 0);

                              my $headers = {

                              Authorization => 'Basic ' . MIME::Base64::encode_base64($username . ':' . $password),

                              'Content-Type' => 'application/json'

                              };

                              my $json = JSON->new->allow_nonref->utf8;

                              my $json_text = $json->space_after->encode(\@verbArguments);

                               

                              my $response = $rest->POST($uri, $json_text, $headers);

                              print Dumper $response;

                               

                               

                              Here it the $json_desc output on print which looks correct: -> {"BulkList":[{"Address":"172.20.72.26"}],"WmiRetryIntervalMiliseconds":0,"Credentials":[{"Order":1,"CredentialID":1}],"WmiRetriesCount":0}

                               

                              I see it complaining about “"Message":"Verb Orion.Discovery.StartDiscovery cannot unpackage parameter 0",”

                               

                              Then here is the full output error,

                               

                              R1 = bless( {

                              '_config' => {

                              'useragent' => bless( {

                              'max_redirect' => 7,

                              'ssl_opts' => {

                              'verify_hostname' => 0

                              },

                              'protocols_forbidden' => undef,

                              'show_progress' => undef,

                              'handlers' => {

                              'response_header' => bless( [

                              {

                              'owner' => 'LWP::UserAgent::parse_head',

                              'callback' => sub { "DUMMY" },

                              'm_media_type' => 'html',

                              'line' => '/home/autoeng/lib/perl5/LWP/UserAgent.pm:684'

                              }

                              ], 'HTTP::Config' )

                              },

                              'no_proxy' => [],

                              'protocols_allowed' => undef,

                              'local_address' => undef,

                              'use_eval' => 1,

                              'requests_redirectable' => [

                              'GET',

                              'HEAD'

                              ],

                              'timeout' => 300,

                              'def_headers' => bless( {

                              'user-agent' => 'REST::Client/272'

                              }, 'HTTP::Headers' ),

                              'proxy' => {},

                              'max_size' => undef

                              }, 'LWP::UserAgent' )

                              },

                              '_res' => bless( {

                              '_protocol' => 'HTTP/1.1',

                              '_content' => '{"Message":"Verb Orion.Discovery.StartDiscovery cannot unpackage parameter 0","ExceptionType":"SolarWinds.InformationService.Verb.VerbExecutorException","FullException":"SolarWinds.InformationService.Verb.VerbExecutorException: Verb Orion.Discovery.StartDiscovery cannot unpackage parameter 0 ---> Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON object (e.g. {\\"name\\":\\"value\\"}) into type \'System.Collections.Generic.List`1[SolarWinds.Data.Providers.Orion.Verbs.Discovery+PluginConfiguration]\' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.\\u000d\\u000aTo fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.\\u000d\\u000aPath \'PluginConfigurations.PluginConfigurationItem\'.\\u000d\\u000a   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\\u000d\\u000a   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\\u000d\\u000a   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)\\u000d\\u000a   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)\\u000d\\u000a   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\\u000d\\u000a   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\\u000d\\u000a   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)\\u000d\\u000a at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)\\u000d\\u000a   at SolarWinds.InformationService.Verb.VerbExecutorContext.UnpackageParameters(JArray parameters)\\u000d\\u000a   --- End of inner exception stack trace ---\\u000d\\u000a   at SolarWinds.InformationService.Verb.VerbExecutorContext.UnpackageParameters(JArray parameters)\\u000d\\u000a   at SolarWinds.InformationService.Core.InformationService.InvokeInternal[T](String entity, String verb, Action`1 setupParameters, Func`2 extractReturnValue)\\u000d\\u000a   at SolarWinds.InformationService.Core.InformationService.SolarWinds.InformationService.Core.IRestInformationService.Invoke(String entity, String verb, Object parameters)"}',

                              '_rc' => '400',

                              '_headers' => bless( {

                              'client-response-num' => 1,

                              'date' => 'Tue, 29 Dec 2015 21:22:12 GMT',

                              'client-ssl-cert-issuer' => '/CN=SolarWinds-Orion',

                              'client-ssl-cipher' => 'ECDHE-RSA-AES256-SHA384',

                              'client-peer' => '172.20.194.23:17778',

                              'content-length' => '3452',

                              '::std_case' => {

                              'client-date' => 'Client-Date',

                              'client-ssl-warning' => 'Client-SSL-Warning',

                              'client-response-num' => 'Client-Response-Num',

                              'client-ssl-cert-subject' => 'Client-SSL-Cert-Subject',

                              'client-ssl-cert-issuer' => 'Client-SSL-Cert-Issuer',

                              'client-ssl-cipher' => 'Client-SSL-Cipher',

                              'client-peer' => 'Client-Peer',

                              'client-ssl-socket-class' => 'Client-SSL-Socket-Class'

                              },

                              'client-date' => 'Tue, 29 Dec 2015 21:22:13 GMT',

                              'client-ssl-warning' => 'Peer certificate not verified',

                              'content-type' => 'application/json',

                              'client-ssl-cert-subject' => '/CN=SolarWinds-Orion',

                              'server' => 'Microsoft-HTTPAPI/2.0',

                              'client-ssl-socket-class' => 'Net::SSL'

                              }, 'HTTP::Headers' ),

                              '_msg' => 'Bad Request',

                              '_request' => bless( {

                              '_content' => '[{"EngineID": 1, "SnmpPort": 161, "PluginConfigurations": {"PluginConfigurationItem": "{\\"BulkList\\":[{\\"Address\\":\\"172.20.72.26\\"}],\\"WmiRetryIntervalMiliseconds\\":0,\\"Credentials\\":[{\\"Order\\":1,\\"CredentialID\\":1}],\\"WmiRetriesCount\\":0}"}, "IsAutoImport": 1, "AllowDuplicateNodes": 1, "DisableIcmp": 0, "SnmpTimeoutMiliseconds": 4000, "JobTimeoutSeconds": 3600, "SnmpRetries": 3, "PreferredSnmpVersion": "SNMP2c", "HopCount": 0, "IsHidden": 1, "Name": "Discovery API Profile", "SearchTimeoutMiliseconds": 4000, "RepeatIntervalMiliseconds": 1800}]',

                              '_uri' => bless( do{\(my $o = 'https://asbwdnmsswapp01.vlab.corp.tnsi.com:17778/SolarWinds/InformationService/v3/Json/Invoke/Orion.Discovery/StartDiscovery')}, 'URI::https' ),

                              '_headers' => bless( {

                              'user-agent' => 'REST::Client/272',

                              'content-type' => 'application/json',

                              'content-length' => 551,

                              '::std_case' => {

                              'if-ssl-cert-subject' => 'If-SSL-Cert-Subject'

                              },

                              'authorization' => 'Basic YXV0b2JvdG9yaW9uOk1lZUZhSDAwY2g6

                              '

                              }, 'HTTP::Headers' ),

                              '_method' => 'POST',

                              '_uri_canonical' => $VAR1->{'_res'}{'_request'}{'_uri'}

                              }, 'HTTP::Request' )

                              }, 'HTTP::Response' )

                              }, 'REST::Client' );

                               

                               

                               

                              Here is what the Json Payload looks like:

                               

                              [{"EngineID": 1, "SnmpPort": 161, "PluginConfigurations": {"PluginConfigurationItem": "{\"BulkList\":[{\"Address\":\"172.20.72.26\"}],\"WmiRetryIntervalMiliseconds\":0,\"Credentials\":[{\"Order\":1,\"CredentialID\":1}],\"WmiRetriesCount\":0}"}, "IsAutoImport": 1, "AllowDuplicateNodes": 1, "DisableIcmp": 0, "SnmpTimeoutMiliseconds": 4000, "JobTimeoutSeconds": 3600, "SnmpRetries": 3, "PreferredSnmpVersion": "SNMP2c", "HopCount": 0, "IsHidden": 1, "Name": "Discovery API Profile", "SearchTimeoutMiliseconds": 4000, "RepeatIntervalMiliseconds": 1800}]

                                • Re: Perl SDK - Start Discovery - PluginConfigurations
                                  tdanner

                                  This appears to be the problem. In Python, we have this:

                                   

                                  'PluginConfigurations': [

                                          {'PluginConfigurationItem': config}

                                        ]

                                   

                                  Which means that in the python dictionary we are building, the key PluginConfigurations should have a value consisting of a list with one item that is a dictionary with one key, PluginConfigurationItem, whose value is the current value of the variable config.

                                   

                                  But in Perl, we have this:

                                   

                                  PluginConfigurations => { PluginConfigurationItem => $json_test }

                                   

                                  Which means that in the perl hash we are building, the key PluginConfigurations should have a value consisting of a hash with one key, PluginConfigurationItem, whose value is the current value of the variable $json_test. It needs to be a list with one item that is that hash.

                                   

                                  I think this will do what you need:

                                   

                                  PluginConfigurations => [ { PluginConfigurationItem => $json_test } ]

                                   

                                  Let me know if that works for you.

                                    • Re: Perl SDK - Start Discovery - PluginConfigurations
                                      wlipford

                                      How do I map parameter 0 to my input ? Not sure which one it doesn't like.

                                       

                                      I switched my perl code to ->

                                        my %startDiscoveryConfiguration = (

                                                      Name => 'Discovery API Profile' ,

                                                      EngineID => $engineID,

                                                      JobTimeoutSeconds => 3600,

                                                      SearchTimeoutMiliseconds => 4000,

                                                      SnmpTimeoutMiliseconds => 4000,

                                                      SnmpRetries => 3,

                                                      RepeatIntervalMiliseconds => 1800,

                                                      SnmpPort => 161,

                                                      HopCount => 0,

                                                      PreferredSnmpVersion => 'SNMP2c',

                                                      DisableIcmp => 0,

                                                      AllowDuplicateNodes => 1,

                                                      IsAutoImport => 1,

                                                      IsHidden => 1,

                                                      PluginConfigurations => [ { PluginConfigurationItem => \%discoveryProfileXml } ]

                                                  );

                                       

                                      JSON Payload looks good  ->

                                       

                                      '_request' => bless( {

                                                                                                 '_content' => '[{"EngineID": 1, "SnmpPort": 161, "PluginConfigurations": [{"PluginConfigurationItem": {"BulkList": {"Address": "172.20.72.26"}, "WmiRetryIntervalMiliseconds": 0, "Credentials": {"Order": 1, "CredentialID": 1}, "WmiRetriesCount": 0}}], "IsAutoImport": 1, "AllowDuplicateNodes": 1, "DisableIcmp": 0, "SnmpTimeoutMiliseconds": 4000, "JobTimeoutSeconds": 3600, "SnmpRetries": 3, "PreferredSnmpVersion": "SNMP2c", "HopCount": 0, "IsHidden": 1, "Name": "Discovery API Profile", "SearchTimeoutMiliseconds": 4000, "RepeatIntervalMiliseconds": 1800}]'

                                       

                                       

                                      Same Error ->

                                       

                                      '_content' => '{"Message":"Verb Orion.Discovery.StartDiscovery cannot unpackage parameter 0","ExceptionType":"SolarWinds.InformationService.Verb.VerbExecutorException","FullException":"SolarWinds.InformationService.Verb.VerbExecutorException: Verb Orion.Discovery.StartDiscovery cannot unpackage parameter 0 ---> Newtonsoft.Json.JsonReaderException: Error reading string. Unexpected token: StartObject. Path \'PluginConfigurations[0].PluginConfigurationItem\'.\\u000d\\u000a   at Newtonsoft.Json.JsonReader.ReadAsStringInternal()\\u000d\\u000a   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter)\\u000d\\u000a   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)\\u000d\\u000a   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\\u000d\\u000a   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\\u000d\\u000a   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IWrappedCollection wrappedList, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)\\u000d\\u000a   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)\\u000d\\u000a   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\\u000d\\u000a   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)\\u000d\\u000a   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)\\u000d\\u000a   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\\u000d\\u000a   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\\u000d\\u000a   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)\\u000d\\u000a   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)\\u000d\\u000a   at SolarWinds.InformationService.Verb.VerbExecutorContext.UnpackageParameters(JArray parameters)\\u000d\\u000a   --- End of inner exception stack trace ---\\u000d\\u000a   at SolarWinds.InformationService.Verb.VerbExecutorContext.UnpackageParameters(JArray parameters)\\u000d\\u000a   at SolarWinds.InformationService.Core.InformationService.InvokeInternal[T](String entity, String verb, Action`1 setupParameters, Func`2 extractReturnValue)\\u000d\\u000a   at SolarWinds.InformationService.Core.InformationService.SolarWinds.InformationService.Core.IRestInformationService.Invoke(String entity, String verb, Object parameters)"}',

                                        • Re: Perl SDK - Start Discovery - PluginConfigurations
                                          tdanner

                                          StartDiscovery only takes one parameter, so "parameter 0" is the whole thing you are sending.

                                           

                                          Here's what I missed last time I read your code: you are creating %discoveryProfileXml as a perl hash and then sending that as the PluginConfigurationItem directly. The goofy thing (one of the goofy things...) about this API is that you don't send those options to StartDiscovery directly. Instead, you send them to CreateCorePluginConfiguration, which does some validation, processing, and conversion on them and returns you back a string (that is actually XML, but this doesn't matter - for your purposes it is just a string) and you use that string as the value of PluginConfigurationItem.

                                           

                                          Please look at the python code again for how to call CreateCorePluginConfiguration.

                                            • Re: Perl SDK - Start Discovery - PluginConfigurations
                                              wlipford

                                              Tim,


                                              Ok, I see what you mean now. So I now invoke CreateCorePluginConfiguration and it returns the XML as expected, but doesn't seem to be formatted correctly to simply pass to StartDiscovery. As you can see its adding -> <?xml version=\"1.0\" encoding=\"utf-16\"?>

                                               

                                              This is coming off  $rest->POST($uri, $json_text, $headers).

                                               

                                              my $xmlResponse = $rest->responseContent();

                                                        print "RawXMLReponse: ".$xmlResponse;

                                               

                                              Here is the returned XML Payload:

                                               

                                              RawXMLReponse: "<?xml version=\"1.0\" encoding=\"utf-16\"?><PluginItems><knownTypes><ArrayOfstring xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\"><string>SolarWinds.Orion.Core.Models.Discovery.CoreDiscoveryPluginConfiguration,SolarWinds.Orion.Core.Models</string></ArrayOfstring></knownTypes><pluginItem><ArrayOfDiscoveryPluginConfigurationBase xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.datacontract.org/2004/07/SolarWinds.Orion.Core.Models.Discovery\"><DiscoveryPluginConfigurationBase xmlns:d2p1=\"http://schemas.solarwinds.com/2008/Orion\" i:type=\"d2p1:CoreDiscoveryPluginConfiguration\"><d2p1:AddressRange /><d2p1:AgentsAddresses xmlns:d3p1=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\" /><d2p1:BulkList xmlns:d3p1=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\"><d3p1:string>172.20.72.26</d3p1:string></d2p1:BulkList><d2p1:Credentials><d2p1:credentials><knownTypes><ArrayOfstring xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\" /></knownTypes><pluginItem><d2p1:ArrayOfCredential xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" /></pluginItem></d2p1:credentials></d2p1:Credentials><d2p1:DiscoverAgentNodes>false</d2p1:DiscoverAgentNodes><d2p1:SharedCredentials xmlns:d3p1=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\"><d3p1:KeyValueOfintint><d3p1:Key>1</d3p1:Key><d3p1:Value>1</d3p1:Value></d3p1:KeyValueOfintint></d2p1:SharedCredentials><d2p1:SubnetList /><d2p1:WmiRetries>0</d2p1:WmiRetries><d2p1:WmiRetryInterval>PT0S</d2p1:WmiRetryInterval></DiscoveryPluginConfigurationBase></ArrayOfDiscoveryPluginConfigurationBase></pluginItem></PluginItems>"

                                               

                                               

                                              Before I started down this road I built the XML by hand and it looked like this (and it worked):

                                               

                                              <PluginItems xmlns="http://schemas.datacontract.org/2004/07/SolarWinds.Orion.Core.Models.Discovery">

                                                      <knownTypes>

                                                              <ArrayOfstring xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">

                                                                      <string>SolarWinds.Orion.Core.Models.Discovery.CoreDiscoveryPluginConfiguration,SolarWinds.Orion.Core.Models</string>

                                                              </ArrayOfstring>

                                                      </knownTypes>

                                                      <pluginItem>

                                                              <ArrayOfDiscoveryPluginConfigurationBase xmlns:i="http://www.w3.org/2001/XMLSchema-instance">

                                                                      <DiscoveryPluginConfigurationBase i:type="d2p1:CoreDiscoveryPluginConfiguration" xmlns:d2p1="http://schemas.solarwinds.com/2008/Orion">

                                                                              <d2p1:AddressRange/>

                                                                              <d2p1:AgentsAddresses xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>

                                                                              <d2p1:BulkList xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">

                                                                                      <d3p1:string>$ipAddress</d3p1:string>

                                                                              </d2p1:BulkList>

                                                                              <d2p1:Credentials>

                                                                                      <d2p1:credentials>

                                                                                              <knownTypes>

                                                                                                      <ArrayOfstring xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">

                                                                                                              <string>SolarWinds.Orion.Core.Models.Credentials.SnmpCredentialsV2,SolarWinds.Orion.Core.Models</string>

                                                                                                      </ArrayOfstring>

                                                                                              </knownTypes>

                                                                                              <pluginItem>

                                                                                                      <d2p1:ArrayOfCredential>

                                                                                                              <d2p1:Credential i:type="d2p1:SnmpCredentialsV2">

                                                                                                                      <d2p1:Description i:nil="true"/>

                                                                                                                      <d2p1:ID i:nil="true"/>

                                                                                                                      <d2p1:IsBroken>false</d2p1:IsBroken>

                                                                                                                      <d2p1:Name>mud</d2p1:Name>

                                                                                                                      <d2p1:Owner i:nil="true"/>

                                                                                                                      <d2p1:Community>$snmpCommunityString</d2p1:Community>

                                                                                                              </d2p1:Credential>

                                                                                                      </d2p1:ArrayOfCredential>

                                                                                              </pluginItem>

                                                                                      </d2p1:credentials>

                                                </d2p1:Credentials>

                                                                              <d2p1:DiscoverAgentNodes>false</d2p1:DiscoverAgentNodes>

                                                                              <d2p1:SharedCredentials xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>

                                                                              <d2p1:SubnetList/>

                                                                              <d2p1:WmiRetries>1</d2p1:WmiRetries>

                                                                              <d2p1:WmiRetryInterval>PT10S</d2p1:WmiRetryInterval>

                                                                      </DiscoveryPluginConfigurationBase>

                                                              </ArrayOfDiscoveryPluginConfigurationBase>

                                                      </pluginItem>

                                              </PluginItems>