How to link VMware View desktop to its replica
A while back I was looking at a VMware View environment that had Storage DRS enabled and set to automatic. If I recall correctly, one of the first things the installation document from VMware mentions is not to use Storage DRS in a View enviroment. If you need to rebalance the desktops and replica data on your datastores you can do so with the “Rebalance” option within the View administrator console.
In this enviroment storage DRS had been running like that for some time resulting in desktops and replica’s beeing moved across the datastores and View losing control over the desktops. Creating new pools and migrate the users to newly created pools was done fairly quick and from the View admin console perspective the problem was solved. However the datastores still containedmore desktop and replica folders present than there should have been. So how do you determine if a folder is still in use or not?
The way we checked the folders was through the use of the tables within the vCenter and View Composer database. In this article I want to describe how you can link a VMware View desktop to its replica within vCenter.
1. First thing you should do is open up the table called “SVI_SIM_CLONE” in the View Composer database and look up the desktop name in the column “VM_NAME”.
2. In the same row as the “VM_NAME” find the column “REPLICA_ID” and remember that value.
3. Open up the table “SVI_REPLICA” also present in the View Composer database and look for the value in “ID” that matches the value you found in step 2.
4. On the same row of “ID” find the value in the column named “REPLICA_MOID”.
5. In the vCenter database open the table “VPX_ENTITY” and use the value of “REPLICA_MOID” minus the “vm-” part to find a match in the “ID” column.
6. Write down the value in the column “NAME” and you have the name that is shown in the vCenter client.
In case that you cannot find the “ID” / “REPLICA_MOID” in the “VPX_ENTITY” table it means that vCenter isn’t aware of that replica. It is likely that there are still some desktops running and are using this replica. Best thing to do is to shutdown those desktops manually and remove them from vCenter / View composer and then remove the replica manually.
Knowing how the tables and columns link to each other can also provide other uses. For example knowing the vCenter name of a replica can help you find all the desktops that are linked to it. The “REPLICA_ID” value in the “SVI_SIM_CLONE” table isn’t unique, if you order the table on the replica_id you can group up all the “VM_NAME” values and thus the desktops related to that replica.
Manually checking the relation between a desktop and it’s replica can be very time consuming, so it might be worth scripting something that can provide a good overview. With powershell you can open up connections to your database and use SQL queries to retreive the data you like and proces it to the information that you need.
Example of a SQL connection script with Powershell:
$connectionString = “Server=$Server;uid=$user;pwd=$pwd;Database=$databaseVcenter;Integrated Security=True;”
$connection = New-Object System.Data.SqlClient.SqlConnection
$connection.ConnectionString = $connectionString
$query = “Select ID,NAME From VPX_ENTITY WHERE NAME LIKE ‘replica%'”
$command = $connection.CreateCommand()
$command.CommandText = $query
$result = $command.ExecuteReader()
$table = new-object “System.Data.DataTable”
This script connects to a vCenter database and will select all the ID’s and Names from the “VPX_ENTITY” table where the name starts with “replica”. The values found are then put into a table for Powershell that can be used for the rest of the script.
Hopefully the information in this article can help in future endeavours. If you know any other relations between the tables / databases then please let us know, we might be able to describe those to.
Sander Martijn is a Technical Professional for Conoscenza in The Netherlands. As a Technical Professional he works for different clients, building, troubleshooting and managing ICT infrastructures. He is a certified VMware VCP-DCV, VCP-DTM, several VSP and VTSP. Since 2015 he has been awarded vExpert status.