VMware Cloud Community
jauling
Enthusiast
Enthusiast

vRO vSphere Plug-in 7.0.0-18421354 - Folder to Folder Object conversion bug?

Hi,

I had posted a few comments about this in the vSphere Plug-in Tech Preview page: https://communities.vmware.com/docs/DOC-32872, but wanted to share this issue here as per suggested by @qc4vmware.

When using the 7.0.0-18421354 plug-in, which is latest as per this post, we had a very old action that began to fail, with this error message:

 

Unexpected state FAILED: Unable to convert object, 'Stub: moRef = (ManagedObjectReference: type = Folder, value = group-v29, serverGuid = null), binding = https://vcenter-ruh1.mhint:443/sdk' plugin exception reason : convertToResult() --> Finder 'VC:Folder' : unexpected error 'ch.dunes.model.sdk.SDKFinderException: convertToResult() --> Finder 'VC:Folder' : unable to invoke read method : 'namespace'' (VMware::Orchestrator::WorkflowException)

 

I was able to find an older version of this plug-in I had installed on a test vRO instance a while ago when I was working on this topic, and this 6.5.0-16904859 version worked fine and also allowed me to start adding vCenter 7.0 instances to vRO. FWIW, older builds of this plug-in don't seem to be available for download, which could have helped tremendously.

Here is the custom action code, in case someone can replicate and/or escalate this bug in 7.0.0-18421354. I believe it takes a string representation of a VM Folder, then finds the object and assigns it out. This is very old code, and I didn't write it, so if it's poorly written, it isn't my fault 😁

 

var datacenterObj = System.getModule("com.vmware.library.vc.basic").getDatacenterForVimObject(anyVcenterObject);
var vmf = datacenterObj.vmFolder;

for (var i = 0; i < vmf.childEntity.length; i++) {
	var f = vmf.childEntity[i];
	var folder = VcPlugin.convertToVimManagedObject(datacenterObj, f);
	
	if (folder.name === folderName) {
		return folder;
	}
}

return null;

 

 

2 Replies
qc4vmware
Virtuoso
Virtuoso

Yes I was able to reproduce this easily.  Seemed to me like something is going on when looping through the array of folders returned by datacenterObj.vmFolder .  Whenever I tried to set a variable to one of the items in that array to return that conversion error triggers.

This is some alternate code that returns the desired folder but doesn't generate the conversion error.

 

var datacenter = System.getModule("com.vmware.library.vc.basic").getDatacenterForVimObject(anyVcenterObject);
var parent = datacenter.parent;
var dcPath = "";

while (parent && parent.parent) {
System.debug(parent.name + ": " + System.getObjectType(parent));
dcPath = parent.name + "/" + dcPath;
parent = parent.parent;
}

System.debug("dcPath; " + dcPath);
System.debug("Query for folder in datacenter: " + datacenter.name);
System.debug(System.getObjectType(datacenter.parent));
var index = anyVcenterObject.vimHost.searchIndex;

// Inventory path of the folder to search for (note: starts with datacenter name and folder if datacenter is in a folder)
// root folder is always named Datacenters and if included in query it will not work sor check for that too!
var invPath = dcPath + datacenter.name + "/vm/" + folderName;
System.debug("Query index for path: " + invPath);

var folder = index.findByInventoryPath(invPath);

return folder;

jauling
Enthusiast
Enthusiast

Thanks again @qc4vmware for your debugging and troubleshooting efforts, it's highly appreciated. FWIW, SR 21254861909 was opened for this specific issue, but the support personnel clearly stated to me that they are not equipped to deal with this sort of issue.

Curiously enough, they did not suggest further escalation, and were keen to close the SR since I found an alternate plug-in version that works for us. Just to complete the circle, attached here is the 6.5.0-16904859 version of this plug-in. Sorry for zipping it, I was not allowed to upload it directly as named.

I will try to find the time in the next few weeks to test the alternate code you provided and hope to deploy it into production if I don't run into any issues. Again, much thanks for your efforts!

Reply
0 Kudos