calculate IP version for allocate_ip; increment to v1.0.3

This commit is contained in:
John Bowdre 2021-02-21 19:04:36 -06:00
parent 11645c7add
commit 2279014db1
3 changed files with 6 additions and 3 deletions

View file

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

View file

@ -1,2 +1,3 @@
requests==2.21.0
datetime
ipaddress

View file

@ -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}.")