Time for a another lesson in vCO or vRO as its called now. Today I am going to talk about composite types. They help with reducing the complexity and the amount of workflows required. The example I will show today is with an F5, its a situation where there is 3 F5 devices servicing different zones, in this case we will say DEV/TEST/PROD. We can use a composite type to select the rest operation for the environment we want to hit we want basically similar to a case statement.
As we can see from the below image we have 3 rest hosts which represent our 3 F5 devices. there is multible ways we could do this but for this example each rest host will have 2 rest operations one for GET and one for PUT.
1) Let look at how we can create a composite type, open any workflow or start a new one and when addting an attribute either through the general tab or when working in the schema when we select the attribute type we notice a hyperlink at the bottom of the dialog box which says “Define Composite type” as shown in the below image. Click on this to bring up the next window.
2) another window will open, this is we define our selection, By clicking on the small blue arrow icon adds a new line where we enter the name (The name will be used when we make a call to the composite property). In this one we have added DEV, TEST, PROD which will be our selections. .
3) In the type field this is where we choose the property type for this object, Click on the type which should say “not set” if no value has been chosen yet. For this use case here we have selected Rest Operation for all three. This could also be used to hold multiple different object types and values almost like an array of object types if you will. But here we only need the one type.
4) once finished naming and selecting the types click on the “Define” button. We should now see something similar to the bellow image. Here I have done 2 composite types the break it up for both PUT and GET.
5) Now it time to assign the rest operations to the dev, test and prod in the composite type. To do this we click on the properties as shown below. Note if this is the first time assigning the value then it will say “not set”
6) This will bring up a window as shown in the below image, As we can see all my names are shown with a properly link underneath. By clicking this we then choose in this case a preconfigured rest operation as shown in the first image on this post. Click on the define button to accept the selections.
7) It is now time to use this in a workflow. Im going to updating a previous workflow I did which was to change the F5 monitor send and receive strings which is located on flow grab on THIS link (I will be also updating this with what has been done today)
8) In this flow we have 4 inputs this is monid which is the monitor name we want to change. Next is the sendvar and recvar which are our strings, and last in the env which is going to match our DEV,TEST or PROD name we listed in the composite type.
9) We now move onto the first object Set Rest operation script this is where we will use the composite types. the script we use is very simple and is very much like calling out an array value.
Here I am using 2 blank rest operation objects and will assign thier value based on the env string we imput:
<variable> = <compisite type name[object name]>
10) Next up we move onto get current monitor which is just the stock standard invoke rest operation workflow built into vCO Below I have shown the visual binding to show what is being passed in.
11) Now we have all the returned content of the monitor we want to modify we now move onto constructing the json to send back to the F5 appliance.
var jsonObject = JSON.parse(contentAsString);
newID = monid + "Monitor";
jsonObject.send = sendvar;
jsonObject.recv = recivevar;
var jsonPutContent = JSON.stringify(jsonObject);
System.log("JSON PUT STING = " + jsonPutContent);
When using PUT to update the monitor it would not accept it unless I removed the defualtsFrom section.
12) the next part is making the change to mon, this again is a stock standard invoke rest operation workflow, but we are passing in the json content and using the PUT operation
Thats it, a very simple way to use composite types.
This workflow is available for download on FlowGrab follow THIS link