mirror of
https://github.com/jbowdre/phpIPAM-for-vRA8.git
synced 2024-11-27 01:12:19 +00:00
only get subnets marked as pools; capture gatewayAddress and dnsServerAddresses
This commit is contained in:
parent
2b9ab9a710
commit
c7be21c307
1 changed files with 6 additions and 2 deletions
|
@ -63,8 +63,8 @@ def do_get_ip_ranges(self, auth_credentials, cert):
|
||||||
# Request list of subnets
|
# Request list of subnets
|
||||||
subnet_uri = f'{uri}/subnets/'
|
subnet_uri = f'{uri}/subnets/'
|
||||||
ipRanges = []
|
ipRanges = []
|
||||||
req = requests.get(subnet_uri, headers=token, verify=cert)
|
subnet_req = requests.get(f'{subnet_uri}?filter_by=isPool&filter_value=1', headers=token, verify=cert)
|
||||||
subnets = req.json()['data']
|
subnets = subnet_req.json()['data']
|
||||||
for subnet in subnets:
|
for subnet in subnets:
|
||||||
ipRange = {}
|
ipRange = {}
|
||||||
ipRange['id'] = str(subnet['id'])
|
ipRange['id'] = str(subnet['id'])
|
||||||
|
@ -76,6 +76,10 @@ def do_get_ip_ranges(self, auth_credentials, cert):
|
||||||
ipRange['startIPAddress'] = str(network[10])
|
ipRange['startIPAddress'] = str(network[10])
|
||||||
ipRange['endIPAddress'] = str(network[-6])
|
ipRange['endIPAddress'] = str(network[-6])
|
||||||
ipRange['subnetPrefixLength'] = str(subnet['mask'])
|
ipRange['subnetPrefixLength'] = str(subnet['mask'])
|
||||||
|
ipRange['dnsServerAddresses'] = [server.strip() for server in str(subnet['nameservers']['namesrv1']).split(';')]
|
||||||
|
gw_req = requests.get(f"{subnet_uri}/{subnet['id']}/addresses/?filter_by=is_gateway&filter_value=1", headers=token, verify=cert)
|
||||||
|
if gw_req.status_code == 200:
|
||||||
|
ipRange['gatewayAddress'] = gw_req.json()['data'][0]['ip']
|
||||||
logging.debug(ipRange)
|
logging.debug(ipRange)
|
||||||
ipRanges.append(ipRange)
|
ipRanges.append(ipRange)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue