How to configure a connection between two Bash components¶
In the topology, you can configure a SOURCE
node (e.g., a web application) to connect to a TARGET
node (e.g., a database ) as follows:
Step 1. Drop¶
Drop two Bash components on two compute nodes (e.g.,
Bash_1
andBash_2
).
Step 2. Connect¶
Click on the connect_to_data_endpoint point of
Bash_1
and connect to the data_endpoint ofBash_2
:
In this example, Bash_1
and Bash_2:code:
are the SOURCE
node and the TARGET
node of the relationship, respectively.
Step 3. Configure the source node¶
You can configure Bash_1
to connect to Bash_2
as follows:
Click on
Bash_1
.Provide the artifact for the operation post_configure_source. This operation will be executed on
Compute_1
after the operation configure is executed onCompute_1
successfully.
For example:
#!/usr/bin/env bash
# Result: "Hello I am a script Bash_1 executing on Compute_1 to connect with Bash_2 at 10.0.0.4"
echo "Hello I am a script $SOURCE_NODE executing on $SOURCE_HOST to connect with $TARGET_NODE at $TARGET_IP"
In this example, we use some environment variables (e.g., SOURCE_IP
, TARGET_IP
), which resolve the IP addresses of the two compute nodes at runtime. This information is useful for establishing the connection between two components. For more environment variables, see Section Environment variables for a connection.
Step 4. Configure the target node¶
In the reverse direction, you can configure Bash_2
to connect to Bash_1
as follows:
Click on
Bash_1
.Provide the artifact for the operation add_source. This operation will be executed on
Compute_2
afterBash_1
has completed successfully.
For example:
#!/usr/bin/env bash
# Result: "Hello I am a script Bash_1. I have completed and running at 10.0.0.3""
echo "Hello I am a script $SOURCE_NODE. I have completed and running at $SOURCE_IP"
This example shows we can provide a script to execute on the target node Compute_2
(e.g., to notify that Bash_1
is up and running at a given IP address 10.0.0.3
).
Expected result¶
During the deployment, the resulting workflow between Bash_1
and Bash_2
is as follows:
The orchestrator setups the TARGET node first (i.e., it calls the operation
configure
ofBash_2
onCompute_2
).Afterwards, it setups the SOURCE node to connect to the TARGET node (i.e., it calls the operation
configure
andpost_configure_source
ofBash_1
onCompute_1
).After the SOURCE node has started successfully, the orchestrator notifies the TARGET node (i.e., it calls the operation
add_source
ofBash_1
onCompute_2
).