Allow for subnets without DNS servers defined in IPAM; increment to v1.0.1

This commit is contained in:
jbowdre 2021-01-26 10:56:36 -06:00
parent 1f71766392
commit 6581fde145
2 changed files with 7 additions and 2 deletions

View file

@ -23,7 +23,7 @@ conditions of the subcomponent's license, as noted in the LICENSE file.
<properties> <properties>
<provider.name>phpIPAM</provider.name> <provider.name>phpIPAM</provider.name>
<provider.description>phpIPAM integration for vRA</provider.description> <provider.description>phpIPAM integration for vRA</provider.description>
<provider.version>1.0</provider.version> <provider.version>1.0.1</provider.version>
<provider.supportsAddressSpaces>false</provider.supportsAddressSpaces> <provider.supportsAddressSpaces>false</provider.supportsAddressSpaces>
<provider.supportsUpdateRecord>true</provider.supportsUpdateRecord> <provider.supportsUpdateRecord>true</provider.supportsUpdateRecord>

View file

@ -75,7 +75,12 @@ 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(';')] # return empty set if no nameservers are defined in IPAM
try:
ipRange['dnsServerAddresses'] = [server.strip() for server in str(subnet['nameservers']['namesrv1']).split(';')]
except:
ipRange['dnsServerAddresses'] = []
# try to get the address marked as the gateway in IPAM
gw_req = requests.get(f"{subnet_uri}/{subnet['id']}/addresses/?filter_by=is_gateway&filter_value=1", headers=token, verify=cert) 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: if gw_req.status_code == 200:
gateway = gw_req.json()['data'][0]['ip'] gateway = gw_req.json()['data'][0]['ip']