2. API definitions

2.1. Environment variables

A resource agent receives all configuration information about the resource it manages via environment variables. The names of these environment variables are always the name of the resource parameter, prefixed with OCF_RESKEY_. For example, if the resource has an ip parameter set to, then the resource agent will have access to an environment variable OCF_RESKEY_ip holding that value.

For any resource parameter that is not required to be set by the user — that is, its parameter definition in the resource agent metadata does not specify required="true" — then the resource agent must

  • Provide a reasonable default. This should be advertised in the metadata. By convention, the resource agent uses a variable named OCF_RESKEY_<parametername>_default that holds this default.
  • Alternatively, cater correctly for the value being empty.

In addition, the cluster manager may also support meta resource parameters. These do not apply directly to the resource configuration, but rather specify how the cluster resource manager is expected to manage the resource. For example, the Pacemaker cluster manager uses the target-role meta parameter to specify whether the resource should be started or stopped.

Meta parameters are passed into the resource agent in the OCF_RESKEY_CRM_meta_ namespace, with any hypens converted to underscores. Thus, the target-role attribute maps to an environment variable named OCF_RESKEY_CRM_meta_target_role.