13 Replies Latest reply on Feb 13, 2019 3:33 PM by jearle

    Python command to create dependencies

    cfy33678

      in a old post found the following command: but what's the existing one please

       

      $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'}

        • Re: Python command to create dependencies
          tdanner

          I don't understand the question. What do you mean by "what's the existing one"?

            • Re: Python command to create dependencies
              cfy33678

              so please what is the command to add dependence with groups in current SDK version?

                • Re: Python command to create dependencies
                  tdanner

                  This API has not changed.

                      • Re: Python command to create dependencies
                        cberg42

                        Cfy33678,

                        Were you able to create dependencies in python, using the python sdk, rather than in powershell?

                         

                        Does anyone know if this is currently possible?

                          • Re: Python command to create dependencies
                            tdanner

                            Like this:

                             

                            import orionsdk

                             

                            swis = orionsdk.SwisClient('myserver', 'myusername', 'mypassword')

                             

                            depUri = swis.create('Orion.Dependencies',

                              Name='test dependency 1',

                              ParentUri='swis://myserver/Orion/Orion.Nodes/NodeID=1',

                              ChildUri='swis://myserver/Orion/Orion.Nodes/NodeID=2')

                            2 of 2 people found this helpful
                              • Re: Python command to create dependencies
                                jearle

                                Hey Tdanner,

                                 

                                I attempted this last night and was successful in creating the dependency I required.

                                I am however attempting it now with the same script and the code is executing fine with no errors but nothing ends up being created.

                                Perhaps there is something that you know of that may cause this.

                                 

                                Thanks,

                                  • Re: Python command to create dependencies
                                    tdanner

                                    Can you post the script you are using?

                                      • Re: Python command to create dependencies
                                        jearle

                                        I actually was able to get it to work. But I am running into another issue now. Though the dependency is created the child is still showing down when the parent is down.

                                         

                                        depUri=swis.create('Orion.Dependencies',

                                                                      Name=name,

                                                                      ParentUri=str(parent['DetailsUrl']),

                                                                      ParentEntityType=str(parent['EntityType']),

                                                                      ParentNetObjectID=str(parent['NodeId']),

                                                                      ChildUri= str(child['DetailsUrl']),

                                                                      ChildEntityType=str(child['EntityType']),

                                                                      ChildNetObjectID=str(child['NodeId']))

                                         

                                        I am wanting the child to be unreachable rather than down. After executing this script the dependency shows accurately under  "Manage Dependencies" but does not seem to work as expected. Are there any additional items it requires to show the child node as unreachable when the parent is down? I am somewhat new to SW so I may be missing something.

                                         

                                          • Re: Python command to create dependencies
                                            tech2734

                                            This is expected behavior I believe.

                                              • Re: Python command to create dependencies
                                                jearle

                                                So the dependency will not set the child as "unreachable" when the parent goes down if you create the dependency using this method? I am creating 4 dependencies for each of 1700 locations. So there is no way I can edit anything manually. is there a way to ensure that the child is "unreachable " when the parent is down when automating the creation of the dependency? Thanks,

                                                  • Re: Python command to create dependencies
                                                    cberg42

                                                    jearle,

                                                    I pass all of the below:

                                                    depUri = swis.create(
                                                       'Orion.Dependencies',
                                                       Name=dep['Name'],
                                                       ParentUri=dep['ParentUri'],
                                                       ChildUri=dep['ChildUri'],
                                                       AutoManaged=False,
                                                       IncludeInStatusCalculation=True,
                                                       EngineID=0,
                                                       Category=0,
                                                       ParentEntityType='Orion.Nodes',
                                                       ParentNetObjectID=parent_net_obj,
                                                       ChildEntityType='Orion.Nodes',
                                                       ChildNetObjectID=child_net_obj,
                                                       Description='Node To Node Dependency'
                                                      )
                                                    

                                                     

                                                    And it marks nodes as unreachable. It acts as if you had made it in the GUI.

                                                      • Re: Python command to create dependencies
                                                        jearle

                                                        Thanks for the quick response! I apologize for the late reply.

                                                        I tried this but as you can see in the screenshot below it never marks the child node as unreachable:

                                                         

                                                             depUri = swis.create('Orion.Dependencies',

                                                         

                                                                Name=name,

                                                                ParentUri=parent['DetailsUrl'],

                                                                ChildUri= child['DetailsUrl'],

                                                                AutoManaged=False,

                                                                IncludeInStatusCalculation=True,

                                                                EngineID=0,

                                                                Category=0,

                                                                ParentEntityType=parent['EntityType'],

                                                                ParentNetObjectID=parent['NodeId'],

                                                                ChildEntityType=child['EntityType'],

                                                                ChildNetObjectID=child['NodeId'],

                                                                Description='Node To Node Dependency')

                                                         

                                                        I have called solar winds about it and they suggested that I change the engine id but that did not work either.

                                                        If anyone has any ideas let me know. I really appreciate the help so far!