VMware Cloud Community
rubberduck70
Contributor
Contributor

How to use Orchestrator tags to place VM's in folders

Hi guys

We currently use orchestrator as our provisioning tool and would like to start using tags that will assist to a VM in a specific folder during creation or post workflow process. The reason behind this is, vCOPS uses the folder structure within vSphere to do reporting on it and it would work hand-in-hand that we can place and report on specific departmental servers if they are placed in the correct folder during creation. The aim is to select a department from a drop-down selection and based on that selection, Orchestrator must then place that VM in the corresponding folder. Is there currently something out there that someone is aware of in the form of a scriptable task perhaps?

Any ideas / feedback is welcome

thank you

0 Kudos
6 Replies
cdecanini_
VMware Employee
VMware Employee

vCO has tag methods (in recent versions) and custom properties methods (been there for several years).

The vCenter tags are not accessible form vCO since sadly vCenter does not have an open API for these.

If you need to use vCenter tags then I have heard there are some powerShell Commandlets allowing to find objects by tags. You may want to use these commandlets with the PowerShell plug-in to get the VMS and pass these to your vCO workflows.

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
0 Kudos
rubberduck70
Contributor
Contributor

Thanks Cdecanini

Do you perhaps have a reference of these commandlets and an example of how I can pass this through? Action element to run powershell scrip etc?

0 Kudos
cdecanini_
VMware Employee
VMware Employee

See this thread : Re: creating and assigning tags in vCenter through vCO

For using powerShell from vCO you may find tutorials on internet and find help from people who use PowerShell from vCO in this forum.

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
0 Kudos
croeleveld
Contributor
Contributor

Why use tags in the first place? If orchestrator is the provisioning tool then orchestrator can place the VM in the right folder right away without using tags.

I would do it like this:

Create a configuration element in vCO.In the CE create attributes of type VC:VmFolder using the departmental name as the name of the attribute and the folder as the value. If you ask for the departmental name in a dropdown you can lookup the corresponding folder by using: targetfolder = <attribute_pointing_to_ce>.getAttributeWithKey(departmentalname);

Now user targetfolder variable as input for the create/clone VM workflow.

0 Kudos
zebduin
Enthusiast
Enthusiast

Setting tags on a VM is possible through vCO via PowerCLI and the Powershell plugin.  In this example, facility and networkCore are both variables that are defined via drop-down menus in vCAC. 

a couple of notes:

vm = VC:VirtualMachine

vmName = vm.name

vcServer = vm.sdkConnection.id

PowerCLI script example:

powerShellScript = "Add-PSSnapin VMware.VimAutomation.Core \n"

+ "Connect-VIServer -Server '"+ vcServer + "' -User " + vcUser + " -Password '" + vcPassword + "'\n"

+ "New-TagAssignment -Tag '" + facility + "' -Entity '" + vmName + "'\n"

+ "New-TagAssignment -Tag '" + networkCore + "' -Entity '" + vmName + "'\n"

+ "Disconnect-VIServer -Server '" + vcServer + "' -Confirm:$false \n";

0 Kudos
rubberduck70
Contributor
Contributor

Would it be possible to use the above mentioned code in a scriptable task but with user input in the current worklfow? So basically, as the user inputs the properties for the VM upon provisioning, place the scriptable task in the worklow but use it as a predefined list of answers?

I would then insert all the values in the backend from which they can select?

So where +facility,  +networkcore and + entity is, use something like the below:

+ "New-TagAssignment -Tag '" Predefined list of answers (select from dropdown) + vmName + "'\n"

+ "New-TagAssignment -Tag '" +Predefined list of answers (select from dropdown) + "' -Entity '" + vmName + "'\n

0 Kudos