Re-add 'owner' tag on phpIPAM reservation note inside 'try' block to work around bug in vRA 8.6

This commit is contained in:
John Bowdre 2021-11-22 16:27:28 -06:00
parent 21ed9d7c66
commit 493452fdbf

View file

@ -145,9 +145,14 @@ def allocate_in_range(range_id, resource, allocation, context, endpoint, bundle)
uri = bundle['uri'] uri = bundle['uri']
token = bundle['token'] token = bundle['token']
cert = bundle['cert'] cert = bundle['cert']
# Attempt to grab 'owner' to work around bug in vRA 8.6 (fixed in 8.6.1)
try:
owner_string = f" for {resource['owner']} "
except:
owner_string = " "
payload = { payload = {
'hostname': vmName, 'hostname': vmName,
'description': f'Reserved by vRA at {datetime.now()}' 'description': f'Reserved by vRA{owner_string}at {datetime.now()}'
} }
allocate_uri = f'{uri}/addresses/first_free/{str(range_id)}/' allocate_uri = f'{uri}/addresses/first_free/{str(range_id)}/'
allocate_req = requests.post(allocate_uri, data=payload, headers=token, verify=cert) allocate_req = requests.post(allocate_uri, data=payload, headers=token, verify=cert)