Environment variables for a connection

The following environment variables are available in the operation post_configure_source and add_source of the script component:

  • SOURCE_NODE: name of the source node in the relationship (e.g., Bash_1).

  • TARGET_NODE: name of the target node in the relationship (e.g., Bash_2).

  • SOURCE_HOST: name of the compute node which hosts the source node (e.g., Compute_1).

  • TARGET_HOST: name of the compute node which hosts the target node (e.g., Compute_2).

  • SOURCE_IP and TARGET_IP: the runtime IP address of the compute nodes, which host the source and target components, respectively.

  • All properties of the components are also available. They are prefixed by SOURCE_ and TARGET_ (e.g., SOURCE_PORT, TARGET_PORT, etc.).

Examples

  • Select Bash_2.

  • Set the port property to 27017.

  • Add an entry in the env property with key FOO value bar.

../_images/7-Bash-env-relationship.png

Figure 1. Set environment variable on a target node

In post_configure_source of Bash_1, we can access the environment variables of Bash_2:

# Result: Bash_2 is running on Compute_2 on port 27017
echo "$TARGET_NODE is running on $TARGET_HOST on port $TARGET_PORT"

# Result: Bash_2 has environment variable FOO with value: bar
echo "$TARGET_NODE has environment variable FOO with value: $TARGET_FOO"