I have the following problem :
Some of my colleagues have deploy some VMs by vRA and change the IP address in the Guest OS after the deployment.
So the IP address displayed on the VM properties is not correct, and it's the same for the IP address reserved in the network profile range.
I know how to update the IP address displayed in the properties, it's quite simple, I have build a workflow to update the custom property "VirtualMachine.Network0.Address".
But this action doesn't update the IP address in the network profile ip addresses range, so I have to do it.
I tried to do this by REST API like this:
1) First, I get the network profile properties in an XML object :
GET /iaas-proxy-provider/api/network/profiles/"networkprofileID"
{
"@type": "ExternalNetworkProfile",
"id": "4860fc89-1518-4a0e-8047-7162a1bc61c8",
"name": "TEST-NET1",
"description": "Configured by vRO",
"createdDate": "2018-01-17T14:37:03.000Z",
"lastModifiedDate": "2018-01-17T14:37:03.000Z",
"isHidden": false,
"definedRanges": [
{
"id": "d5e88c81-3195-4afb-83db-6ad0cca88ac3",
"name": "range",
"description": "Configured by vRO",
"beginIPv4Address": "1.252.128.34",
"endIPv4Address": "1.252.128.62",
"state": "UNALLOCATED",
"createdDate": "2018-01-17T14:37:03.000Z",
"lastModifiedDate": "2019-05-16T15:27:45.000Z",
"definedAddresses": [
{
"id": "675e6ec3-a498-44da-a16f-52d92fb150f0",
"staticIPv4RangeId": "d5e88c81-3195-4afb-83db-6ad0cca88ac3",
"IPv4Address": "1.252.128.38",
"IPSortValue": 33325094,
"state": "UNALLOCATED",
"stateValue": 1,
"createdDate": "2018-01-17T14:37:03.000Z",
"lastModifiedDate": "2018-01-17T14:37:03.000Z"
},
{
"id": "f80cc5ed-6be6-4845-b1cb-3ea8b3036a0e",
"staticIPv4RangeId": "d5e88c81-3195-4afb-83db-6ad0cca88ac3",
"virtualMachineId": "6526b667-fcf9-4be9-aa47-98c0dc95a79a",
"virtualMachineName": "test-000094",
"IPv4Address": "1.252.128.45",
"IPSortValue": 33325101,
"state": "ALLOCATED",
"stateValue": 0,
"createdDate": "2018-01-17T14:37:03.000Z",
"lastModifiedDate": "2018-01-17T14:37:03.000Z"
},
2) Then I parse the "defineAddresses" section and update the XML subnode object to free an IP address like :
defineAddress.state = "UNALLOCATED"
defineAddress.stateValue = 1
delete defineAddress.virtualMachineId
delete defineAddress.virtualMachineName
3) And a run a PUT REST API request to update the network profile, the return code is 204 meaning than the update is succeed, BUT if I perform a new GET or check in the vRA web console, the update was not performed.
Any idea on this behavior ?
is it possible to perform an ip address allocation or unallocation by another way or trick ? (excepted by a SQL query in the database of course, because I find this method ugly and unsupported)
Thanks for your help
Regards