Credit goes to demehta for writing this article!
At various stages in the deployment lifecycle of VMs, Cisco CloudCenter supports the ability to control the behavior of the provisioning process. The different lifecycle points where the behavior can be controlled are called topics. The behavior is controlled by scripts via callouts that are assigned to topics. Some common use cases for callouts are as follows
The callout scripts are configured on a per-CCO (Cloud Center Orchestrator) basis and thus allowing users to control the deployment behavior based on the target cloud. Each callout consists of two key parts: a configuration file (callout.conf) and the script to be executed. These files are placed in the /usr/local/osmosix/callout/<name> path on the CCO. The name of the sub-folder that you use is arbitrary, but a best-practice is to use the name of the topic that the callout is for. Ex: /usr/local/osmosix/callout/ipam/<files>
Each callout script, when executed from CloudCenter, has access to a wide variety of environment variables that can be used, including cloud type, deployment environment, etc. A full list is available in the callout script log at /usr/local/osmosix/callout/<name>/logs/<logs>
The callout scripts use the same parameters and incoming variables. However, each callout script exposes a different variable and they are mutually exclusive.
Please refer to the following URL for more information about Callouts in CloudCenter
Use Case: Using callout to assign static IP address during deployment time
Sometimes there is a requirement to assign static IP addresses to the VM’s during application deployment. This may be due to the application requirement or the cloud environment requirement.
For this use case, we will use the IPAM callout topic to assign static IP addresses to the VM’s during deployment time.
We need to configure the callout on the CCO before we begin to deploy applications by providing static IP address at deployment time.
Following are the steps to configure the callout on the CCO
1. First, we need to create a folder on the CCO under the callout directory on the CCO.
To keep things simple, we will create a directory called ipam-static
2. Create the following file in the ipam-static directory
The key value pairs for the callout.conf are as follows
The name must match the dir name that we have configured in Step 1.
3. Create the script run.sh in the ipam-static dir
This script is that one that is going to fetch the IP address that we need to assign to the deployed node. The IP address can be read from a file or any other source. Also, all of the parameters specified during deployment time and the cloud environment variables are available to this script.
A sample run.sh that will fetch the IP Addr depending on the env is as follows:
# Get the Env Details. In this case as part of the App Profile we will define a custom variable "DEP_ENV" to indicate which list to pick the IP from
# CloudCenter CCO will be passed the variable by prefix it with eNV as shown below.
# File to fetch the IP from. These files will be stored on the CCO and will maintain the IP Addr list.
# Fetch the first available IP Address from the list and mark the status as used
ipAddr=`grep -m 1 "available" $fname | cut -d' ' -f1`
# Change the status of the IP Address from available to used
sed -i -e /$ipAddr/s/available/used/ $fname
# Configure the key value pairs that are needed to be passed to the VM for static IP Address configuration
# These value pairs will be used by the CCO to configure the static IP Address for the deployed VM
echo "nicDnsServerList_0=188.8.131.52"; # DNS Server List can also be dynamically fetched from the file.
echo "nicGateway_0=10.0.0.1" ; # Gateway can also be dynamically fetched from the file.
echo "nicNetmask_0=255.255.255.0"; # Netmask can also be dynamically fetched from the file.
4. Ensure that run.sh has executable permissions
chmod +x run.sh
5. In this case, the 2 files (dep_ip_list and prod_ip_list) that maintain the ip list will also be in the same location as run.sh i.e /usr/local/osmosix/callout/ipam-static/
The sample entries in these files look like as follows
At this point we have configured all of the steps that we need as part of the callout.
The next step is to configure the App profile so that we can specify a static IP address during deployment.
As part of the App profile, we are going to create a custom parameter as shown below
During deployment time, depending on the Environment that the user selects, the callout script will automatically fetch the IP address to be assigned to the VM's.
Please note that the run.sh script is a sample script to showcase how callout's can be configured in CloudCenter to manage static IP addresses.
The script can be customized to meet the user's requirement.
Some examples are as follows