cancel
Showing results for 
Search instead for 
Did you mean: 
cancel

CloudCenter IPAM Callout Module for Static IP Addressing assignment

735
Views
7
Helpful
0
Comments

Credit goes to demehta for writing this article!


Overview

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


  • Query an IPAM tool during the IP Address Allocation (IPAM) topic to get an IP address and during the IP shutdown topic (IPAM2) to de-allocate the IP address.
  • Assign static IP address to the nodes during deployment time and release the IP address back to the pool upon tear down of the deployment.
  • Configure the name of the VM that is going to be deployed
  • Initiate some clean up action before terminating a deployment


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

http://docs.cloudcenter.cisco.com/display/CCD46/Callout+Scripts

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

/usr/local/osmosix/callout/ipam-static/

2. Create the following file in the ipam-static directory

/usr/local/osmosix/callout/ipam-static/callout.conf

The key value pairs for the callout.conf are as follows


     callout.conf


name=ipam-static

type=exec

topic=ipam

debug=true

executable=run.sh

reinject=true

disabled=false

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:

     run.sh

#!/bin/bash

# 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.

dep_env=$eNV_DEP_ENV


# File to fetch the IP from. These files will be stored on the CCO and will maintain the IP Addr list.

fname=${dep_env}_ip_list

echo $fname

# Fetch the first available IP Address from the list and mark the status as used

ipAddr=`grep -m 1 "available" $fname | cut -d' ' -f1`

echo $ipAddr


# 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 "nicIP_0=$ipAddr"

echo "nicDnsServerList_0=8.8.8.8"; # 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


dev_ip_list

10.0.0.2 available

10.0.0.3 available

10.0.0.4 available

10.0.0.5 available

10.0.0.6 available

10.0.0.7 available

10.0.0.8 available

10.0.0.9 available

10.0.0.10 available

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


centosscreenshot.png

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


  • User can specify the IP Address to be assigned as part of the App profile
    • In this can we can define a custom parameter to take the IP Address as input during deployment.
    • The logic for the callout script will read this IP and can check against a list to see if it is available or assigned and take actions accordingly.
  • Pick IP address depending on the Environment where the VM is deployed and configure a domain name for the deployed VM
    • In this case, we can also specify domain name as an additional parameter and the script will configure the IP Address and then configure the domain name as well.
CreatePlease to create content
Content for Community-Ad
August's Community Spotlight Awards
This widget could not be displayed.