improved logging for get_ip_ranges

This commit is contained in:
jbowdre 2020-11-09 11:25:55 -06:00
parent 4a47e20c72
commit 6543865597

View file

@ -34,6 +34,7 @@ def do_get_ip_ranges(self, auth_credentials, cert):
result_ranges = [] result_ranges = []
qResult = swis.query("SELECT DISTINCT GroupID AS id, FriendlyName AS name, Address AS addressSpaceId, CIDR AS subnetPrefixLength, Comments AS description, i.CustomProperties.Gateway as gatewayAddress, i.CustomProperties.DNS_Servers as dnsServers, i.CustomProperties.Site_ID AS siteId FROM IPAM.GroupNode i WHERE GroupTypeText LIKE 'Subnet' AND i.CustomProperties.VRA_Range = TRUE") qResult = swis.query("SELECT DISTINCT GroupID AS id, FriendlyName AS name, Address AS addressSpaceId, CIDR AS subnetPrefixLength, Comments AS description, i.CustomProperties.Gateway as gatewayAddress, i.CustomProperties.DNS_Servers as dnsServers, i.CustomProperties.Site_ID AS siteId FROM IPAM.GroupNode i WHERE GroupTypeText LIKE 'Subnet' AND i.CustomProperties.VRA_Range = TRUE")
for range in qResult['results']: for range in qResult['results']:
logging.info(f"Found subnet: {str(range['name'])}")
network = ipaddress.ip_network(str(range['addressSpaceId']) + '/' + str(range['subnetPrefixLength'])) network = ipaddress.ip_network(str(range['addressSpaceId']) + '/' + str(range['subnetPrefixLength']))
range['ipVersion'] = 'IPv' + str(network.version) range['ipVersion'] = 'IPv' + str(network.version)
range['startIPAddress'] = str(network[10]) range['startIPAddress'] = str(network[10])