User Tools

Site Tools


vrealize:bugs:movevm

Assigning a new Network Profile

For some stupid reason. vmware has never provied a way to update (and RELEASE) and IP if somebody changes the VLAN and/or IP of a deployed VM.

This is a HUGE HACK directly into the vRA database to release the old IP reservation, and create a new one in another network reservation. This works in vRA 7.3 and 7.6 atleast.

First you need the 'VirtualMachineID'. This is the internal ID of the VM inside the vRA database.

select VirtualMachineID from VirtualMachine where VirtualMachineName='computername'

This should bring you the VirtualMachineID, for the example here, say it was 6B2C963F-3E0C-4719-B5F0-C708BB30654D

You can verify that you have the selected VM by using:

select * from StaticIPv4Address where VirtualMachineID ='<VirtualMachineID>'

Next you need to delete this Address, this will free up the IP in the old range

DELETE from StaticIPv4Address where VirtualMachineID ='<VirtualMachineID>'

Now to allocate the new IP in vRA Network profile, you need to get the ID of the network profile you want to assign:

select * from StaticIPv4NetworkProfile

Gives you a list over all network profiles. You need the ID (first column) for later. It's also a good idea to get the Subnetmask, Gateway, Dns etc if you want to update the VM's properties.

For this example, say it's '9C9A9069-DCE5-4880-967C-34A838E09E82'

Then you need ID of the Range (if your remember from the GUI, you can have multiple ranges for one Network Reservation)

select * from StaticIPv4Range where StaticIPv4NetworkProfileID='9C9A9069-DCE5-4880-967C-34A838E09E82'

This gives you a list over all ranges. You need to pick the range where the new ip is within (and ofcource it needs be be free/unallocated!) Get the ID of the Range, for this example say the StaticIPv4RangeID is C48E859D-7AC3-4B72-BEFA-65E2E96BE7BB

Next you need to calcuate the SortMask of the new IP you selected. This is basically only a 32 bit integer of the IP address itself. You can use this sql query to do this:

Declare @IP  as nvarchar(16)
set @IP= '10.10.1.250'

select CONVERT(bigint, PARSENAME(@IP, 4)) * 256 * 256 * 256 +
        CONVERT(bigint, PARSENAME(@IP, 3)) * 256 * 256 +
        CONVERT(bigint, PARSENAME(@IP, 2)) * 256 +
        CONVERT(bigint, PARSENAME(@IP, 1))

In this case you should get 168428026

The last thing you need is a new uniqueidentifer and you are ready to go.

DECLARE @myid uniqueidentifier  
SET @myid = NEWID()  
exec usp_StaticIPv4AddressCreateAddress @myid,'<StaticIPv4NetworkProfileID>','<StaticIPv4RangeID>','<VirtualMachineID>',null,'<NEWIP>',<IPSortValue>,0,NULL

Example with data:
exec usp_StaticIPv4AddressCreateAddress @myid,'9C9A9069-DCE5-4880-967C-34A838E09E82','C48E859D-7AC3-4B72-BEFA-65E2E96BE7BB','6B2C963F-3E0C-4719-B5F0-C708BB30654D',null,'10.10.1.250',168428026,0,NULL

To update the IP listed in the “Deployment” page, you need to update the Custom Property of the VM. This can actually be done using vcafe from vRO. But as a shortcut here:

-- EntityID is the same as VirtualMachineID
Update VirtualMachineProperties set PropertyValue = '10.10.1.250' where EntityID ='6B2C963F-3E0C-4719-B5F0-C708BB30654D' and PropertyName='VirtualMachine.Network0.Address'
vrealize/bugs/movevm.txt · Last modified: 2019/09/06 00:52 by admin