17 Replies Latest reply on Jan 15, 2014 11:59 AM by tdanner

    SDK 1.5 invoke with Perl ?

    cacao76

      Hello,

       

      I am just studying the New SDK 1.5 with the examples. I was able to read a node Information and to add a Node with severall properties with the perl client but I am unable to do a invoke operation with perl . Unfortunately there isn't any invoke example in the sample.pl although invoke is defined in the perl module.

      I want to add a Node to the NCM. I got the ID from the node but I was unable to add him with perl.

       

      I tried

       

      print $swis->Invoke('Cirrus.Nodes', 'AddNodeToNCM 1485');

       

       

      What would be the correct syntax for that operation ?

       

       

      Best regards

        • Re: SDK 1.5 invoke with Perl ?
          tdanner

          The version of InformationService.pm distributed with the SDK doesn't have the Invoke operation hooked up correctly. I have updated it and attached a new copy to this reply. I also added an example of how to use it to unmanage a node.

           

          To add a node to NCM, the call would look like this:

           

          $swis->Invoke('Cirrus.Nodes', 'AddNodeToNCM', [1485]);

            • Re: SDK 1.5 invoke with Perl ?
              cacao76

              Hello tdanner,

               

              I tryed the new modul and your syntax for adding a node but I still got an error message.

               

              print $swis->Invoke ('Cirrus.Nodes','AddNodeToNCM',[1498]);

               

              2012-07-02 12:39:08,322 [891] ERROR SolarWinds.InformationService.Core.InformationService - Exception caught in method Invoke

              System.ArgumentNullException: Verb Execution requires an array of parameters

              Parameter name: parameters

                 at

                • Re: SDK 1.5 invoke with Perl ?
                  tdanner

                  I hate to ask you "are you sure it is plugged in?" But the first troubleshooting step that comes to mind is to check that it Perl is actually loading the updated version of InformationService.pm (attached to my previous message in this thread), because the error you are getting is exactly what you would get with the version that's in SDK 1.5.

                  1 of 1 people found this helpful
                    • Re: SDK 1.5 invoke with Perl ?
                      cacao76

                      Hello tdanner,

                       

                      you are right! ! I have two different Perl Installations on my System and I updated the module on the secondary version but perl uses by default the primary version  . Now the Invoke was successfull ! :-))).  Thank you for that awesome client, it's really  very, very helpful for us. Stay tuned with the SDK. The last thing one my wish list is a improved documentation of the verbs and the necessary parameters. e.g. I found the Cirrus.ConfigArchive Download Verb in the v3.0 Schema Documentation but I can't use it currently since it needs 3 parameters which I don't know because they are not mentioned anywhere .

                       

                      Best regards

                       

                      cacao76

                        • Re: SDK 1.5 invoke with Perl ?
                          tdanner

                          Sorry for the long delay! This one fell through the cracks.

                           

                          The arguments for Cirrus.ConfigArchive.Download are:

                          1. NodeIDs - this is an array of the values from the NodeID property of Cirrus.Nodes, which is a GUID. You can query Cirrus.Nodes to look up this guid from the regular Orion integer NodeID values (using the CoreNodeID property of Cirrus.Nodes) or an IP Address.
                          2. Config type - generally this will be either Running or Startup, though you can configure NCM to manage other config types.
                          3. Username - just put the user you are connecting to SWIS with.

                          The tricky part is that I haven't been able to get the perl xml serialization for the array of GUIDs to match up with what the product wants. To get it to work from Perl, I needed to use this syntax:

                           

                          $swis->Invoke("Cirrus.ConfigArchive", "Download", [

                            SOAP::Data->type('xml' => "<ArrayOfguid xmlns='http://schemas.microsoft.com/2003/10/Serialization/Arrays'><guid>0ef3270e-866f-42ca-8114-f464cd2ffd15</guid></ArrayOfguid>"),

                            "Running", "Admin"]);

                           

                          You should be able to adapt that to your needs.

                            • Re: SDK 1.5 invoke with Perl ?
                              thamizh85

                              I was also stuck at the same point. Where to get this documentation to find the necessary arguments for SwisVerbs?

                                • Re: Re: SDK 1.5 invoke with Perl ?
                                  tdanner

                                  For some verbs, we have documentation in the Orion SDK.pdf file installed with the SDK. Others you can figure out from looking at the sample programs.

                                   

                                  But there are a bunch more that don't have written descriptions. You can find out the names and types of the arguments with a query like this:

                                   

                                  SELECT EntityName, VerbName, Position, Name, Type, XmlTemplate, XmlSchemas, IsOptional
                                  FROM Metadata.VerbArgument
                                  WHERE EntityName='Orion.Nodes' AND VerbName='Unmanage'
                                  

                                   

                                  If there's a verb you are interested in and you need more information than these sources provide, just ask in this forum.

                      • Re: SDK 1.5 invoke with Perl ?
                        emarkiewicz

                        Hello tdanner,

                        Quick question here, can I launch a SWIS verb with Perl Invoke?  I've tried about a dozen iterations and get the same error.  The latest is below.


                        print $swis->Invoke('Orion.NPM.Interfaces', 'Orion.NPM.Interfaces.DiscoverInterfacesOnNode', [22]);


                        Error:

                        2012-10-19 12:11:46,257 [3] ERROR SolarWinds.InformationService.Core.InformationService - Exception caught in method Invoke&#xD;

                        SolarWinds.InformationService.Verb.VerbExecutorException: Verb Orion.NPM.Interfaces.Orion.NPM.Interfaces.DiscoverInterfacesOnNode: Not found&#xD;

                           at SolarWinds.InformationService.Verb.VerbCache.GetVerbContext(String entity, String verb, VerbExecutor&amp; executor, VerbExecutorContext&amp; context)&#xD;

                           at SolarWinds.InformationService.Core.InformationService.Invoke(String entity, String verb, XmlElement[] parameters)&#xD;

                        </log></s:Header><s:Body><s:Fault><faultcode>s:Client</faultcode><faultstring xml:lang="en-US">Invoke failed, check fault information.</faultstring><detail><InformationServiceFaultContract xmlns="http://schemas.solarwinds.com/2007/08/informationservice" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Message>Verb Orion.NPM.Interfaces.Orion.NPM.Interfaces.DiscoverInterfacesOnNode: Not found</Message></InformationServiceFaultContract></detail></s:Fault></s:Body></s:Envelope>

                         

                        ~Ed

                        • Re: SDK 1.5 invoke with Perl ?
                          emarkiewicz

                          Tom & everyone,

                          One last question on this subject.  Below is the Perl code I'm using to ~try~ and install interfaces for a node.

                           

                          my $hostname = "<someHost>;

                          my $username = "<UID>";

                          my $password = "<PWD>";

                           

                          my $endpoint = "https://$hostname:17778/SolarWinds/InformationService/v3/OrionBasic";

                          my $swis = SW::InformationService->new();

                          $swis->outputxml("true");

                          $swis->proxy($endpoint);

                          $swis->proxy->ssl_opts(verify_hostname => 0);

                          $swis->proxy->http_request->authorization_basic($username, $password);

                           

                          my @NodeIDToUse = ('22');

                          my $interfaceList =  $swis->Invoke('Orion.NPM.Interfaces', 'DiscoverInterfacesOnNode', [22]);

                          my $interfaceXML = XMLin($interfaceList);

                          #print Dumper($interfaceXML);

                           

                          my $requestStatus = $interfaceXML->{'s:Body'}->{'InvokeResponse'}->{'InvokeResult'}->{'Return'}->{'d1p1:Result'};

                          my $discoveredInterfaces = $interfaceXML->{'s:Body'}->{'InvokeResponse'}->{'InvokeResult'}->{'Return'}->{'d1p1:DiscoveredInterfaces'}->{'d1p1:DiscoveredLiteInterface'};

                           

                          if ($requestStatus eq 'Succeed') {

                             $swis->Invoke('Orion.NPM.Interfaces', 'AddInterfacesOnNode', [22], $discoveredInterfaces, 'AddDefaultPollers');

                          }

                          else {

                              print "We have errors\n\n";

                          }

                           

                           

                          Now, I can get to the "Succeed" part but, when I run the AddInterfacesOnNode I get no errors, but no interfaces for the node can not be found.  I know it's the syntax but what?

                          ~Ed

                            • Re: SDK 1.5 invoke with Perl ?
                              tom.rybka

                              Ed,

                               

                              I can see two problems in your script to fix:

                              1. Invoke service call expects 3 arguments in total: the first and the second indicates which verb to execute, the third argument is however expected to be a list of arguments of the particular verb. So in your case, you should put $discoveredInterfaces and 'AddDefaultPollers' in the list with 22 (specifying a node).

                              2. In place of $discoveredInterfaces, an XML fragment of the response is expected. Unfortunately, the Perl SWIS client in SDK 1.5 (including the fix for Invoke method published on thwack) currently supports only simple data types for arguments, it doesn't recognize any complex type or XML fragments. I'll try to implement the support in the client and come back once I have something to share.

                              • Re: SDK 1.5 invoke with Perl ?
                                tom.rybka

                                Attaching the updated version of Perl SWIS client module that brings support for more complex verb arguments, like list of interfaces required by Orion.NPM.Interfaces.AddInterfacesOnNode verb in your script. For such parameters, it is needed to build SOAP::Data objects that contain xml-serialized structured values which will be embedded in resulting SOAP requests as they are.

                                 

                                In your script (updated version inline below), the list of discovered interfaces are serialized back to XML and converted to corresponding SOAP::Data object passed to the verb as its second argument. I also had to replace XML::Simple with XML::LibXML module. XML::Simple module doesn't keep the order of elements when serializing a previously parsed XML document back to XML text (what happens in the case of list of discovered interfaces). Unfortunately, the valid order of elements is important.

                                 

                                my $hostname = "<someHost>";

                                my $username = "<UID>";

                                my $password = "<PWD>";

                                 

                                my $endpoint = "https://$hostname:17778/SolarWinds/InformationService/v3/OrionBasic";

                                my $swis = SW::InformationService->new();

                                $swis->outputxml("true");

                                $swis->proxy($endpoint);

                                $swis->proxy->ssl_opts(verify_hostname => 0);

                                $swis->proxy->http_request->authorization_basic($username, $password);

                                 

                                my $interfaceList =  $swis->Invoke('Orion.NPM.Interfaces', 'DiscoverInterfacesOnNode', [22]);

                                 

                                my $xmlParser = new XML::LibXML();

                                my $interfaceXML = $xmlParser->parse_string($interfaceList);

                                 

                                my $xpc = new XML::LibXML::XPathContext();

                                $xpc->registerNs('soap', 'http://schemas.xmlsoap.org/soap/envelope/');

                                $xpc->registerNs('swis', 'http://schemas.solarwinds.com/2007/08/informationservice');

                                $xpc->registerNs('sic', 'http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract');

                                $xpc->registerNs('npm', 'http://schemas.solarwinds.com/2008/NPM');

                                 

                                my $requestStatus = $xpc->find('/soap:Envelope/soap:Body/swis:InvokeResponse/swis:InvokeResult/sic:Return/npm:Result', $interfaceXML)->shift()->textContent();

                                 

                                my $discoveredInterfaces = $xpc->find('/soap:Envelope/soap:Body/swis:InvokeResponse/swis:InvokeResult/sic:Return/npm:DiscoveredInterfaces', $interfaceXML)->shift();

                                 

                                if ($requestStatus eq 'Succeed') {

                                   my $discoveredInterfacesSoapList = SOAP::Data->type('xml' => $discoveredInterfaces->toStringC14N());

                                   $swis->Invoke('Orion.NPM.Interfaces', 'AddInterfacesOnNode', [22, $discoveredInterfacesSoapList, 'AddDefaultPollers']);

                                }

                                else {

                                    print "We have errors\n\n";

                                }