VMware Cloud Community
AnotherPassword
Enthusiast
Enthusiast

Not sure if I need a ForEach or a decision in Orchestrator workflow learning question

I have a workflow with a scriptable task and an action. The scriptable task finds the available networks for a reservation and returns an array of strings like ['192.168.1.x', '192.168.2.x', '192.168.3.x']. Lets call it networkArray. That array gets passed to the action called ac_bluecatIPAM that connects to my powershell host which runs a script that connects to our Bluecat (API gag) IPAM. The script takes 1 input, ie the 1st element of networkArray. If it finds an open reservation for that network, it returns and array of strings [ip,mask,subnet,dns]. If it does not find a match, it returns "no ip found" which is element [0] of that array.

So, I have 2 options. I CAN just pass the whole array to the Bluecat IPAM and have it go through all the network(s) untils it finds an ip or none. I really would like to not go this route and control the logic/looping in Orchestrator.

I am really wanting to to learn how to do this in Orchestrator where I iterate thru networkArray, passing each element until I get an IP and not "no ip found".

I looked at "Custom Decision". I can get the actionresult from ac_bluecatIPAM and I can do an if/then. I do get the IP info back, I can log it. I THOUGHT I could just then if it is successful set my workflow attributes for ip info but there are no OUT bindings. I thought if it came back "no ip found" i could also set an attribute as a counter, itierate it, and pass it back for another run using next element in networkArray but again not OUT. Decision activity looked the same.

I can't really get my head around how to use the foreach . I  know I want to iterate through networkArray. If DO NOT get "no ip found" i want to set  my worflow ip attributes and move on, if I DO get "no ip found" I need to ++ my networkArray index and call ac_bluecatIPAM until i get to end of networkArray. When I get there, i need to break out of workflow.

thanks,ds

0 Kudos
7 Replies
sbeaver
Leadership
Leadership

It would seem to me that if you made a request for the next available IP in a subnet you should be able to get what you need a little easier. At least that is how most of stiff has been set up in the past but to answer your question you can try something like....

var ips = [Array] IP Addresess

for each ( var ip in ips ) {

     if ( ip.name.indexOf("no ip found")){

          System.log("Found Open IP")

          return ip.ipAddress

     }

Personal note:  You are using BlueCat and have many API options available.  Why worry about this in the form?  You can reserve the name and IP during a different phase and I would absolutely just make a request for the next available address and then you can update the vRA properties once you have that info.  You might have a specific use case for getting this in the form and if so cool but if you don't I would consider using some of the native APIs and let BlueCat do what it does best.

FYI there is a BlueCat Orchestrator Plugin that is worth checking out

Cheers!

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**
0 Kudos
daphnissov
Immortal
Immortal

And just to put it out there, if you just want to skip the custom code in vRO altogether, SovLabs has an IPAM plug-in specifically for BlueCat which is 100% able to be setup and managed from within vRA without writing or maintaining any JS. SovLabs Docs - BlueCat DNS

0 Kudos
AnotherPassword
Enthusiast
Enthusiast

We tested the Sovlabs integration and were not able to secure funding so the API is the only option.

0 Kudos
daphnissov
Immortal
Immortal

Ah, too bad. The BlueCat API is horrible to work with. Did their solution at least work for you?

0 Kudos
AnotherPassword
Enthusiast
Enthusiast

This is coming from a PRE Event Broker subscription. So I am going to populate the IP info into the vmproperties (along with cloneSpec etc). The issue is that we have multiple networks per cluster, so I can not assume the 1st network for the reservation will have any IPs. I want to make orchestrator loop through the networks using my bluecat action until it finds an IP, I can then move on and assign the IPs to propeties etc. The Bluecast API does not take a list of subnets and walk them.

What other phase would I do this in?

0 Kudos
AnotherPassword
Enthusiast
Enthusiast

Yes, the Sovlabs bluecat integration did work for demo purposes.

0 Kudos
AnotherPassword
Enthusiast
Enthusiast

Got it working. Dragging the forEach onto the main workflow (in my case from the Event Broker PRE subscription that exposes the payload) asks for which workflow you want to run the ForEach on. The workflow I specified has 1 input paramater (an array of subnets to test if there is an address available in bluecat) and 1 output, an array of strings which are the results. You specify the iterator array as the array (attribute) from the main workflow you wish to traverse. The for each takes each element and runs the workflow you chose against it. It then updates the output which you map to an attribute in the main workflow.

ONE THING to be careful of. In my case, since I am consuming the payload, when I dragged the foreach onto the workflow, make sure skip promoting the input paramater from the workflow the foreach is running, or you will get 2 paramaters and the payload will fail.

And for all wondering why all the trouble, we have multiple vcenters, multiple clusters, each of which may or may not have 1 or more available networks. So on a build request I have to determin where the template is coming from so it is in the same region, which cluster it will land on based on criteria such as prod or non-prod or specific applicatoin, then based on that figure out which networks are available and then look them up in a IPAM which may or may not be correctly populated.

0 Kudos