7 Replies Latest reply on Jul 31, 2015 2:53 PM by slebbon

    Can we create dependencies using the SDK?

    RichardLetts

      I have a couple of thousand switches, for which dependency mapping through a GUI would be painful.: rob.hock descubed that here Re: Alert Chaining

       

      Is there a way to create these programmatically?

      can you share sample code to do this  ( prefer Perl, but can cope with any language)

        • Re: Can we create dependencies using the SDK?
          tdanner

          This is not supported in NPM 11, but you can do it with the NPM 12 betas. In PowerShell, it looks like this:

           

          $swis = Connect-Swis -UserName admin -Password ''

          New-SwisObject $swis Orion.Dependencies @{Name="test1";ParentUri='swis://tdanner-dev.swdev.local/Orion/Orion.Nodes/NodeID=1';ChildUri='swis://tdanner-dev.swdev.local/Orion/Orion.Nodes/NodeID=2'}

           

          You need the SWIS Uri for the parent and child objects in the dependency. The Name property is just a string for your own reference, so it can be anything.

            • Re: Can we create dependencies using the SDK?
              RichardLetts

              Thank you. I'm really looking forward to NPM 12.

              Any idea how this might affect performance (putting 17,000+ dependencies in the system? CPU intensive or database intensive?)

                • Re: Can we create dependencies using the SDK?
                  tdanner

                  That quantity of dependencies would be well beyond what we have tested today. We have already identified some of the bottlenecks that we need to fix to enable that kind of scale. We will have to fix them before we can get to the magical world of automatic dependency mapping Rob mentioned in Re: What aspect of Orion/NPM do you find most annoying?, but in the current version you can expect major problems with database CPU load, CPU load and memory usage in the Data Processor service, and long page load times for certain parts of the website (especially, the "All Dependencies" resource, which doesn't even have paging!).

                  1 of 1 people found this helpful
                • Re: Can we create dependencies using the SDK?
                  slebbon

                  This code doesn't seem to work, was there a change before RTM?  I'm running v11.5 which I think was what v12 beta turned into?

                   

                  I ran:

                   

                  New-SwisObject $swis "Orion.Dependencies" @{Name="AUBal-LAN on Router";ParentUri="swis://myserver.domain/Orion/Orion.Nodes/NodeID=53";ChildUri="swis://myserver.domain/Orion/Orion.Groups/ContainerID=152"}

                   

                  The Orion.Dependencies table was updated with a new row:

                   

                  DependencyId, Name, ParentUri, ChildUri, LastUpdateUTC, AutoManaged, EngineID, Category, ParentEntityType, ParentNetObjectID, ChildEntityType, ChildNetObjectID

                  4, AUBal-LAN on Router, swis://myserver.domain/Orion/Orion.Nodes/NodeID=53, swis://myserver.domain/Orion/Orion.Groups/ContainerID=152, 31/07/2015 16:59:55, False, 0 , 0, UNKNOWN, -1, UNKNOWN, -1

                   

                  Nothing shows up different in the webpage for dependencies.

                  Obviously there is some bits missing from the SDK code, since it didn't define the Parent/Child NetObjectID and EntityTypes.

                   

                  Also is there a good way to remove the bad line?  Should I just delete the row?

                    • Re: Can we create dependencies using the SDK?
                      tdanner

                      Yes, you should delete the row.

                       

                      I'm talking with the dev team about this now. Short answer: there are some extra values you will need to supply to New-SwisObject when creating dependencies. Longer answer: details to follow.

                        • Re: Can we create dependencies using the SDK?
                          tdanner

                          Yes, this was a change between beta and RTM. These extra fields were added to improve UI performance. I'm looking at how we can simplify the API back to what it was in the betas, since these fields can be calculated or looked up just given the ParentUri and ChildUri for the dependency.

                            • Re: Can we create dependencies using the SDK?
                              slebbon

                              Great!  Something similar to how the Group/Container objects are created/updated would make sense to me.  I admit I had assumed that the other fields would get generated from the supplied URIs, like how a filter 'Definition' supplied to the Container object is transformed into the required 'Expression' field as well.

                               

                              In the meantime, do you think I can just pass the additional columns' names and correct values through the hashtable?  It should be pretty easy to split the values returned for the URI.  I might try this on Monday.