Remove machine from vRA 7.x
How to remove Machines from vRA 7.x
The steps here are contained in VMware Kb article 2144269 but read on below for a more user-friendly guide & explanation of the process.
From time to time it is required to remove a machine from vRA management manually. The destroy operation may only partially succeed in vRA due to a temporary issue with vSphere proxy agent or the vm might be restored from backup in vCenter with a different UID resulting in it being marked as "Missing" in vRA UI.
The VMware KB article focuses on removing machine using the cloud client however I have found that to be the least successful method. The most successful & reliable way for me has been direct database manipulation contained in KB2144269_RemoveVMFromVRA7.zip file attached to the above KB.
Quick points before we begin
The steps covered here only remove the machines from vRA management, they do not delete the vm's from vCenter, so if the vm's haven't already been removed from VC then you need to perform this manually as an additional clean up task
vRA has two databases:
- A Microsoft Sql database for IaaS components which will be running on an sql server.The IaaS MS SQL database contains the information displayed on the infrastructure Managed Machines tab.
- If you only need to clean up entries from the infrastructure Managed machine tab then you only need to alter the MS SQL DB entries. (you can skip the postgres steps)
- An embedded PSQL instance running on the appliances themselves. This database stores the information for the machine and deployment objects that exists in the UI under the Deployments tab of the UI.
- If you only need to clean up entries from the Deployments tab then you only need to alter the psql DB entries. (you can skip the MSql steps)
If you need to remove entries from both the Deployment tab and Infrastructure -> Managed machines tab then both sets of steps need to be followed.
!!Before proceeding snapshot each of the vRA appliances and take a manual backup of the IaaS SQL database: Open in MSSQL studios right click DB objects -> Tasks -> Backup !!
The Steps
To remove machine from IaaS DB (Infrastructure-> Managed machines UI)
- Download zip file containing the stored procedure usp_RemoveVMFromVRA.sql
- Open SQL Server Management Studio and login as VCAC/vRA database owner;
- On "Object Explorer" window, click "Databases->VCAC/vRA database" to highlight VCAC/vRA database
- Click "File->Open->File..." menu and then select "usp_RemoveVMFromVRA.sql" file on query window;
- Click "Execute" button on menu bar or "F5" key to install the stored procedure on VCAC
- Expand "VCAC database->Programmability->Stored Procedures" & right click on "usp_RemoveVMFromVRA" and select Execute stored procedure
- Input the virtual machine name into "Value" column of "@MachineName" parameter & select OK to execute the stored procedure.
To remove machine & parent deployment objects from the Postgres DB (Deployment tab)
- Putty/SSH to Primary vRA appliance and run command below to connect to postgres database: /opt/vmware/vpostgres/current/bin/psql vcac postgres
- Run below select query to validate only the machine we want is returned
SELECT * FROM cat_resource WHERE name='<machine name>' and tenant_id='<tenant name>'; - Run below update query to mark the machine returned above as deleted:
update cat_resource set status = 'DELETED' where name = '<machine name>’ and tenant_id='<tenant name>'; - You can now attempt again to delete the parent deployment object from the vRA UI, if this still fails then you can remove the deployment object by following steps 2 & 3 above simply by replacing <machine name> with the deployment name <deployment name>.
Comments
Post a Comment