VMware Cloud Community
MuayThai88
Enthusiast
Enthusiast

Adding Computer to Specific OU upon Provisioning.

I am trying to create a custom property that will allow me to choose which OU to place my newly created VM upon provisioning. I added a custom property named domainOU and added a value of OU=TEST,DC=mydomain,DC=local. Will this work and place the VM into the OU named TEST when it creates the VM?

0 Kudos
6 Replies
MuayThai88
Enthusiast
Enthusiast

I've read that article before, it is helpful but not for what I am trying to do. I am trying to be able to choose which OU the computer will go into. I created a task in vRealize Orchestrator and add the XaaS blueprint to my design. I add the 2 attributes (ou and Computers) which let me search Active Directory for the computer and OU. I added a java script which reads: ou.addElements(Computers);  will this work?

0 Kudos
MuayThai88
Enthusiast
Enthusiast

I also tried adding a custom spec, I tried using the value Infrastructure.Admin.MachineObjectOU and added values for the actual OU path. When I made a request to make a new VM, I was able to choose the OU based on the value that I set displayed in a drop down box. But when the machine was finished creating, it never went into the OU.

0 Kudos
MuayThai88
Enthusiast
Enthusiast

I ran the script in vRealize Orchestrator and got the following error message:

[2018-03-01 12:49:12.602] [E] Error in (Workflow:Add Computer to OU / Add Computer to OU (item1)#0) TypeError: Cannot find function addElements in object DynamicWrapper (Instance) : [AD_OrganizationalUnit]-[class ch.dunes.ad.object.OU] -- VALUE : #_v2_#,#OU#,#1cdf8f55-701d-431a-962c-7c38a4883eb3#,#OU=TEST,DC=xxxx,DC=xxxx#.

[2018-03-01 12:49:12.616] [E] Workflow execution stack:

***

item: 'Add Computer to OU/item1', state: 'failed', business state: 'null', exception: 'TypeError: Cannot find function addElements in object DynamicWrapper (Instance) : [AD_OrganizationalUnit]-[class ch.dunes.ad.object.OU] -- VALUE : #_v2_#,#OU#,#1cdf8f55-701d-431a-962c-7c38a4883eb3#,#OU=TEST,DC=xxxx,DC=xxxx#.'

workflow: 'Add Computer to OU' (a894591d-2e94-472a-8687-cbd367283313)

|  'input': name=ou type=AD:OrganizationalUnit value=dunes://service.dunes.ch/CustomSDKObject?id='%23_v2_%23%2C%23OU%23%2C%231cdf8f55-701d-431a-962c-7c38a4883eb3%23%2C%23OU%3DTEST%2CDC%3Dxxxx%2CDC%3Dxxxx%23'&dunesName='AD:OrganizationalUnit'

|  'input': name=Computers type=AD:ComputerAD value=dunes://service.dunes.ch/CustomSDKObject?id='%23_v2_%23%2C%23Computer%23%2C%231cdf8f55-701d-431a-962c-7c38a4883eb3%23%2C%23CN%3DVMxxxxx%2CCN%3DComputers%2CDC%3Dxxxx%2CDC%3Dxxxx%23'&dunesName='AD:ComputerAD'

|  'no outputs'

|  'no attributes'

*** End of execution stack.

Any Ideas?

0 Kudos
nsajepi
Enthusiast
Enthusiast

0 Kudos
qc4vmware
Virtuoso
Virtuoso

Hey there.  We've always done this by adding the machine to the OU during the provisioning by using the lifecycle extension mechanisms.  Assuming you are using vRA 7.x I'd suggest in the PRE phase of building machine.

I have a whole series of wrapper workflows I've written around the AD plugin but the couple of lines that ends up adding the computer are

ou.createComputer(cn, domain);

var newComputer = ou.searchComputer(cn);

In my wrapper I pass in the full distinguished name and parse it.  I have another action that takes the OU string and searches the plugin for the matching OU scriptable object from the plugin then runs the ou.createComputer() method.

Paul

0 Kudos