This is the second in a series of blog posts dedicated to SAP Landscape Virtualization Management (LVM) and aims to provide a quick overview of how you can customize SAP LVM with custom operations and hooks and is aimed at system administrators responsible for configuring and operating SAP LVM. Although the details provided show how this can be achieved in a UNIX environment, it can be easily adapted for the Windows platform. In this blog, we will show you how to create custom operations and hooks for managing a Red Hat® cluster containing the SAP Central Services (SCS).

SAP LVM can be setup to manage SAP instances and databases using the SAP Host Agent. This is standard with out-of-the-box SAP LVM Standard Edition and is free to all SAP customers owning at least one active SAP application license.

Out-of-the box operations include “stop”, “start”, “restart”, “mass stop”, “mass start” and “mass restart” but SAP LVM can be extended to include your own custom operations that can be associated to instances and hosts to provide additional system management capabilities.

Custom operations are defined in LVM via a Provider Implementation and a Custom Operation and/or Hook definitions and, as with SAP LVM custom instances, they are registered with the SAP Host Agent using a configuration file.

As custom operations are reliant on the SAP Host Agent being present and running on the server hosting the custom instance, you will need to ensure the SAP Host Agent is installed before being able to add custom operations.

Provider Implementation

The Provider Implementation defines the link between SAP LVM and the SAP host agent and describes how the custom operations are implemented. In this example, the provider implementation “LVM_CustomOperation_ClusterAdm” will be defined for administering the clustered services.

The Provider Implementation must include the custom parameter OPERATION which SAP LVM will supply to the SAP host agent when triggered from the SAP LVM system.

The SAP host agent configuration file definition for the provider implementation will reference the Korn script with the $[PARAM-OPERATION] parameter.

Custom Operation Definitions

The custom operation “Freeze” is used to freeze the Red Hat cluster so that other operations can take place without a cluster failover – e.g. stop, start and restart. You want to prevent the cluster from failing over for example, when you wish to apply maintenance to the clustered service and have full control of where the cluster groups reside during this maintenance. The rolling kernel switch functionality would be one example where you would need to have this level of control.

The important fields to note here are the “Name” and “Button Group” – Freeze and Cluster Operation respectively. The custom parameter “Operation” has been set to FREEZE which will be passed to the host agent and subsequently the Korn script via the configuration file. The “Name” and “Button Group” appear on the host operation screen in SAP LVM. Clicking the Cluster Operation button triggers the custom operation and the associated Korn script. Constraints have been added in this definition to further restrict where the Cluster Operation button appears – i.e. only in Production and Test systems and for the SAP Central Services and SAP Web Dispatcher.

Similar custom operations are created for “Unfreeze” and “Relocate”.

Custom Hook Definitions

The custom hook is needed to intercept stop and start requests for the SAP Central Services in order to prepare the cluster (freeze/unfreeze) so that cluster monitoring does not incorrectly failover the instance whilst your controlled stop/start operations are being performed.

Host Agent Registered Scripts

For each Provider Implementation a standard host agent configuration file with extension “.conf” must be created in the “operations.d” sub-directory of /usr/sap/hostctrl/exe. For the cluster management custom operations the sample configuration file “ClusterAdm.conf” would look as below.

The “Name” must match the name of the Registered Script on the Provider Implementation in SAP LVM. The $[PARAM-OPERATION] can be seen being passed as the first parameter to the Korn script, indicating the custom operation being requested by SAP LVM.

Sample Configuration File for Cluster Operation (ClusterAdm.conf)

Name: LVM_CustomOperation_ClusterAdm
Command: /sap/Scripts/ClusterAdm.ksh $[PARAM-OPERATION] $[SAPSYSTEMNAME]
Workdir: $[DIR_HOME:#sapparam]
Username: root
ResultConverter: flat

Example Script for Cluster Administration

Included here is an extract from the Korn script for the administration of the cluster. Site specific validations and checks should be performed before this coding extract but this shows the important coding which performs the actual functions it is written for.

Sample Coding for Monitor Operation (ClusterAdm.ksh)

# Variables from LVM via Hostagent Configuration File                                                                                                            
# Determine requested operation                                                                                                            
case $OPERATION in
  STOP) echo "[RESULT]: ${OPERATION} requested for a clustered service”
        if [[ ${STATUS} != "FROZEN" ]]; then
          echo "[RESULT]: Service group is not currently frozen; FREEZE operation will be enforced”
 START) echo "[RESULT]: ${OPERATION} requested for a clustered service”
        if [[ ${STATUS} != "FROZEN" ]]; then
          echo "[RESULT]: Service group is not frozen; nothing to do”
          exit 0
  FREEZE) echo "[RESULT]: Cluster operation ${OPERATION} requested”
          if [[ ${STATUS} == "FROZEN" ]]; then
            echo "[RESULT]: Service group is already frozen; nothing to do”
            exit 0
UNFREEZE) echo "[RESULT]: Cluster operation ${OPERATION} requested”
          if [[ ${STATUS} != "FROZEN" ]]; then
            echo "[RESULT]: Service group ${SERVICE} is not frozen; nothing to do”
            exit 0
RELOCATE) echo "[RESULT]: Cluster operation ${OPERATION} requested”
          if [[ ${STATUS} == "FROZEN" ]]; then
            echo "[ERROR]: Service group ${SERVICE} is frozen; ${OPERATION} operation not possible”
            exit 8
       *) echo "[ERROR]: Invalid cluster operation - ${OPERATION}”
           exit 8;;
# Perform operation
echo "[RESULT]: Command issued to OS: ${clus_path}/clusvcadm ${OPERAND} ${SERVICE}”
/usr/sbin/clusvcadm ${OPERAND} ${SERVICE}
exit 0

Useful Links and Notes

The following pages on SAP Help are useful:

Configuring Custom Operations

Configuring Custom Hooks

The following SAP notes provide some information:

1465491 – Provider Implementation Definition

If you’d like to learn more about the capabilities of SAP LVM or SAP LaMa or are considering your own deployment, drop us a line with no obligation