Re-register a vCloud VM in vCenter

Consider during troubleshooting a VM issue , you would have to unregister the VM which is being managed by vCloud.

Let’s call the VM “chosenone(0e68e734-ce66-3567-15ca98dfc228)”

If we search the vCloud database, we can see the moref of this VM is vm-xxxx.  You will find this moref under the following tables:

computevm
licensing_vm_data
networked_vm
property_map
vapp_vm
vc_task_mapping
vm
vm_inv

select id, name,vc_id ,moref, cloud_uuid,instance_uuid from vm where name like ‘%chosenone%’
select vm_inv_id, name,moref ,vc_id, cloud_uuid,instance_uuid from vm_inv where name like ‘%chosenone%’

In the VM’s vmx file, we find the following UUIDs

uuid.bios = “42 2a f4 r5 a8 77 01 bd-52 17 99 78 64 8f f3 9d”
vc.uuid = “50 2a 53 a7 38 91 b1 06-a2 35 34 76 89 c7 a4 09″
cloud.uuid = “a8108db8-9845-43a7-bd4c-98ca588afa0d”

Un-registering  the VM and re-registering the VM, the VM will keep the vc.uuid (instance_uuid in the database) and the cloud.uuid.  However, it will get a new moref.

Moref ?  What is it ?

The MoRef ID is a VMware internal identifier that is generated by vSphere when new objects are created in vCenter (e.g. adding ESXi host or creating a VM). This MoRef ID is used by all VMware solutions to reference objects within vCenter

With vCloud Director, to uniquely identify a virtual machine, you would use the vCloud Director Object ID that is automatically generated by vCloud Director when a new virtual machine is created.

If you need to uniquely identify a virtual machine in both vSphere and vCloud, you can still use the identifiers listed above in their respective stack but how do you go about correlating the two? As mentioned earlier, all VMware solutions leverage the MoRef ID to reference objects within vCenter. Since vCloud Director sits on top of vSphere, it too also uses the MoRef ID to map entities between the two environments. As part of the vCloud API, there is a vCloud Extension API that provides information about the underlying vSphere infrastructure including the MoRef ID of a VM and vCenter Server instanceUuid.

Coming back , After you re-register the VM, you may see two entries in the vCloud databases’s vm table.  Once the vCloud VC inventory services runs or you re-connect vCenter through vCloud, the old entry (moref vm-xxxx) will disappear.

If you try to start the VM in vCloud, you will receive the following error
Error: Could not find object with moref “vm-xxxx″ and VC ID in inventory category “VirtualMachine”.If you search the vCloud database for this moref, you will find it under the following tables.

select * from computevm where vmmoref = ‘vm-xxxx
select * from networked_vm  where moref = ‘vm-xxxx’

We need to fix this by replacing the old moref in these tables with the new moref.

The following query helps us to find the moref id

select moref from vm where name = chosenone (0e68e734-ce66-3567-15ca98dfc228)’ > vm-xxxx

Update the tables with the new moref

update computevm set vmmoref = ‘vm-xxxx where vmmoref = ‘vm-xxxx’
update networked_vm set moref = ‘vm-xxxx where moref = ‘vm-xxxx’

You should be able to power on the vm now .

We would may be need  to refresh vCenter through vCloud so that vCloud will mark the VMs that is it manages.

The vm should show as being managed by vcloud solution now and should be mapped fine.

Happy Learning 🙂

Advertisements