Quantcast
Channel: THWACK: All Content - Orion SDK
Viewing all articles
Browse latest Browse all 2677

How to find if a subnet is available for allocation

$
0
0

I'm trying to programmatically create subnets and have run across the following challenge: How do you determine if a subnet is already in use?

 

Here's a snippet from my code, which gets subnet attributes from the database:

 

# Get the subnet attributes
q = swis.query("SELECT TOP 1 " \    "SubnetId, Address, CIDR, Comments, VLAN, Location, Description, URI " \    "FROM IPAM.Subnet "\    "WHERE (Address = '{}' AND CIDR = {})".format(        net.network_address,        net.prefixlen        )

If this returns an empty result set, then we know that the subnet does not exist, which is great. But say I have a subnet allocated already on 10.1.1.0/24, and I ask IPAM if 10.1.1.0/28 is available? It will tell me that the 28 does not exist, which is not what I want.

 

Any ideas?


Viewing all articles
Browse latest Browse all 2677

Trending Articles



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