VMware Cloud Community
mg1978
Enthusiast
Enthusiast
Jump to solution

How to get a vmfolder from string

Hi All,

I have a problem with my vCO. After every reboot of the vCO server or VC server I lost my values in the workflows which point to the virtual center. For example, I have a workflow where I define a special vmfolder, special VM as a template, special host where the machine should start, etc. After a reboot are the values as "Not configured" and I need to define the values again. The values for Active Directory working, like LDAP groups or OUs.

I have already now a script how I get a VM, Host, Datastore and Network using a string with the name auf the VM/Host/... as input and get an output as VC:VirtualMachine/VC:Host,...

What I need now is a script where I can define an input parameter as a string with the same name of the vmfolder what I have ion VC and get an output attribute with the vmfolder as type = vmfolder.

Reply
0 Kudos
1 Solution

Accepted Solutions
Burke-
VMware Employee
VMware Employee
Jump to solution

OK, well you are certainly storing the values in the correct location... try Christophe's request for some additional troubleshooting.

For the immediate workaround and to answer your actual request, the following script should retrieve a vmFolder based on the string: Only input required is the "vmFolderName" which is a String. The return value is "vmFolder"

var folders = VcPlugin.getAllVmFolders(null, "xpath:name='"+vmFolderName+"'");
var vmFolder = null;
if (folders != null){
     if (folders.length == 1){
          System.log("Match found for vm named: "+vmFolderName);
          vmFolder = folders[0];
     }else{
          System.log("More than one vmFolder found with that name! "+vmFolderName);
          for each (folder in folders){
               System.log("Folder ID: "+folder.id);
          }
     }
}

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter

View solution in original post

Reply
0 Kudos
9 Replies
cdecanini_
VMware Employee
VMware Employee
Jump to solution

If you set these values as workflow attributes they should stay after a reboot since all vCenter object are referenced through their unique ID. If when restarting the attribute appears as not found then you have a serious problem and should send your logs to VMware support.

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
Reply
0 Kudos
mg1978
Enthusiast
Enthusiast
Jump to solution

Hi,

I install a new VC server and a new vCO box with update1 and vCO 4.2.1

The vCO get a new blank DB. I configure the server and create a test workflow only with three attributes where values for VC:Hostsystem,VC:Datastore and VMFolder were set.

The three values were set as "Not Found" after a reboot of the vCO server.

I had open a call by VM about this issue and wait for more than 2 weeks for a solution, but I don´t get this one. VMWare don´t have an idea why the VC values losts and this are only the VC values. LDAP values or other are OK.

I can set already a host, datastore, vm or network inside my workflow from string, but I need to set also a vmFolder as an output attribute where I provide a string as a input parameter.

Can somebody help me, with a script ?

Thanks.

Reply
0 Kudos
Burke-
VMware Employee
VMware Employee
Jump to solution

Can you please share some screenshots showing:

1) values set (Before executing the workflow)

2) Not Found (After executing the workflow)

Perhaps actually seeing your problem will help us to help you Smiley Wink

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
Reply
0 Kudos
mg1978
Enthusiast
Enthusiast
Jump to solution

Here is a screenshot after a reboot,

sometime are all three values as not found and sometimes is one vaule set.

2015907.png

Reply
0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

Do a:

System.log(BDCHost.originalStringRepresentation);

System.log(Folder.originalStringRepresentation);

Once done go check the vCO inventory and check the IDs of the objects and if they are matching.

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
Reply
0 Kudos
Burke-
VMware Employee
VMware Employee
Jump to solution

OK, well you are certainly storing the values in the correct location... try Christophe's request for some additional troubleshooting.

For the immediate workaround and to answer your actual request, the following script should retrieve a vmFolder based on the string: Only input required is the "vmFolderName" which is a String. The return value is "vmFolder"

var folders = VcPlugin.getAllVmFolders(null, "xpath:name='"+vmFolderName+"'");
var vmFolder = null;
if (folders != null){
     if (folders.length == 1){
          System.log("Match found for vm named: "+vmFolderName);
          vmFolder = folders[0];
     }else{
          System.log("More than one vmFolder found with that name! "+vmFolderName);
          for each (folder in folders){
               System.log("Folder ID: "+folder.id);
          }
     }
}

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
Reply
0 Kudos
Burke-
VMware Employee
VMware Employee
Jump to solution

Ah yes, you should also confirm that your forward/reverse DNS is resolving properly for your vCenter server from your vCO server - and be sure that your vCenter plugin is configured with the appropriate name as per the forward/reverse lookups. If you connect using the API, but the server returns the FQDN in the plugin calls, you could have some mis-matches that are intermittent - explaining why some values fail to store and others are okay.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
Reply
0 Kudos
mg1978
Enthusiast
Enthusiast
Jump to solution

Here is the screenshot from the log

2015907.png

2015907-2.png

Reply
0 Kudos
mg1978
Enthusiast
Enthusiast
Jump to solution

Hi Burke,

your script is working very well.

Thank you very much.

Reply
0 Kudos