Re-import VM from vCenter

Hello,
How I can re-import VM without physical delete VM from vCenter?

Hi Anton!
that behavior is not supported by OpenNebula but I’ve created a ticket for this feature in OpenNebula’s Redmine.

In any case I can think of a workaround that you can try at your own risk that deals with your database so you should proceed with caution and checking that you have backups. I’d test this workaround in a testing environment first.

Basically you can remove the VM from two tables in OpenNebula’s database:

  • DELETE FROM vm_import WHERE vmid=$VMID;$VMID should be replaced with OpenNebula’s ID of the imported VM that you want to remove and reimport.
  • DELETE FROM vm_pool WHERE oid=$VMID; Once again $VMID should be replaced with the ID you want.

I think that the cleanest and right solution is using the onedb patch command which requires a patch file to be created. There are some examples of patches here that may help you to create one patch to apply those sentences but I don’t have one for this issue right now sorry. If you don’t use the onedb patch tool, you should take great care if you want to apply them to your database, those sentences should be executed with the OpenNebula services stopped and you should have a backup in case you break something.

Finally you should run the onedb fsck command once you’ve removed the VM from those tables (the command is explained here) so any inconsistence is solved.

Once the VM is not shown anymore in Sunstone, once the host is monitored again you should be able to re-import the VM again,

Hope it helps!

Cheers!

Thanks mcabrerizo!