In the previous chapters, we developed a workflow that creates a new VM and mounts a CD-ROM so that a new OS can be installed on it. Our first attempts were extremely manual. Over the last chapters we have now improved it quite a bit and made it much more user-friendly. Now, we will make it not only look and feel better, but also much less error-prone. We will use workflow presentation to do this.
In this chapter, we will learn the following:
In the previous chapters, we concentrated on the workflow content and how to improve our scripting. In the chapters that we have covered so far, we also discussed the problems that wrong user input, such as the OS name, may cause and how we can intercept it by using JavaScript. Now, we will go a step further and make sure that a user cannot enter values that are wrong or not allowed.
We will start with something simple that has actually quite a massive effect, and that is, the description. A good description helps the user of a workflow better understand what they should enter in the fields.
Check out the other input parameters and decide on better descriptions. The result of your efforts becomes visible as soon as you run the workflow.
There are more options to look into, and we will now start discussing them. First, we will make sure that a user has to provide a value. Currently, a user can just submit the workflow without entering anything, which will lead to an error.
We will now make a value mandatory by performing the following steps:
Try it out and think about which other parameters should be made mandatory.
We are now sure that the user has to enter a value, but he still could go ahead and enter, for instance, -1 CPUs or 1.000 GB memory, which isn't really that helpful. So, let's fix this by using min and max values, as follows:
After locking in these values, think about which other values could benefit from a min and max value.
Have a look at the properties for the vmName. Check whether you can fix the length of the string entered. This can be quite useful, for instance, a hostname (not the FQDN but the name of the host) should have at least 2 characters, and it should not be longer than 15 characters. Have a go at it!
We have fixed the range of the values that can be entered, but when the user starts the workflow, it is still empty. It is a good idea to provide the user with some ideas or settings, such as a default value.
We can add a default value by performing the following steps:
Have a look at the other input parameters and think about which could benefit from a default value.
There are several more useful properties, but before we can go on, we need to learn about arrays.