Whilst testing vCAC (188.8.131.52) we have recently run into a strange little issue when trying to tear down and evacuate everything from a test tenant. In order to remove a tenant you must strip back everything first by removing machines, blueprint, reservations, business and fabric groups. We got as far as removing the blueprints before running in to the error below. “Error Deleting Blueprint <blueprint name>/ it is still being referenced by 1 machines.”
This should not be the case as we had destroyed all test machines assigned by this blueprint in the correct manor before. Indeed, selecting the blueprint and choosing “view machines” yields the information shown below. i.e. there are no machines managed from this blueprint.
We also have another blueprint within this tenant and attempting to delete this gives the same result. However, this time, clicking “view machines” shows that one VM is seemingly stuck in the “Disposing” state. This is a permanent issue as no amount of refreshing, data collection or restarting clears this status. Clearly, this is blocking this blueprint from being removed.
It is possible to try to force a destroy of this machine but, despite claiming success, and eventually removing the machhine from the “disposing” state nothing actually changes. Deleting the blueprint still gives the error that is it still being ‘referenced by 1 machines’.
Please note: The following solution involves hacking about in the vcac SQL database. this is almost certainly not a supported action and could cause things to go badly wrong if you do something silly. Only do the following at your own risk and after backing up the SQl and PSQL databased associated with your vCAC install.
This issue was traced down to an incorrct entry in the vcac SQL database. within the vCAC database there is a table called ‘dbo.VirtualMachine’ Running the query below will return all VMs that the vcac databse considers being currently managed or assigned to a blueprint.
SELECT * FROM Virtualmachine WHERE IsManaged=1
This returns a list of VMs. take a look through the VMs and see if any of them co relate to the name of the blueprint you are trying to remove.
<Insert Picture here>
For each of the VMs that relate tot he affected blueprint copy and paste out the ‘VirtualMachineID’ to a text file for later use.
<Insert Picture here>
Now, for each of the VirtualmachineIDs you have run the query below. Again, ensure you have a backup and the ID is correct and only referencing the blueprint you are wishing to delete.
UPDATE dbo.VirtualMachine SET IsManaged=0 WHERE VirtualMachineID=’<Insert VM ID Here>’
Now restart the IaaS Web services and log back on to the vCAC web interface and try to remove the blueprints again. In the case above the steps performed allowed the removal of the second Blueprint but NOT the first. Further steps were required to enable this to be removed.