Unsupported content

 

This version of the product has reached end of support. The documentation is available for your convenience. However, you must be logged in to access it. You will not be able to leave comments.

While loop example: Look up available hostname

In this example, the While activity is used to look for the next available hostname in a user's environment. The user provides an initial hostname value for a hostname lookup and specifies the number of times to run the process. The While loop runs as long as the specified conditions are met. The While loop generates a list of available hostnames and stores them in a file.

This section provides an overview of the While loop example and the activities used to create the workflow.

When the process starts, the user is prompted to provide the following values:

  • The hostname prefix 
  • The starting hostname value, called hostno
  • The maximum number of times the process will run through the While loop. 

In this example, the user provides the following parameters:


The hostname utility concatenates the provided hostname prefix and hostno and outputs the value to a context item called hostname.

In this example, the value is server01.


The process does a DNS lookup for the hostname and outputs the result to the adapter response context item. The result is in XML format.

The Assign activity filters the XML in adapter response to return the hostname from the hostname context item.

Basic and advanced transforms are used in this activity as follows:

 The switch compares the DNS hostname lookup output to the hostname context item value (server01 in this example).

An advanced transform is used for this comparison. 

The comparison results determine the next step.

  • If the hostname lookup output does not match the hostname context item value, the process proceeds to the end and terminates. 
  • If hostname lookup output matches the hostname context item value, the process continues to the While activity (the start of the While loop). 

In this example, the process continues to the While activity.

The While activity checks that the incoming hostname meets the While condition (in this example, the condition is that the incoming value has a hostno value that is less than 99).

The comparison result determines the next step.

  • If hostno is equal to or greater than 99, the process proceeds to the end and terminates.
  • If hostno is less than 99, the process continues to the next step in the loop.

In this example, hostname (server01) has a hostno of 01, so the process continues to the next step in the loop.

The increment utility increments hostno by 1.

The incremented hostname utility concatenates the hostname prefix and hostno and updates the hostname context item with the new value.

In this example, the new value is server02.


Another DNS lookup happens for the incremented hostname.

If the hostname is not found, the loop goes back to the beginning and starts again. If the hostname is found, the result is stored in the adapter response context item.

The Assign activity filters the adapter response XML to return the hostname.

The hostname is appended to the specified file on the Grid Manager machine.

In this example, the file is called hostname and located in the root directory.



This process continues until the While loop has matched the specified loop conditions (in this example, completed less than 99 iterations) and then terminates. The specified hostname file includes a list of available hostnames that were generated in the loop.

This version of the documentation is no longer supported. However, the documentation is available for your convenience. You will not be able to leave comments.

Comments