Working with configurations

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.

Getting ready

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.

How to do it...

We will split the recipe in two sections, creating and using a configuration.

Creating a configuration

  1. Using the Orchestrator Client in Design mode, click on Configurations (the white paper with a gear icon).
  2. Right-click on the root and create a new folder. Give the folder a name. It's always a good idea to use new folders.
  3. Right-click on the new folder and select New element. Give the new element a name. The new configuration opens up in edit mode. Click on Attributes.
  4. Now, we can create new variables as we used to in a normal workflow. Create the following variables:

    Name

    Type

    Value(s)

    Use

    selectionList

    Array of String

    First, Second, Third

    This represents a selection list

    passwordLength

    Number

    8

    This limits the number of letters that can be entered

  5. Click on Save and Close.

    Creating a configuration

Using a configuration in a workflow

We will now make use of the variables we created in the configuration:

  1. Using the Orchestrator Client, either make a duplicate of the example workflow 05.05 Workflow Presentation or edit it.
  2. In the General tab, click on the selection attribute and click on the two blue arrows right next to value (see the following screenshot).
  3. In the window that pops up, you will find all the configurations that Orchestrator knows; click on the one you have created.
  4. You now see all the variables that you have defined in this configuration; please note that only the ones that match the current type are black and selectable, all others are grayed out.
  5. Select the array of strings and click on Select. See how the value of the attribute has changed and that it now points to the configuration.
  6. Link the length attribute to the configuration element of the same name.

    Using a configuration in a workflow

  7. You are now able to use the values from the configuration inside the workflow. Give it a go.

How it works...

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.

There's more...

You can use JavaScript to read and write configuration values. The scripting classes are as follows:

  • ConfigurationElement
  • ConfigurationElementCategory
  • Attribute

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.

See also

The example workflows:

  • 08.03.1 Using Configuration
  • 08.03.2 read and write configurations
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset