• This site is read-only while we complete some maintenance. You can't create or edit pages right now.
CloudCenter 4.8 has reached End of Life (EOL) as of November 14, 2018. See End of Support Notices for additional context.

Deployment Lifecycle Scripts

Script Workflow

Scripts can be called at multiple points during a deployment. The following images depict the execution process for each service workflow:

Node Initialization Workflow


External Initialization Workflow for VM tiers.

See External Service for additional context.

External Initialization Workflow

For non-VM tiers like application tiers. See External Service for additional context.

Node Reboot Workflow

Triggered from either the VM Reboot or Suspend/Resume action in the Deployments page.

The Suspend script, introduced in CloudCenter 4.8.0 is similar to the Resume script that is triggered when the node is suspended.

Node reboot 4.8

Node Update Workflow

Triggered by a VM scaling action or a reboot on other VMs.


Node Terminate Workflow

Requires all nodes to be running in order for the application to be powered off.


Script Categories

Service lifecycle actions can be divided into two categories:

  • Service Scripts: Each service script corresponds to a Service Lifecycle Actions. See Service Administration for additional context. Once the root admin configures the services and makes it available to users, users can access the service and add on their own application scripts to each service or tier as required.
  • Application Scripts: Users specify each application script when modeling an application or application profile. The New Application and New Application Profile sections provide more details on these scripts.

Using Scripts in Application Profiles

While the Topology Modeler > Services tab (or palette) allows the root admin to add on the required services for each user or tenant, the Topology Modeler > Properties tab allows users to initialize, clean up, or resume the app tier. The following images highlight the application script configuration location in the Topology Modeler's Properties tab.

  • Service Initialization Pre-Start and Post-Start:

  • Node Initialization and Clean Up:
  • External Initialization (see External Service for additional context):
  • Similarly, you will also find the Migration and Upgrade in the configuration location in the Topology Modeler's Properties tab.

Script Source Details

The different script sources are explained in the following table:

Sourcing MethodsDescriptionAdditional Details

Points to a repository hosted in the external site (such as HTTP or Amazon S3).

See Share Artifact Repositories

File in package

The script resides in the Application Content Package.

See the Application Content Package section below
URL or Command

A URL Points to a file that is downloaded and executed by the Management Agent. This URL can point to any location relevant to this service.

A command (shell or powershell direct commands) is used to run all service-related actions. For example: apt-get install foo, or echo hello, or rerun cliqr, and so forth.

The script option does not work when using the command line. Instead, use the URL option and add a script URL.

See Parameters and Macros

Script from bundle (for Service Lifecycle Actions)

The script path is a relative path inside the extracted folder (/usr/local/osmosix/service).

The name of the bundle directory must match the name displayed in the Identifier field. This step is essential – the service cannot be created if the name or the relative path differs.

This action is only available if the service points to a bundle Location.

See Bundle Store –  Repo (Conditional)

Lifecycle Action Script Definition

The following table identifies the level and details required to define and use each script.

See the following sections for additional information on the lifecycle action script definition at each level:

All scripts are executed from the current script directory and allow multiple scripts to be issued at the same time.

Script Download Owner Permission

The download owner permission for all scripts at all levels is root (-rwxr-xr-x).

 ScriptLevel of Script


Script Download LocationUser Running ScriptScript Run Location
Pre-VM StartRegion

  • /opt/remoteFiles/cliqr_local_file/
  • C:\temp\remoteFiles\cliqr_local_file\


Same as Script Download Location

Pre-VM Init
Post-VM Init
Pre-VM Init
Post-VM Init

  • /usr/local/osmosix/service/{serviceName}/
  • C:\program files\osmosix\service\{serviceName}\

Same as Script Download Location
Clean Up
Pre-VM StartService
  • /opt/remoteFiles/cliqr_local_file/
  • C:\temp\remoteFiles\cliqr_local_file\


Same as Script Download Location
Pre-VM Init
Post-VM Init
Pre-VM Init
Post-VM Init
Initialization ScriptApplication
  • /opt/remoteFiles/initScript/
  • C:\temp\remoteFiles\initScript\
Agent user (typically cliqruser)Same as Script Download Location
Cleanup Script
  • /opt/remoteFiles/cleanupScript/
  • C:\temp\remoteFiles\cleanupScript\


  • Resume Script
  • Suspend Script
  • /opt/remoteFiles/resumeScript/
  • C:\temp\remoteFiles\resumeScript\
Agent user (typically cliqruser)
Pre-Start Script


(Service Initialization)

  • /opt/remoteFiles/cliqr{serviceName}PreStartAction/
  • C:\temp\remoteFiles\cliqr{serviceName}PreStartAction\


Post-Start Script
  • /opt/remoteFiles/cliqr{serviceName}PostStartAction/
  • C:\temp\remoteFiles\cliqr{serviceName}PostStartAction\
Pre-Stop Script
  • /opt/remoteFiles/cliqr{serviceName}PreStopAction/
  • C:\temp\remoteFiles\cliqr{serviceName}PreStopAction\
Post-Stop Script
  • /opt/remoteFiles/cliqr{serviceName}PostStopAction/
  • C:\temp\remoteFiles\cliqr{serviceName}PostStopAction\
VM Pre-provision Script
  • /opt/remoteFiles/cliqr_local_file/
  • C:\temp\remoteFiles\cliqr_local_file\
Same as Script Download Location
VM Pre-initialization Script
VM Post-start ScriptApplication (External Initialization)

  • /opt/remoteFiles/cliqr_local_file/
  • C:\temp\remoteFiles\cliqr_local_file\


Same as Script Download Location
VM Pre-terminate Script
VM Post-terminate Script
Pre Migrate ScriptApplication
  • /opt/remoteFiles/preMigrateScript/
  • C:\temp\remoteFiles\preMigrateScript\
Agent user (typically cliqruser)/home/cliqruser/
Backup Script
  • /opt/remoteFiles/backupScript/
  • C:\temp\remoteFiles\backupScript\
Restore Script
  • /opt/remoteFiles/restoreScript/
  • C:\temp\remoteFiles\restoreScript\


Post Migrate Script
  • /opt/remoteFiles/postMigrateScript/
  • C:\temp\remoteFiles\postMigrateScript\
Pre Upgrade Script
  • /opt/remoteFiles/upgradeScript/
  • C:\temp\remoteFiles\upgradeScript\
Upgrade Script
Post Upgrade Script
Rollback Script

The dynamically-generated VM password is injected as part of the lifecycle action and made available for use inside External scripts.

  • Windows deployments: The password for cliqr users is available in the cliqrWindowsPassword environment variable in the pre-Init, post-start, pre-terminate, and post-terminate phases.
  • Linux deployments:
    • The user name is available in the sshUserName environment variable
    • The SSH private key is available in the sshKey environment variable.
    • The SSH public key is available in the sshPublicKey environment variable

Utility Files

Users can also include utility files in scripts.

The following are some examples of utility files that can be sourced by Linux users:

  • Environment Variables: /usr/local/osmosix/etc/userenv

  • OS Information: /usr/local/osmosix/service/utils/os_info_util.sh

  • Service Install Utility: /usr/local/osmosix/service/utils/install_util.sh

  • Configuration Utility: /usr/local/osmosix/service/utils/cfgutil.sh

  • Request Utility: /usr/local/osmosix/etc/request_util.sh (send request to agent to get things done)

The following are utility files that can be sourced by Windows users:

  • Environment Variables: c:\temp\userenv.ps1

  • Utility Information: c:\Program Files\osmosix\etc\cliqr.ps1
  • Request Utility: c:\Program Files\osmosix\etc\request_util.ps1

Parameters and Configuration Files

CloudCenter-Defined Parameters are also available for use in application profiles to automate jobs without writing extensive scripts (examples include timestamp, dynamically-generated IP address, private IP address, IP address of a tier, environment variables, automation policy parameters, number of nodes in a cluster, deployment name, and so forth).

Sometimes, you may have a custom parameter already defined in a particular service that you do not want to set in the application profile. Instead, you want to leave it to your end users to Substitute a Parameter or use Troubleshooting Parameters when they model application profiles or deploy applications.

If you use parameters (either CloudCenter-Defined Parameters or Substitute Parameters), you may need to Modify the Service Configuration Files to reflect the correct property defined in the relevant parameter.

Application Content Package

Scripts for each VM and  its associated scripts can be bundled into a single ZIP file and referenced as an application content package in the application profile. This packaging allows for easier management of the scripts as well as the ability to enable scripts to refer to each other using relative paths without having to contain explicit download logic. See Model Using Application Packages.

Internal Reboot During Node Initialization

The reboot referenced above is initiated externally when a user reboots the VM, or issues a Suspend/Resume command, or a direct OS reboot command. This reboot usually happens after the node is fully initialized and running. 

Another reboot scenario is the internal reboot – when the reboot is part of node initialization process. This reboot is initiated by the management agent. Once the agent detects the .cliqrRebootResumeInit flag, it performs a backup and reboots itself.

You can setup multiple stage node init scripts by using appropriate flow-control logic and manipulating the following files:

  • /tmp/.cliqrRebootResumeInit 
  • $OSMOSIX_PROD_HOME/.cliqrRebootResumeInit

    $OSMOSIX_PROD_HOME defaults to /usr/local/osmosix

The CloudCenter platform executes each pass in order, picking up where it left off each time. Consider the following sample scripts:

  • Linux
    # Make sure to source these files to pick up all the CliQr environment variables.
    . /usr/local/osmosix/etc/.osmosix.sh
    . /usr/local/osmosix/etc/userenv
    # After triggered reboot, CliQr agent generates file $OSMOSIX_PROD_HOME/.cliqrRebootResumeInit
    # with prior state from /tmp/.cliqrRebootResumeInit
    # If this file DOES NOT exist, it means that this is the first pass through the script.
    # The CliQr agent has not previously triggered a reboot and created this file.
    if [ ! -e $OSMOSIX_PROD_HOME/.cliqrRebootResumeInit ];
        # Node was not rebooted already by CliQr nodeInit. First pass through this script.
        # Triggers a reboot after the script exits, then this file is deleted.
        # "Step 2" will now appear in $OSMOSIX_PROD_HOME/.cliqrRebootResumeInit
        echo "Part 2" > /tmp/.cliqrRebootResumeInit
        # Node was rebooted on the last pass through the script.
        # Read in prior state from file generated by CliQr
        step=`cat $OSMOSIX_PROD_HOME/.cliqrRebootResumeInit`
        # Check the prior state to continue with the next part of the script.
        case $step in
            "Part 2")
                # Triggers a reboot after the script exits, then this file is deleted.
                # "Step 3" will now appear in $OSMOSIX_PROD_HOME/.cliqrRebootResumeInit
                echo "Part 3" > /tmp/.cliqrRebootResumeInit
            "Part 3")
                # Don't write to /tmp/.cliqrRebootResumeInit this time. CliQr will not reboot.
                # Script exists, and node init is complete.
  • Windows
    #Set the "numOfReboots" variable to reflect the number of reboots required. In #this example the VM will be rebooted 5 times.
    $startTime = Get-Date
    $VerbosePreference = "Continue" 
    $numOfReboots = 5 
    $logPath = "C:\nodeinit"
    $logFile = "cliqr-nodeinitlog.txt"
    $envscript = ' c:\temp\userenv.ps1'
    $agent_utils = ". 'C:\Program Files\osmosix\service\utils\agent_util.ps1'"
    $tmpfolder = "C:\tmp"
    $logfolderFlag = 1
    $tmpFolderFlag = 1
    $logFileCreationFlag = 1
    Invoke-Expression $envscript
    Invoke-Expression $agent_utils
    if (!(Test-Path $logPath)){
        $logDir = New-Item -ItemType Dir $logPath 
     } else {
        $logfolderFlag = 0
    if (!(Test-Path $tmpfolder)){
        $tmpDir = New-Item -ItemType Dir $tmpfolder 
    } else {
        $tmpDir = $tmpfolder
        $tmpFolderFlag = 0
    $logFilePath = Join-Path $logPath $logFile
    if (!(Test-Path $logFilePath)){
        $logFile = New-Item -ItemType File (Join-Path $logPath $logFile) 
    } else {
        $logFile = $logFilePath
        $logFileCreationFlag = 0
    function print($line,$logFileHandle) {
        $timestamp = get-date
        $line = [string]$timestamp + " : INFO " + $line
        Write-Output $line >> $logFileHandle
        Write-Verbose $line
        agentSendLogMessage $line
    ############MAIN ##########################
    $resumeinitfile1 = Join-Path (Get-ChildItem env:OSMOSIX_HOME).Value ".cliqrRebootResumeInit"
    $resumeinitfile2 = Join-Path $tmpDir ".cliqrRebootResumeInit"
    if (! (Test-Path $resumeinitfile1)) {
       #Checking for existence of file for first reboot. If not then create the flag file 
       print "File .cliqrRebootResumeInit not created yet" $logFile
       Write-Output "RC=1" > $resumeinitfile2
       print "Restart Count = 1" $logFile    
    } else {
       #For subsequent reboots flag file will exist in a different location
       print "File '$resumeinitfile1' Found" $logFile 
       $data = gc $resumeinitfile1
       $rcCount = $data.trim().split("=")[-1]
       print "Data from $resumeinitfile1 file => $data" $logFile
       if ([int]$rcCount -lt $numOfReboots) {
            $rcCount = [int]$rcCount + 1
            $strdata = "RC=" + $rcCount 
            print "Writing data '$strdata' to file '$resumeinitfile2'" $logFile
            Write-Output $strdata > $resumeinitfile2
       print "Restart Count = $rcCount" $logFile     
    $VerbosePreference = "SilentlyContinue" 

  • No labels
© 2017-2019 Cisco Systems, Inc. All rights reserved