Quantcast
Viewing all articles
Browse latest Browse all 2677

Stuck - Orion SDK - Python Get Next 2 IP Address from a list of Subnets in IPAM

I am extremely new to Orion SDK and have much to learn.  I have been really struggling over the last several days with performing a task that I responsible for.  We have a cloud environment that is constantly changing in that we are spinning up and tearing down VPCs.  For each of the deployments there are dual virtual routers that I configure with GRE tunnels for connectivity.   I have everything automated with the exception of the IP Addressing for the GRE tunnels.  I have approximately 200 /30 subnets that I've added to IPAM. 100 for prod & 100 for nonprod.  During my automation script after the routers are launched, I am trying to use Orion SDK to get the next two IP addresses within the same /30 subnet so that the script can use those IP addresses and auto build the GRE tunnel and connectivity. Everything seemed to be working fine with the syntax below, until I decided to test what would happen if someone accidentally put one of the ip addresses in IPAM into a "used" status.  I thought that would just cause the script go to the next /30 Subnet that had two available ip addresses with a comment of "AWS-Prod_GRE_Tunnels"; however, that is not what is occuring.  Instead it returns the other ip address that is available and one address from the next subnet.  How do I make sure I only get two available IP address from the same /30?  I thought using the "SubnetId" would take care of that, but clearly I am missing something.  In the example below, Orion should have returned the two IP address that have a subnetid of 2286 since they are the next two available in the same subnet matching the comments.

 

Any feedback and or suggestions will be greatly appreciated. 

 

SELECT TOP 2 IPAddress, SubnetId FROM IPAM.IPNode WHERE Status=2 and SubnetId IN (SELECT TOP 2 SubnetId From IPAM.Subnet as s WHERE Comments='AWS-Prod_GRE_Tunnels')

 

Image may be NSFW.
Clik here to view.
Example of the SWQL query

 

Image may be NSFW.
Clik here to view.
Second Example

 

 

Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 2677

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>