diff --git a/pom.xml b/pom.xml index 4e72487..c830ca5 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ conditions of the subcomponent's license, as noted in the LICENSE file. phpIPAM phpIPAM integration for vRA - 1.0.2 + 1.0.3 false true diff --git a/src/main/python/allocate_ip/requirements.txt b/src/main/python/allocate_ip/requirements.txt index 27bb602..88574fe 100644 --- a/src/main/python/allocate_ip/requirements.txt +++ b/src/main/python/allocate_ip/requirements.txt @@ -1,2 +1,3 @@ requests==2.21.0 -datetime \ No newline at end of file +datetime +ipaddress \ No newline at end of file diff --git a/src/main/python/allocate_ip/source.py b/src/main/python/allocate_ip/source.py index 7bdbd39..fa9e2e1 100644 --- a/src/main/python/allocate_ip/source.py +++ b/src/main/python/allocate_ip/source.py @@ -15,6 +15,7 @@ import requests from vra_ipam_utils.ipam import IPAM import logging from datetime import datetime +import ipaddress """ Example payload @@ -153,10 +154,11 @@ def allocate_in_range(range_id, resource, allocation, context, endpoint, bundle) allocate_req = requests.post(allocate_uri, data=payload, headers=token, verify=cert) allocate_req = allocate_req.json() if allocate_req['success']: + version = ipaddress.ip_address(allocate_req['data']).version result = { "ipAllocationId": allocation['id'], "ipRangeId": range_id, - "ipVersion": "IPv4", + "ipVersion": "IPv" + str(version), "ipAddresses": [allocate_req['data']] } logging.info(f"Successfully reserved {str(result['ipAddresses'])} for {vmName}.")