dhodovsk / source-git / pacemaker

Forked from source-git/pacemaker 3 years ago
Clone

Blame include/crm/services.h

rpm-build 3ee90c
/*
rpm-build 3ee90c
 * Copyright 2010-2019 the Pacemaker project contributors
rpm-build 3ee90c
 *
rpm-build 3ee90c
 * The version control history for this file may have further details.
rpm-build 3ee90c
 *
rpm-build 3ee90c
 * This source code is licensed under the GNU Lesser General Public License
rpm-build 3ee90c
 * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
rpm-build 3ee90c
 */
rpm-build 3ee90c
rpm-build 3ee90c
#ifndef __PCMK_SERVICES__
rpm-build 3ee90c
#  define __PCMK_SERVICES__
rpm-build 3ee90c
rpm-build 3ee90c
#ifdef __cplusplus
rpm-build 3ee90c
extern "C" {
rpm-build 3ee90c
#endif
rpm-build 3ee90c
rpm-build 3ee90c
/**
rpm-build 3ee90c
 * \file
rpm-build 3ee90c
 * \brief Services API
rpm-build 3ee90c
 * \ingroup core
rpm-build 3ee90c
 */
rpm-build 3ee90c
rpm-build 3ee90c
#  include <glib.h>
rpm-build 3ee90c
#  include <stdio.h>
rpm-build 3ee90c
#  include <string.h>
rpm-build 3ee90c
#  include <stdbool.h>
rpm-build 3ee90c
#  include <sys/types.h>
rpm-build 3ee90c
rpm-build 3ee90c
#  ifndef OCF_ROOT_DIR
rpm-build 3ee90c
#    define OCF_ROOT_DIR "/usr/lib/ocf"
rpm-build 3ee90c
#  endif
rpm-build 3ee90c
rpm-build 3ee90c
#  ifndef LSB_ROOT_DIR
rpm-build 3ee90c
#    define LSB_ROOT_DIR "/etc/init.d"
rpm-build 3ee90c
#  endif
rpm-build 3ee90c
rpm-build 3ee90c
/* TODO: Autodetect these two ?*/
rpm-build 3ee90c
#  ifndef SYSTEMCTL
rpm-build 3ee90c
#    define SYSTEMCTL "/bin/systemctl"
rpm-build 3ee90c
#  endif
rpm-build 3ee90c
rpm-build 3ee90c
/* Known resource classes */
rpm-build 3ee90c
#define PCMK_RESOURCE_CLASS_OCF     "ocf"
rpm-build 3ee90c
#define PCMK_RESOURCE_CLASS_SERVICE "service"
rpm-build 3ee90c
#define PCMK_RESOURCE_CLASS_LSB     "lsb"
rpm-build 3ee90c
#define PCMK_RESOURCE_CLASS_SYSTEMD "systemd"
rpm-build 3ee90c
#define PCMK_RESOURCE_CLASS_UPSTART "upstart"
rpm-build 3ee90c
#define PCMK_RESOURCE_CLASS_NAGIOS  "nagios"
rpm-build 3ee90c
#define PCMK_RESOURCE_CLASS_STONITH "stonith"
rpm-build 3ee90c
rpm-build 3ee90c
/* This is the string passed in the OCF_EXIT_REASON_PREFIX environment variable.
rpm-build 3ee90c
 * The stderr output that occurs after this prefix is encountered is considered
rpm-build 3ee90c
 * the exit reason for a completed operation.
rpm-build 3ee90c
 */
rpm-build 3ee90c
#define PCMK_OCF_REASON_PREFIX "ocf-exit-reason:"
rpm-build 3ee90c
rpm-build 3ee90c
// Agent version to use if agent doesn't specify one
rpm-build 3ee90c
#define PCMK_DEFAULT_AGENT_VERSION "0.1"
rpm-build 3ee90c
rpm-build 3ee90c
enum lsb_exitcode {
rpm-build 3ee90c
    PCMK_LSB_OK                  = 0,
rpm-build 3ee90c
    PCMK_LSB_UNKNOWN_ERROR       = 1,
rpm-build 3ee90c
    PCMK_LSB_INVALID_PARAM       = 2,
rpm-build 3ee90c
    PCMK_LSB_UNIMPLEMENT_FEATURE = 3,
rpm-build 3ee90c
    PCMK_LSB_INSUFFICIENT_PRIV   = 4,
rpm-build 3ee90c
    PCMK_LSB_NOT_INSTALLED       = 5,
rpm-build 3ee90c
    PCMK_LSB_NOT_CONFIGURED      = 6,
rpm-build 3ee90c
    PCMK_LSB_NOT_RUNNING         = 7,
rpm-build 3ee90c
};
rpm-build 3ee90c
rpm-build 3ee90c
/* The return codes for the status operation are not the same for other
rpm-build 3ee90c
 * operatios - go figure
rpm-build 3ee90c
 */
rpm-build 3ee90c
enum lsb_status_exitcode {
rpm-build 3ee90c
    PCMK_LSB_STATUS_OK             = 0,
rpm-build 3ee90c
    PCMK_LSB_STATUS_VAR_PID        = 1,
rpm-build 3ee90c
    PCMK_LSB_STATUS_VAR_LOCK       = 2,
rpm-build 3ee90c
    PCMK_LSB_STATUS_NOT_RUNNING    = 3,
rpm-build 3ee90c
    PCMK_LSB_STATUS_UNKNOWN        = 4,
rpm-build 3ee90c
rpm-build 3ee90c
    /* custom codes should be in the 150-199 range reserved for application use */
rpm-build 3ee90c
    PCMK_LSB_STATUS_NOT_INSTALLED      = 150,
rpm-build 3ee90c
    PCMK_LSB_STATUS_INSUFFICIENT_PRIV  = 151,
rpm-build 3ee90c
};
rpm-build 3ee90c
rpm-build 3ee90c
/* Uniform exit codes
rpm-build 3ee90c
 * Everything is mapped to its OCF equivalent so that Pacemaker only deals with one set of codes
rpm-build 3ee90c
 */
rpm-build 3ee90c
enum ocf_exitcode {
rpm-build 3ee90c
    PCMK_OCF_OK                   = 0,
rpm-build 3ee90c
    PCMK_OCF_UNKNOWN_ERROR        = 1,
rpm-build 3ee90c
    PCMK_OCF_INVALID_PARAM        = 2,
rpm-build 3ee90c
    PCMK_OCF_UNIMPLEMENT_FEATURE  = 3,
rpm-build 3ee90c
    PCMK_OCF_INSUFFICIENT_PRIV    = 4,
rpm-build 3ee90c
    PCMK_OCF_NOT_INSTALLED        = 5,
rpm-build 3ee90c
    PCMK_OCF_NOT_CONFIGURED       = 6,
rpm-build 3ee90c
    PCMK_OCF_NOT_RUNNING          = 7,  /* End of overlap with LSB */
rpm-build 3ee90c
    PCMK_OCF_RUNNING_MASTER       = 8,
rpm-build 3ee90c
    PCMK_OCF_FAILED_MASTER        = 9,
rpm-build 3ee90c
rpm-build 3ee90c
rpm-build 3ee90c
    /* 150-199	reserved for application use */
rpm-build 3ee90c
    PCMK_OCF_CONNECTION_DIED = 189, // Deprecated (see PCMK_LRM_OP_NOT_CONNECTED)
rpm-build 3ee90c
rpm-build 3ee90c
    PCMK_OCF_DEGRADED        = 190, /* Active resource that is no longer 100% functional */
rpm-build 3ee90c
    PCMK_OCF_DEGRADED_MASTER = 191, /* Promoted resource that is no longer 100% functional */
rpm-build 3ee90c
rpm-build 3ee90c
    PCMK_OCF_EXEC_ERROR    = 192, /* Generic problem invoking the agent */
rpm-build 3ee90c
    PCMK_OCF_UNKNOWN       = 193, /* State of the service is unknown - used for recording in-flight operations */
rpm-build 3ee90c
    PCMK_OCF_SIGNAL        = 194,
rpm-build 3ee90c
    PCMK_OCF_NOT_SUPPORTED = 195,
rpm-build 3ee90c
    PCMK_OCF_PENDING       = 196,
rpm-build 3ee90c
    PCMK_OCF_CANCELLED     = 197,
rpm-build 3ee90c
    PCMK_OCF_TIMEOUT       = 198,
rpm-build 3ee90c
    PCMK_OCF_OTHER_ERROR   = 199, /* Keep the same codes as PCMK_LSB */
rpm-build 3ee90c
};
rpm-build 3ee90c
rpm-build 3ee90c
enum op_status {
rpm-build 3ee90c
    PCMK_LRM_OP_UNKNOWN = -2,
rpm-build 3ee90c
    PCMK_LRM_OP_PENDING = -1,
rpm-build 3ee90c
    PCMK_LRM_OP_DONE,
rpm-build 3ee90c
    PCMK_LRM_OP_CANCELLED,
rpm-build 3ee90c
    PCMK_LRM_OP_TIMEOUT,
rpm-build 3ee90c
    PCMK_LRM_OP_NOTSUPPORTED,
rpm-build 3ee90c
    PCMK_LRM_OP_ERROR,
rpm-build 3ee90c
    PCMK_LRM_OP_ERROR_HARD,
rpm-build 3ee90c
    PCMK_LRM_OP_ERROR_FATAL,
rpm-build 3ee90c
    PCMK_LRM_OP_NOT_INSTALLED,
rpm-build 3ee90c
    PCMK_LRM_OP_NOT_CONNECTED,
rpm-build 3ee90c
    PCMK_LRM_OP_INVALID,
rpm-build 3ee90c
};
rpm-build 3ee90c
rpm-build 3ee90c
enum nagios_exitcode {
rpm-build 3ee90c
    NAGIOS_STATE_OK        = 0,
rpm-build 3ee90c
    NAGIOS_STATE_WARNING   = 1,
rpm-build 3ee90c
    NAGIOS_STATE_CRITICAL  = 2,
rpm-build 3ee90c
    NAGIOS_STATE_UNKNOWN   = 3,
rpm-build 3ee90c
    NAGIOS_STATE_DEPENDENT = 4,
rpm-build 3ee90c
rpm-build 3ee90c
    NAGIOS_INSUFFICIENT_PRIV = 100,
rpm-build 3ee90c
    NAGIOS_NOT_INSTALLED     = 101,
rpm-build 3ee90c
};
rpm-build 3ee90c
rpm-build 3ee90c
enum svc_action_flags {
rpm-build 3ee90c
    /* On timeout, only kill pid, do not kill entire pid group */
rpm-build 3ee90c
    SVC_ACTION_LEAVE_GROUP = 0x01,
rpm-build 3ee90c
    SVC_ACTION_NON_BLOCKED = 0x02,
rpm-build 3ee90c
};
rpm-build 3ee90c
rpm-build 3ee90c
typedef struct svc_action_private_s svc_action_private_t;
rpm-build 3ee90c
typedef struct svc_action_s {
rpm-build 3ee90c
    char *id;
rpm-build 3ee90c
    char *rsc;
rpm-build 3ee90c
    char *action;
rpm-build 3ee90c
    guint interval_ms;
rpm-build 3ee90c
rpm-build 3ee90c
    char *standard;
rpm-build 3ee90c
    char *provider;
rpm-build 3ee90c
    char *agent;
rpm-build 3ee90c
rpm-build 3ee90c
    int timeout;
rpm-build 3ee90c
    GHashTable *params; /* used for setting up environment for ocf-ra &
rpm-build 3ee90c
                           alert agents
rpm-build 3ee90c
                           and to be sent via stdin for fence-agents
rpm-build 3ee90c
                         */
rpm-build 3ee90c
rpm-build 3ee90c
    int rc;
rpm-build 3ee90c
    int pid;
rpm-build 3ee90c
    int cancel;
rpm-build 3ee90c
    int status;
rpm-build 3ee90c
    int sequence;
rpm-build 3ee90c
    int expected_rc;
rpm-build 3ee90c
    int synchronous;
rpm-build 3ee90c
    enum svc_action_flags flags;
rpm-build 3ee90c
rpm-build 3ee90c
    char *stderr_data;
rpm-build 3ee90c
    char *stdout_data;
rpm-build 3ee90c
rpm-build 3ee90c
    /*!
rpm-build 3ee90c
     * Data stored by the creator of the action.
rpm-build 3ee90c
     *
rpm-build 3ee90c
     * This may be used to hold data that is needed later on by a callback,
rpm-build 3ee90c
     * for example.
rpm-build 3ee90c
     */
rpm-build 3ee90c
    void *cb_data;
rpm-build 3ee90c
rpm-build 3ee90c
    svc_action_private_t *opaque;
rpm-build 3ee90c
} svc_action_t;
rpm-build 3ee90c
rpm-build 3ee90c
/**
rpm-build 3ee90c
 * \brief Get a list of files or directories in a given path
rpm-build 3ee90c
 *
rpm-build 3ee90c
 * \param[in] root       full path to a directory to read
rpm-build 3ee90c
 * \param[in] files      return list of files if TRUE or directories if FALSE
rpm-build 3ee90c
 * \param[in] executable if TRUE and files is TRUE, only return executable files
rpm-build 3ee90c
 *
rpm-build 3ee90c
 * \return a list of what was found.  The list items are char *.
rpm-build 3ee90c
 * \note It is the caller's responsibility to free the result with g_list_free_full(list, free).
rpm-build 3ee90c
 */
rpm-build 3ee90c
    GList *get_directory_list(const char *root, gboolean files, gboolean executable);
rpm-build 3ee90c
rpm-build 3ee90c
/**
rpm-build 3ee90c
 * Get a list of services
rpm-build 3ee90c
 *
rpm-build 3ee90c
 * \return a list of services.  The list items are gchar *.  This list _must_
rpm-build 3ee90c
 *         be destroyed using g_list_free_full(list, free).
rpm-build 3ee90c
 */
rpm-build 3ee90c
    GList *services_list(void);
rpm-build 3ee90c
rpm-build 3ee90c
/**
rpm-build 3ee90c
 * \brief Get a list of providers
rpm-build 3ee90c
 *
rpm-build 3ee90c
 * \param[in] standard  list providers of this standard (e.g. ocf, lsb, etc.)
rpm-build 3ee90c
 *
rpm-build 3ee90c
 * \return a list of providers as char * list items (or NULL if standard does not support providers)
rpm-build 3ee90c
 * \note The caller is responsible for freeing the result using g_list_free_full(list, free).
rpm-build 3ee90c
 */
rpm-build 3ee90c
    GList *resources_list_providers(const char *standard);
rpm-build 3ee90c
rpm-build 3ee90c
/**
rpm-build 3ee90c
 * \brief Get a list of resource agents
rpm-build 3ee90c
 *
rpm-build 3ee90c
 * \param[in] standard  list agents using this standard (e.g. ocf, lsb, etc.) (or NULL for all)
rpm-build 3ee90c
 * \param[in] provider  list agents from this provider (or NULL for all)
rpm-build 3ee90c
 *
rpm-build 3ee90c
 * \return a list of resource agents.  The list items are char *.
rpm-build 3ee90c
 * \note The caller is responsible for freeing the result using g_list_free_full(list, free).
rpm-build 3ee90c
 */
rpm-build 3ee90c
    GList *resources_list_agents(const char *standard, const char *provider);
rpm-build 3ee90c
rpm-build 3ee90c
/**
rpm-build 3ee90c
 * Get list of available standards
rpm-build 3ee90c
 *
rpm-build 3ee90c
 * \return a list of resource standards. The list items are char *. This list _must_
rpm-build 3ee90c
 *         be destroyed using g_list_free_full(list, free).
rpm-build 3ee90c
 */
rpm-build 3ee90c
    GList *resources_list_standards(void);
rpm-build 3ee90c
rpm-build 3ee90c
/**
rpm-build 3ee90c
 * Does the given standard, provider, and agent describe a resource that can exist?
rpm-build 3ee90c
 *
rpm-build 3ee90c
 * \param[in] standard  Which class of agent does the resource belong to?
rpm-build 3ee90c
 * \param[in] provider  What provides the agent (NULL for most standards)?
rpm-build 3ee90c
 * \param[in] agent     What is the name of the agent?
rpm-build 3ee90c
 *
rpm-build 3ee90c
 * \return A boolean
rpm-build 3ee90c
 */
rpm-build 3ee90c
    gboolean resources_agent_exists(const char *standard, const char *provider, const char *agent);
rpm-build 3ee90c
rpm-build 3ee90c
svc_action_t *services_action_create(const char *name, const char *action,
rpm-build 3ee90c
                                     guint interval_ms, int timeout /* ms */);
rpm-build 3ee90c
rpm-build 3ee90c
/**
rpm-build 3ee90c
 * \brief Create a new resource action
rpm-build 3ee90c
 *
rpm-build 3ee90c
 * \param[in] name        Name of resource
rpm-build 3ee90c
 * \param[in] standard    Resource agent standard (ocf, lsb, etc.)
rpm-build 3ee90c
 * \param[in] provider    Resource agent provider
rpm-build 3ee90c
 * \param[in] agent       Resource agent name
rpm-build 3ee90c
 * \param[in] action      action (start, stop, monitor, etc.)
rpm-build 3ee90c
 * \param[in] interval_ms How often to repeat this action (if 0, execute once)
rpm-build 3ee90c
 * \param[in] timeout     Consider action failed if it does not complete in this many milliseconds
rpm-build 3ee90c
 * \param[in] params      Action parameters
rpm-build 3ee90c
 *
rpm-build 3ee90c
 * \return newly allocated action instance
rpm-build 3ee90c
 *
rpm-build 3ee90c
 * \post After the call, 'params' is owned, and later free'd by the svc_action_t result
rpm-build 3ee90c
 * \note The caller is responsible for freeing the return value using
rpm-build 3ee90c
 *       services_action_free().
rpm-build 3ee90c
 */
rpm-build 3ee90c
svc_action_t *resources_action_create(const char *name, const char *standard,
rpm-build 3ee90c
                                      const char *provider, const char *agent,
rpm-build 3ee90c
                                      const char *action, guint interval_ms,
rpm-build 3ee90c
                                      int timeout /* ms */, GHashTable *params,
rpm-build 3ee90c
                                      enum svc_action_flags flags);
rpm-build 3ee90c
rpm-build 3ee90c
/**
rpm-build 3ee90c
 * Kick a recurring action so it is scheduled immediately for re-execution
rpm-build 3ee90c
 */
rpm-build 3ee90c
gboolean services_action_kick(const char *name, const char *action,
rpm-build 3ee90c
                              guint interval_ms);
rpm-build 3ee90c
rpm-build 3ee90c
    const char *resources_find_service_class(const char *agent);
rpm-build 3ee90c
rpm-build 3ee90c
/**
rpm-build 3ee90c
 * Utilize services API to execute an arbitrary command.
rpm-build 3ee90c
 *
rpm-build 3ee90c
 * This API has useful infrastructure in place to be able to run a command
rpm-build 3ee90c
 * in the background and get notified via a callback when the command finishes.
rpm-build 3ee90c
 *
rpm-build 3ee90c
 * \param[in] exec command to execute
rpm-build 3ee90c
 * \param[in] args arguments to the command, NULL terminated
rpm-build 3ee90c
 *
rpm-build 3ee90c
 * \return a svc_action_t object, used to pass to the execute function
rpm-build 3ee90c
 * (services_action_sync() or services_action_async()) and is
rpm-build 3ee90c
 * provided to the callback.
rpm-build 3ee90c
 */
rpm-build 3ee90c
    svc_action_t *services_action_create_generic(const char *exec, const char *args[]);
rpm-build 3ee90c
rpm-build 3ee90c
    void services_action_cleanup(svc_action_t * op);
rpm-build 3ee90c
    void services_action_free(svc_action_t * op);
rpm-build 3ee90c
    int services_action_user(svc_action_t *op, const char *user);
rpm-build 3ee90c
rpm-build 3ee90c
    gboolean services_action_sync(svc_action_t * op);
rpm-build 3ee90c
rpm-build 3ee90c
/**
rpm-build 3ee90c
 * Run an action asynchronously.
rpm-build 3ee90c
 *
rpm-build 3ee90c
 * \param[in] op services action data
rpm-build 3ee90c
 * \param[in] action_callback callback for when the action completes
rpm-build 3ee90c
 * \param[in] action_fork_callback callback for when action forked successfully
rpm-build 3ee90c
 *
rpm-build 3ee90c
 * \retval TRUE succesfully started execution
rpm-build 3ee90c
 * \retval FALSE failed to start execution, no callback will be received
rpm-build 3ee90c
 */
rpm-build 3ee90c
    gboolean services_action_async_fork_notify(svc_action_t * op,
rpm-build 3ee90c
        void (*action_callback) (svc_action_t *),
rpm-build 3ee90c
        void (*action_fork_callback) (svc_action_t *));
rpm-build 3ee90c
rpm-build 3ee90c
    gboolean services_action_async(svc_action_t * op,
rpm-build 3ee90c
                                   void (*action_callback) (svc_action_t *));
rpm-build 3ee90c
rpm-build 3ee90c
gboolean services_action_cancel(const char *name, const char *action,
rpm-build 3ee90c
                                guint interval_ms);
rpm-build 3ee90c
rpm-build 3ee90c
/* functions for alert agents */
rpm-build 3ee90c
svc_action_t *services_alert_create(const char *id, const char *exec,
rpm-build 3ee90c
                                   int timeout, GHashTable *params,
rpm-build 3ee90c
                                   int sequence, void *cb_data);
rpm-build 3ee90c
gboolean services_alert_async(svc_action_t *action,
rpm-build 3ee90c
                              void (*cb)(svc_action_t *op));
rpm-build 3ee90c
rpm-build 3ee90c
    static inline const char *services_lrm_status_str(enum op_status status) {
rpm-build 3ee90c
        switch (status) {
rpm-build 3ee90c
            case PCMK_LRM_OP_PENDING:
rpm-build 3ee90c
                return "pending";
rpm-build 3ee90c
                case PCMK_LRM_OP_DONE:return "complete";
rpm-build 3ee90c
                case PCMK_LRM_OP_CANCELLED:return "Cancelled";
rpm-build 3ee90c
                case PCMK_LRM_OP_TIMEOUT:return "Timed Out";
rpm-build 3ee90c
                case PCMK_LRM_OP_NOTSUPPORTED:return "NOT SUPPORTED";
rpm-build 3ee90c
                case PCMK_LRM_OP_ERROR:return "Error";
rpm-build 3ee90c
                case PCMK_LRM_OP_NOT_INSTALLED:return "Not installed";
rpm-build 3ee90c
                case PCMK_LRM_OP_NOT_CONNECTED:return "No executor connection";
rpm-build 3ee90c
                case PCMK_LRM_OP_INVALID:return "Cannot execute now";
rpm-build 3ee90c
                default:return "UNKNOWN!";
rpm-build 3ee90c
        }
rpm-build 3ee90c
    }
rpm-build 3ee90c
rpm-build 3ee90c
    static inline const char *services_ocf_exitcode_str(enum ocf_exitcode code) {
rpm-build 3ee90c
        switch (code) {
rpm-build 3ee90c
            case PCMK_OCF_OK:
rpm-build 3ee90c
                return "ok";
rpm-build 3ee90c
            case PCMK_OCF_UNKNOWN_ERROR:
rpm-build 3ee90c
                return "error";
rpm-build 3ee90c
            case PCMK_OCF_INVALID_PARAM:
rpm-build 3ee90c
                return "invalid parameter";
rpm-build 3ee90c
            case PCMK_OCF_UNIMPLEMENT_FEATURE:
rpm-build 3ee90c
                return "unimplemented feature";
rpm-build 3ee90c
            case PCMK_OCF_INSUFFICIENT_PRIV:
rpm-build 3ee90c
                return "insufficient privileges";
rpm-build 3ee90c
            case PCMK_OCF_NOT_INSTALLED:
rpm-build 3ee90c
                return "not installed";
rpm-build 3ee90c
            case PCMK_OCF_NOT_CONFIGURED:
rpm-build 3ee90c
                return "not configured";
rpm-build 3ee90c
            case PCMK_OCF_NOT_RUNNING:
rpm-build 3ee90c
                return "not running";
rpm-build 3ee90c
            case PCMK_OCF_RUNNING_MASTER:
rpm-build 3ee90c
                return "master";
rpm-build 3ee90c
            case PCMK_OCF_FAILED_MASTER:
rpm-build 3ee90c
                return "master (failed)";
rpm-build 3ee90c
            case PCMK_OCF_SIGNAL:
rpm-build 3ee90c
                return "OCF_SIGNAL";
rpm-build 3ee90c
            case PCMK_OCF_NOT_SUPPORTED:
rpm-build 3ee90c
                return "OCF_NOT_SUPPORTED";
rpm-build 3ee90c
            case PCMK_OCF_PENDING:
rpm-build 3ee90c
                return "OCF_PENDING";
rpm-build 3ee90c
            case PCMK_OCF_CANCELLED:
rpm-build 3ee90c
                return "OCF_CANCELLED";
rpm-build 3ee90c
            case PCMK_OCF_TIMEOUT:
rpm-build 3ee90c
                return "OCF_TIMEOUT";
rpm-build 3ee90c
            case PCMK_OCF_OTHER_ERROR:
rpm-build 3ee90c
                return "OCF_OTHER_ERROR";
rpm-build 3ee90c
            case PCMK_OCF_DEGRADED:
rpm-build 3ee90c
                return "OCF_DEGRADED";
rpm-build 3ee90c
            case PCMK_OCF_DEGRADED_MASTER:
rpm-build 3ee90c
                return "OCF_DEGRADED_MASTER";
rpm-build 3ee90c
            default:
rpm-build 3ee90c
                return "unknown";
rpm-build 3ee90c
        }
rpm-build 3ee90c
    }
rpm-build 3ee90c
rpm-build 3ee90c
    /**
rpm-build 3ee90c
     * \brief Get OCF equivalent of LSB exit code
rpm-build 3ee90c
     *
rpm-build 3ee90c
     * \param[in] action        LSB action that produced exit code
rpm-build 3ee90c
     * \param[in] lsb_exitcode  Exit code of LSB action
rpm-build 3ee90c
     *
rpm-build 3ee90c
     * \return PCMK_OCF_* constant that corresponds to LSB exit code
rpm-build 3ee90c
     */
rpm-build 3ee90c
    static inline enum ocf_exitcode
rpm-build 3ee90c
    services_get_ocf_exitcode(const char *action, int lsb_exitcode)
rpm-build 3ee90c
    {
rpm-build 3ee90c
        /* For non-status actions, LSB and OCF share error code meaning <= 7 */
rpm-build 3ee90c
        if (action && strcmp(action, "status") && strcmp(action, "monitor")) {
rpm-build 3ee90c
            if ((lsb_exitcode < 0) || (lsb_exitcode > PCMK_LSB_NOT_RUNNING)) {
rpm-build 3ee90c
                return PCMK_OCF_UNKNOWN_ERROR;
rpm-build 3ee90c
            }
rpm-build 3ee90c
            return (enum ocf_exitcode)lsb_exitcode;
rpm-build 3ee90c
        }
rpm-build 3ee90c
rpm-build 3ee90c
        /* status has different return codes */
rpm-build 3ee90c
        switch (lsb_exitcode) {
rpm-build 3ee90c
            case PCMK_LSB_STATUS_OK:
rpm-build 3ee90c
                return PCMK_OCF_OK;
rpm-build 3ee90c
            case PCMK_LSB_STATUS_NOT_INSTALLED:
rpm-build 3ee90c
                return PCMK_OCF_NOT_INSTALLED;
rpm-build 3ee90c
            case PCMK_LSB_STATUS_INSUFFICIENT_PRIV:
rpm-build 3ee90c
                return PCMK_OCF_INSUFFICIENT_PRIV;
rpm-build 3ee90c
            case PCMK_LSB_STATUS_VAR_PID:
rpm-build 3ee90c
            case PCMK_LSB_STATUS_VAR_LOCK:
rpm-build 3ee90c
            case PCMK_LSB_STATUS_NOT_RUNNING:
rpm-build 3ee90c
                return PCMK_OCF_NOT_RUNNING;
rpm-build 3ee90c
        }
rpm-build 3ee90c
        return PCMK_OCF_UNKNOWN_ERROR;
rpm-build 3ee90c
    }
rpm-build 3ee90c
rpm-build 3ee90c
#  ifdef __cplusplus
rpm-build 3ee90c
}
rpm-build 3ee90c
#  endif
rpm-build 3ee90c
rpm-build 3ee90c
#endif                          /* __PCMK_SERVICES__ */