Now that we understand how to work with a workflow, we will take the next step of combining workflows. As there are a lot of previously created workflows in the library, we can simply play Lego and build a new workflow from the existing elements. This is a common practice. What is also pretty common is to modify the existing workflows to make them do what you would like them to do. In this chapter, we will do all that and a bit more.
For this chapter, I assume that you have gone through the previous chapter or are familiar with its concepts. Here are the major concepts that we'll look at in this chapter:
A very common task for workflow creators is to use the existing workflows and put them together. In this section, we will create a new workflow that consists of other workflows. We will build a workflow that will create a VM, add and mount a CD-ROM, and then start it. We have already used the workflows involved in the last chapter. During the next chapters we will enhance this workflow further.
In order to build a workflow that combines two or more existing workflows, we first need to create a new empty workflow. Just placing a workflow somewhere in the library isn't really that professional. So, we will create a new folder in the library that we will use to store our workflows in. This will also help us later when we create a new package for export (see Chapter 9, Packing It All Up).
To create a new library folder, perform the following steps:
A new folder has been created.
You can change the name of the folder by right-clicking on it and then selecting Edit.
Now that we have a folder, we can create a new empty workflow in it, simply follow these steps:
The new workflow opens up and is now ready for editing:
You have seen the preceding window before in Chapter 4, Working with Workflows, where we discussed what each item in this window means.
Let's add elements to our new workflow.
There are two methods that can be used to add workflows to a new workflow. We will first add the Create simple virtual machine workflow by searching for it and then the Add CD-ROM workflow by selecting it from the library.
simple
. The more you type, the fewer results are shown. Now type [space] and vi
.The workflow element has been added to our new workflow. Let's add the Add CD-ROM workflow a different way.
Actions are a different type of workflow. They are what programmers call functions. In Orchestrator, an action is written in JavaScript and can only have one out-parameter, whereas a workflow can have more than one. We will have a closer look at actions in the next chapter when we also look at JavaScript.
Adding an action also works via two methods, as is the case with workflows. Now, we will add an action to our workflow that starts up (powers on) a VM:
We can also use the Action element from the Generic toolbox, which works by searching for the name of an action, just like we did with the workflows.
The big question is, why should we add an action? Surely there is a workflow that powers on a VM? Well, there is one such workflow, and we will work with it at the end of this chapter when we talk about altering existing workflows. The problem with the Start virtual machine and wait workflow is that it waits for the VMware tools to start up inside the VM. However, we are creating a brand new, empty VM. So, there are no VMware tools yet. Therefore, we have to use the action.
Now that we have added two workflows and one action, we have all the elements of our new workflow together, and we can now go ahead and assign all of their parameters.
As you know from Chapter 4, Working with Workflows, each workflow has attributes as well as input and output parameters. To make our new workflow actually work, we need to assign the input and output parameters to our newly created workflow.
Just be mindful of the fact that this process involves a pretty long set of steps, but persistence definitely pays off.
The Delete icon deletes this element from the schema. The Error Path icon will be discussed later in Chapter 8, Errors, Logs, and Debug Mode. The Open Details icon displays the workflow in a separate window so that you can check what it actually does. The Edit icon is the one that we will be using.
Parameter |
Type |
Value |
---|---|---|
vmName |
INPUT | |
vmGuestOs |
Value |
windows7_64Guest |
vmFolder |
Value |
Select a folder in your infrastructure |
vmResourcePool |
Value |
Select a resource pool in your infrastructure |
vmHost |
NULL |
We don't need to fill anything into this parameter |
vmDiskSize |
Value | |
vmMemorySize |
INPUT | |
vmNbOfCpus |
INPUT | |
vmNetwork |
Value |
Select a VM network from your inventory |
vmDatastore |
Value |
Select a datastore in the your infrastructure |
diskThinProvisioned |
Value |
Select Yes to allow for thin provisioning |
Parameter |
Type |
Value |
---|---|---|
vm |
existing |
newVM |
ConnectAtPowerOn |
Value |
Yes |
deviceType |
Value |
Datastore ISO file |
filePath |
Value |
[Datastore name] folder/file |
We are done. We have assigned all the parameters of all the elements in our schema. We learned how to assign a parameter as an input and set a value for it or ignore it by setting it to NULL. We also learned about the special output parameter that actions have.
Since Orchestrator 5.5, things are easier. When you click on the Edit icon, note the grey information bar with a Setup button. By clicking on it, you will now be able to quickly assign all the parameters in one window. Selecting Skip will set the parameter to NULL.
Now that we have assigned all the parameters of the workflow element to the new workflow, we can finally save it and give it a go.
To save the workflow, click on Save and close. If you have created the workflow correctly, Orchestrator will ask whether you want to create a new version of this workflow. In this case, skip to the next section.
If you did something wrong (and you may want to try this), you will be presented with a window that looks like this:
When Orchestrator saves a workflow, it checks whether all the parameters are assigned, whether there are any empty scripts, and so on. If this is the case, you will get a warning. You can ignore this warning by clicking on Continue anyway. This will save the workflow in the current state. However, you will not be able to execute it.
If you click on View details, Orchestrator will present you with a window that shows its findings.
In the preceding example, I didn't assign the deviceType and diskThinProvisioned parameters. I also added a thisIsTooMuch attribute, which isn't used. In section A, we find the error that Orchestrator found. In section B, we see the workflow element in which this error occurred. In section C, you are presented with a possibility of fixing the problem. Clicking on Bind parameter will bring you directly to the window where you can create a new parameter or choose from an existing one.
The Delete attribute option should be used with caution. You may not want to delete the parameter. You may just have forgotten to assign it to something. So, check it out first.
You can also run the validation at any point by clicking on Validation Validate at the top of the schema.
When you save and close a workflow, you are asked whether you would like to Add to Version History. What this means is that Orchestrator can keep different histories of a workflow.
Selecting Increase version will create a new version of the workflow. You can see the current versions of a workflow in the General section. By clicking on Show version history, you can see all the existing versions of this workflow.
You can use this function to compare the versions of a workflow.
Perform the following steps to revert to an older version of the workflow:
Your workflow is now of an earlier version. However, the newer version is still available. You can also revert to a newer version if you wish.