The OCF specification is basically an extension of the definitions for an LSBResourceAgent.

OCF Resource Agents are those found in /usr/lib/ocf/resource.d/{provider} .

The OCF Spec (as it relates to ResourceAgents) can be found at: http://www.opencf.org/cgi-bin/viewcvs.cgi/specs/ra/resource-agent-api.txt?rev=HEAD

Writing your own OCF Resource Agent

Anything found in the /usr/lib/ocf/resource.d/heartbeat is provided as part of the Heartbeat package which supports them as of version 2.0.0. When creating your own agents, you are encouraged to create a new directory under /usr/lib/ocf/resource.d/ and use provider={your subdirectory name} . So, for example, if you want to name your provider dubrouski, and create a resource named serge, you would make a directory called /usr/lib/ocf/resource.d/dubrouski and name your resource script /usr/lib/ocf/resource.d/dubrouski/serge.

For convenience, many of the return codes, defaults and other OCF utility functions are available to be included by custom OCF agents from /usr/lib/heartbeat/ocf-shellfuncs

Beware: Linux-ha implementation have been somewhat extended from the OCF Specs, but none of those changes are incompatible with the OCF specification.

When writing/testing your ResourceAgent, you may find the ocf-tester script to be very useful. It comes in the heartbeat package.

Actions

Normal OCF Resource Agents are required to have these actions:

Note: OCF specs have strict definitions of what exit codes actions must return. We follow these specifications, and exiting with the wrong exit code will cause Heartbeat to behave in ways you will likely find puzzling and annoying. In particular, Heartbeat needs to distinguish a completely stopped resource from one which is in some erroneous and indeterminate state.

OCF Resource Agents should support the following action:

Additional requirements (not part of the OCF specs) are placed on agents that will be used for cloned and multi-state resources.

Some actions specified in the OCF specs are not used by Heartbeat at the moment

Parameters

In addition to having more actions, your OCF resource agent is permitted to take parameters to tell it which instance of the resource it is being asked to control, and any simple configuration parameters it might need to tell it what to do or exactly how it should be done.

These are passed in to the script as environment variables, with the special prefix OCF_RESKEY_. So, if you need to be given a parameter which the user thinks of as ip it will be passed to the script as OCF_RESKEY_ip.

Debugging your OCF Resource Agent

The most common problems when implementing OCF ResourceAgents are:

See Also

ResourceAgent DL321.pdf

OCFResourceAgent (last edited 2008-07-02 11:19:33 by LarsMarowskyBree)