Today I’ve been working on a VMware vCenter Orchestrator workflow to add custom fields on a Virtual Machine. To do this you need to check if the custom field has been created on vCenter using the method addCustomFieldDef on the VcCustomFieldsManager object.

var customFieldsManager = VirtualMachine.sdkConnection.customFieldsManager;

customFieldsManager.addCustomFieldDef(fieldName, VirtualMachine,
null, null); 

This will produce an error if the field is already added on the vCenter server so you need to carry out a check. |

var customFieldsManager = VirtualMachine.sdkConnection.customFieldsManager;

for each( var field in customFieldsManager.field )  
 {  
  if( field.name == name )  
 {  
  // handle match  
 }  
 }  

I found that the attribute field was undefined. After some checking of my code I was sure this was a bug. With a quick Google I found this post on the VMware Community https://communities.vmware.com/thread/477831. It would appear that there is a bug in vCenter Orchestrator 5.5 Inventory Service where it returns incorrect information. The fix for this is to disable the Inventory Service by adding the following line to the file vmo.properties and then restarting vCO.

 com.vmware.o11n.vim.useInventoryService=false  

You will find this file in the following locations depending on how you have deployed vCO.

Installation Location
Orchestrator Installed with the vCenter install\_directoryVMwareInfrastructureOrchestratorapp-serverconf
Standalone version of Orchestrator install\_directoryVMwareOrchestratorapp-serverconf
Orchestrator Virtual Appliance /etc/vco/app-server/

This does appear to be a common issue being reported not just on the customFieldsManager.fields attribute from the Inventory Service. Here is a post where someone has reported the issue when looking up a VlanID on a vSwitch PortGroup. I noticed a comment on this post saying that the vCO Inventory Service is going to be deprecated in a future release.

I think the inventory service will be deprecated in the future releases (if not already).



Comments

comments powered by Disqus