VMware Cloud Community
BillStreet00
Enthusiast
Enthusiast

Create computer in an organizational unit

I have a scriptable task which reads in the computer name.  I have hard coded the OU and domain as they will be static at this point.  When I run this scriptable task as an event it runs fine.  When I add the "Create a computer in an organizational unit" workflow it asks to add the parameters into the workflow, I select promote.  When I run the event subscription again I get a "get" error immediately due to the OU being an AD:OrganizationalUnit type.  I have specifically worked this down to the OU being the culprit.  I attempted to change the type of OU to string and convert it to an AD:OrganizationalUnit type in my script (which works) but the whole workflow tosses an error because the input type was changed from AD:OrganizationalUnit to String.

I'm stuck because I need to have the OU (AD:OrganizationUnit) variable or I need to find a way to change the "Create a computer in an organizational unit" workflow so it doesn't require the OU variable or take it in as a String.

Has anyone ran into symptoms like this and if so, how did you get past it?

Thanks

Reply
0 Kudos
7 Replies
iiliev
VMware Employee
VMware Employee

Well, you can try to duplicate the workflow, move the existing AD:OrganizationalUnit input parameter to an attribute, add your string OU as an input parameter, and then as a first item in the workflow insert a Scriptable Task element with some code to initialize the value of AD:OrganizationalUnit attribute by using one of ActiveDirectory.search(...) scripting API using your string OU as an input.

As a last step, you need to go over the visual bindings of the existing workflow items and ensure they receive their OU from the attribute.

Reply
0 Kudos
BillStreet00
Enthusiast
Enthusiast

Thats what I am working on now.  I found a nice snippet of code to covert the OU here.   I do have an issue though.  My virtualmachine.network0.name is getting pulled in as part of this workflow and it has a value similar to 10.10.10.0%2F24 because of the way its being read in.  Do you know of a way to get rid of the last five characters?  I have tried split, which works but seems to give me only the piece of the string after the split.  I also tried substring but vRO doesn't like that at all. Any thoughts?

Reply
0 Kudos
igaydajiev
VMware Employee
VMware Employee

%2F looks like encoded '/'

===============

var someStr= 'aaa%2F'

System.log("original: "  + someStr)

System.log("decoded: " + decodeURIComponent(someStr))

System.log("substring : " + someStr.substr(0,3))

==========

Produces in my vRO 7.3

[2017-09-19 23:15:27.698] [I] original: aaa%2F

[2017-09-19 23:15:27.702] [I] decoded: aaa/

[2017-09-19 23:15:27.707] [I] substring : aaa

I will sugest also taking a look  at generic LDAP client avaialbe in AD plugin 3.0+

Active Directory plugin 3.0.0 - New and Noteworthy 

In case you don't need inventory objects (as input to your workflow)  but rather work with string or directly with  object DN's it is much easier and performance wise to use directly the generic LDAP  client.

Reply
0 Kudos
BillStreet00
Enthusiast
Enthusiast

It is an encoded '/'.  I am performing the action 'getavailablenetworks' so requester's can pick which network they want to build on rather than hard coding a drop down. Our networks are defined as datacenter-IP/Mask.  In order to send a variable called inRange to our IPAM solution for the next available IP address in the selected IP range I needed to hash out what that range was from the network name. 

Your reply reminded me that 'split' produces an array hence my object error when trying to perform another action on the resulting variable.  Here is what I came up with.

var incNetName = "DC-10.10.10.0%2f24";

var tmpStr = incNetName.split('-');

var tmpRange = tmpStr[1].split('%');

var inRange = tmpRange[0];

var tempMask = incNetName.split('f');

var sMask = tempMask[1];

System.log(inRange);

System.log(sMask);

[2017-09-20 07:24:21.765] [I] 10.10.10.0

[2017-09-20 07:24:21.766] [I] 24

This allows me to send the inRange variable to Men and Mice and get the next available IP in the 10.10.10.0 range, assign it to DNS.  I then perform a small case statement to define our subnet mask values.  Once complete I send IP, DNS, Subnet Mask, DNS Suffix back to the blue print build.  We have quite a few networks so coming up with a small function to define the mask and IP range will save me quite a few lines of code.

It's tough not having anyone here to talk to about vRO. I end up looking at things way to long and just need to step back and slap my forehead at the silliness of what is causing me a headache.

Reply
0 Kudos
daphnissov
Immortal
Immortal

And just FYI, since you're using Men & Mice, all that vRO coding has been done for you with this integration.

Reply
0 Kudos
BillStreet00
Enthusiast
Enthusiast

The link does not seem to resolve.  I did finish up the integration though.  What I ended up with was pretty slick and surprisingly small in the amount of code used.

Reply
0 Kudos
daphnissov
Immortal
Immortal

Reply
0 Kudos