In this recipe, we will see how configurations can improve our design. Configurations are like global variables that are centrally defined and can be used by all workflows.
We just need a working Orchestrator, and you will need the rights to create new workflows and run them. We will work with the Orchestrator Client.
We will use the example workflow 05.05 Workflow Presentation
to test the configuration.
We will split the recipe in two sections, creating and using a configuration.
Name |
Type |
Value(s) |
Use |
|
Array of String |
First, Second, Third |
This represents a selection list |
|
Number |
8 |
This limits the number of letters that can be entered |
We will now make use of the variables we created in the configuration:
05.05 Workflow Presentation
or edit it.
A configuration is what programmers would call a global variable. A global variable is a centrally-stored variable that is accessible to all workflows. Configurations are commonly used to define global objects, for example, the FQDN and credentials of a mail server or general password policies.
Let's look at a typical example for the use of configurations. You have a Development environment and a Production environment. In each environment, you have different vCenters, mail servers, and so on. You develop your workflows in Development and then use them in Production. Using configurations, you can point the workflow to different configurations that are stored in Development or Production Orchestrator.
Another example is to reduce the number of inputs a workflow requires by pushing the variables to configurations and binding them to attributes. We will explore this in the recipes in Chapter 12, Working with vSphere. Last but not least, you can use configuration to share the same variables between different workflows, such as mail server configurations.
To integrate a configuration into a workflow you have to link an attribute to the configuration variable. The variables have to be of the same type. After you have integrated the configuration attribute into the workflow, you can use it to not only pass information along (such as credentials or common server names) but also link presentation properties (such as predefined values to reduce the possible selections). We will explore this in the recipe An approval process for VM provisioning in Chapter 12, Working with vSphere.
You can also create new attributes in a configuration from a workflow. You have probably noticed the Create New selection in the Link Configuration window.
Please note that a configuration also has a history like the workflows do; see the recipe Version control in Chapter 4, Programming Skills for more information.
You can use JavaScript to read and write configuration values. The scripting classes are as follows:
To read a configuration, you can use this:
attrib=configurationElement.getAttributeWithKey(Key);
Here, Key
is a string, which contains the name of the attribute. The return value is of the Attribute
type.
To set a configuration attribute, use this:
configurationElement.setAttributeWithKey(Key, Value);
Here, Key
is a string that contains the name of the attribute and Value
is the value you would like to set it to.