User Tools

Site Tools


vrealize:bugs:vcplugin

VCPlugin

VCPlugin is a plugin in vRO that communicates with the vCenters. This plugin do have some unexpected behaviour. Both in the “Actions” provided in vRO and also the plugin itself.

If you only has one vCenter connected to vRO, you will not be affected by this, however if you have more than one, AND one of these vCenters is down, alot of problems might happend.

Example from the “built in” actions:

findVcConnectionById

If you look at the com.vmware.library.vcac.findVcConnectionById

var sdkConnections = VcPlugin.allSdkConnections;
for each (var sdkConnection in sdkConnections) {
	var uuid = sdkConnection.aboutInfo.instanceUuid;
	if (uuid == id) {
		return sdkConnection;
	}
}

Problem here is the line:

      var uuid = sdkConnection.aboutInfo.instanceUuid;

This command requires the VCPlugin to actually talk to the vCenter, so if the vCenter is down, you will get a “NULL” result, making the action crash. You could fix this with using a try/catch solution. Notice that it's the .aboutInfo.instanceUuid that needs to talk to the vCenter, you CAN search here by name (does not require the vCPlugin to talk to the vCenter)

vCPlugin.getAllDataStores

(Problem goes for all these .get functions)

All of these built in functions fails as soon as a vCenter is down. However since the SDK connection itself (for each vCenter) have the same functionality, you can get around this problem with creating your own functions for these senarious.

Here is an example of that. This is part of the code I use in my “precheck”. (Verfying that the datastore has enought free space, and does not contain any problems (maintainance mode, disk full etc) and if the template is actually exists, and ONLY exists once (Yes, another “feature” of vRA, if you have multiple templates with SAME name, you have no idea witch one it actually chooses) - This is run before the actual deployment start to avoid getting a failed deployment, and rasing a ticket (ServiceNow) to the correct team.

var sdkConnections = VcPlugin.allSdkConnections;
// This function works, since it does not communicate with the vCenters
 
for each (var sdkConnection in sdkConnections) 
{
	try 
	{
		var uuid = sdkConnection.aboutInfo.instanceUuid;
                // This will throw an error if the vCenter is down.
		System.log("Checking UUID: "+uuid);
		var DS = sdkConnection.getAllDatastoreFolders(null , StoragePath);
		if (DS == null || DS.length != 1)
		{
			// This might be a single dataStore. Check for that aswell
			DS=sdkConnection.getAllDatastores(null , StoragePath);
			if (DS == null || DS.length !=1)
			{
				// Check other vCenters...
			}
			else
			{
			       // SINGLE DATA STORE
				System.log("This is a single datastore...");
				if (VerifyDataStores(DS,RequestVMSizeInBytes) == true)
				{
					VerifyTemplate (sdkConnection,templateName,DataCenterName);
				}	
				DSFound = true;
				break;
			}
		}
		else
		{
			// DATASTORE FOLDER (multiple data stores)
			DSFound = true;
			if (VerifyDataStoreCluster(DS[0]) == true)
			{
				if (VerifyDataStores(DS[0].datastore,RequestVMSizeInBytes) == true)
				{
					VerifyTemplate (sdkConnection,templateName,DataCenterName);
				}	
			}	
			break;
		}
	}
	catch (exception)
	{
		InternalErrorMessage = "vCenter might be down? : "+exception;
		System.warn(InternalErrorMessage);
	}
}
vrealize/bugs/vcplugin.txt · Last modified: 2019/03/04 09:53 by admin