Hello to All, in our Vcenter, each user has a folder with his name.
i have simple workflow that create new VM from Template.
so when user start the workflow - i get the display name of current user and i want that new VM will be create in his folder (by his name).
for example:
// get the display name of user
var user = Server.getCurrentLdapUser();
displayName - user.displayName
//try to set vm folder:
vcFolder = displayName ????
i dont know how to convert the string to vcFoldet object.
The method you are using is overkill since it searches all VM folder on your virtual Center (and you may end up getting a folder in a different location than waht you want).
Create an action with an input parameter parentFolder (the folder in which you will be looking for other folders) of type vmFolder and a string attribute foldeName(the name you are looking for).
for each (var child in parentFolder.childEntity) {
if ((System.getObjectType(child) == "VC:VmFolder") && folderName == child.name) return child;
}
return null;
You can now use this action setting it with your user names & the parent vm folder.
The first thing you should look for is an existing workflow in the library and there is one: "Create virtual machine folder". In your main workflow drag and drop it, bind the name attribute to displayName (make sure to create an attribute for it and bind the output of the scriptable task) and bind the parent folder to an attribute that you can set with the root folder whare this folder needs to be created.
thanks for your answer, i don't want to create folder , all the folders existing in vcenter.
i want to use the folder that belog to current user by set the parameter vcFolder to disply name,
when i tryed to get the folder by workflow "Create virtual machine folder" i get error "the folder already exist" before that value of vcFolder change.
In this case you will need to enumerate the folders in a loop and compare the names. The parent folder object has a method or property (.folders ? - i cannot check - i am not in front of the computer) that will return an array of folders objects.
Pseudo code :
var folders = parentFolders.folders;
for each (var folder in folders) {
If (folder.name == displayName) break;
}
Le 25 mars 2014 à 21:47, "Robert_BE" <communities-emailer@vmware.com<mailto:communities-emailer@vmware.com>> a écrit :
VMware Communities<https://communities.vmware.com/index.jspa>
convert string to vcFolder
created by Robert_BE<https://communities.vmware.com/people/Robert_BE> in Orchestrator - View the full discussion<https://communities.vmware.com/message/2361350#2361350>
i dont understand what is "parentFolder.folders", but if i use "var folders = VcPlugin.getAllVmFolders" instead "var folders =parentFolder.folders" - i get what i wanted.
there is way to get folders from specific datacenter or specific parent folder ?
The method you are using is overkill since it searches all VM folder on your virtual Center (and you may end up getting a folder in a different location than waht you want).
Create an action with an input parameter parentFolder (the folder in which you will be looking for other folders) of type vmFolder and a string attribute foldeName(the name you are looking for).
for each (var child in parentFolder.childEntity) {
if ((System.getObjectType(child) == "VC:VmFolder") && folderName == child.name) return child;
}
return null;
You can now use this action setting it with your user names & the parent vm folder.
thank you very much cdecanini - now its working