dhodovsk / source-git / pacemaker

Forked from source-git/pacemaker 3 years ago
Clone

Blame daemons/fenced/pacemaker-fenced.h

rpm-build 3ee90c
/*
rpm-build 3ee90c
 * Copyright 2009-2019 the Pacemaker project contributors
rpm-build 3ee90c
 *
rpm-build 3ee90c
 * This source code is licensed under the GNU General Public License version 2
rpm-build 3ee90c
 * or later (GPLv2+) WITHOUT ANY WARRANTY.
rpm-build 3ee90c
 */
rpm-build 3ee90c
rpm-build 3ee90c
#include <crm/common/mainloop.h>
rpm-build 3ee90c
rpm-build 3ee90c
/*!
rpm-build 3ee90c
 * \internal
rpm-build 3ee90c
 * \brief Check to see if target was fenced in the last few seconds.
rpm-build 3ee90c
 * \param tolerance, The number of seconds to look back in time
rpm-build 3ee90c
 * \param target, The node to search for
rpm-build 3ee90c
 * \param action, The action we want to match.
rpm-build 3ee90c
 *
rpm-build 3ee90c
 * \retval FALSE, not match
rpm-build 3ee90c
 * \retval TRUE, fencing operation took place in the last 'tolerance' number of seconds.
rpm-build 3ee90c
 */
rpm-build 3ee90c
gboolean stonith_check_fence_tolerance(int tolerance, const char *target, const char *action);
rpm-build 3ee90c
rpm-build 3ee90c
enum st_device_flags
rpm-build 3ee90c
{
rpm-build 3ee90c
    st_device_supports_list   = 0x0001,
rpm-build 3ee90c
    st_device_supports_status = 0x0002,
rpm-build 3ee90c
    st_device_supports_reboot = 0x0004,
rpm-build 3ee90c
};
rpm-build 3ee90c
rpm-build 3ee90c
typedef struct stonith_device_s {
rpm-build 3ee90c
    char *id;
rpm-build 3ee90c
    char *agent;
rpm-build 3ee90c
    char *namespace;
rpm-build 3ee90c
rpm-build 3ee90c
    /*! list of actions that must execute on the target node. Used for unfencing */
rpm-build 3ee90c
    char *on_target_actions;
rpm-build 3ee90c
    GListPtr targets;
rpm-build 3ee90c
    time_t targets_age;
rpm-build 3ee90c
    gboolean has_attr_map;
rpm-build 3ee90c
    /* should nodeid parameter for victim be included in agent arguments */
rpm-build 3ee90c
    gboolean include_nodeid;
rpm-build 3ee90c
    /* whether the cluster should automatically unfence nodes with the device */
rpm-build 3ee90c
    gboolean automatic_unfencing;
rpm-build 3ee90c
    guint priority;
rpm-build 3ee90c
rpm-build 3ee90c
    enum st_device_flags flags;
rpm-build 3ee90c
rpm-build 3ee90c
    GHashTable *params;
rpm-build 3ee90c
    GHashTable *aliases;
rpm-build 3ee90c
    GList *pending_ops;
rpm-build 3ee90c
    crm_trigger_t *work;
rpm-build 3ee90c
    xmlNode *agent_metadata;
rpm-build 3ee90c
rpm-build 3ee90c
    /*! A verified device is one that has contacted the
rpm-build 3ee90c
     * agent successfully to perform a monitor operation */
rpm-build 3ee90c
    gboolean verified;
rpm-build 3ee90c
rpm-build 3ee90c
    gboolean cib_registered;
rpm-build 3ee90c
    gboolean api_registered;
rpm-build 3ee90c
} stonith_device_t;
rpm-build 3ee90c
rpm-build 3ee90c
/* These values are used to index certain arrays by "phase". Usually an
rpm-build 3ee90c
 * operation has only one "phase", so phase is always zero. However, some
rpm-build 3ee90c
 * reboots are remapped to "off" then "on", in which case "reboot" will be
rpm-build 3ee90c
 * phase 0, "off" will be phase 1 and "on" will be phase 2.
rpm-build 3ee90c
 */
rpm-build 3ee90c
enum st_remap_phase {
rpm-build 3ee90c
    st_phase_requested = 0,
rpm-build 3ee90c
    st_phase_off = 1,
rpm-build 3ee90c
    st_phase_on = 2,
rpm-build 3ee90c
    st_phase_max = 3
rpm-build 3ee90c
};
rpm-build 3ee90c
rpm-build 3ee90c
typedef struct remote_fencing_op_s {
rpm-build 3ee90c
    /* The unique id associated with this operation */
rpm-build 3ee90c
    char *id;
rpm-build 3ee90c
    /*! The node this operation will fence */
rpm-build 3ee90c
    char *target;
rpm-build 3ee90c
    /*! The fencing action to perform on the target. (reboot, on, off) */
rpm-build 3ee90c
    char *action;
rpm-build 3ee90c
rpm-build 3ee90c
    /*! When was the fencing action recorded (seconds since epoch) */
rpm-build 3ee90c
    time_t created;
rpm-build 3ee90c
rpm-build 3ee90c
    /*! Marks if the final notifications have been sent to local stonith clients. */
rpm-build 3ee90c
    gboolean notify_sent;
rpm-build 3ee90c
    /*! The number of query replies received */
rpm-build 3ee90c
    guint replies;
rpm-build 3ee90c
    /*! The number of query replies expected */
rpm-build 3ee90c
    guint replies_expected;
rpm-build 3ee90c
    /*! Does this node own control of this operation */
rpm-build 3ee90c
    gboolean owner;
rpm-build 3ee90c
    /*! After query is complete, This the high level timer that expires the entire operation */
rpm-build 3ee90c
    guint op_timer_total;
rpm-build 3ee90c
    /*! This timer expires the current fencing request. Many fencing
rpm-build 3ee90c
     * requests may exist in a single operation */
rpm-build 3ee90c
    guint op_timer_one;
rpm-build 3ee90c
    /*! This timer expires the query request sent out to determine
rpm-build 3ee90c
     * what nodes are contain what devices, and who those devices can fence */
rpm-build 3ee90c
    guint query_timer;
rpm-build 3ee90c
    /*! This is the default timeout to use for each fencing device if no
rpm-build 3ee90c
     * custom timeout is received in the query. */
rpm-build 3ee90c
    gint base_timeout;
rpm-build 3ee90c
    /*! This is the calculated total timeout an operation can take before
rpm-build 3ee90c
     * expiring. This is calculated by adding together all the timeout
rpm-build 3ee90c
     * values associated with the devices this fencing operation may call */
rpm-build 3ee90c
    gint total_timeout;
rpm-build 3ee90c
rpm-build 3ee90c
    /*! Delegate is the node being asked to perform a fencing action
rpm-build 3ee90c
     * on behalf of the node that owns the remote operation. Some operations
rpm-build 3ee90c
     * will involve multiple delegates. This value represents the final delegate
rpm-build 3ee90c
     * that is used. */
rpm-build 3ee90c
    char *delegate;
rpm-build 3ee90c
    /*! The point at which the remote operation completed */
rpm-build 3ee90c
    time_t completed;
rpm-build 3ee90c
    /*! The stonith_call_options associated with this remote operation */
rpm-build 3ee90c
    long long call_options;
rpm-build 3ee90c
rpm-build 3ee90c
    /*! The current state of the remote operation. This indicates
rpm-build 3ee90c
     * what stage the op is in, query, exec, done, duplicate, failed. */
rpm-build 3ee90c
    enum op_state state;
rpm-build 3ee90c
    /*! The node that owns the remote operation */
rpm-build 3ee90c
    char *originator;
rpm-build 3ee90c
    /*! The local client id that initiated the fencing request */
rpm-build 3ee90c
    char *client_id;
rpm-build 3ee90c
    /*! The client's call_id that initiated the fencing request */
rpm-build 3ee90c
    int client_callid;
rpm-build 3ee90c
    /*! The name of client that initiated the fencing request */
rpm-build 3ee90c
    char *client_name;
rpm-build 3ee90c
    /*! List of the received query results for all the nodes in the cpg group */
rpm-build 3ee90c
    GListPtr query_results;
rpm-build 3ee90c
    /*! The original request that initiated the remote stonith operation */
rpm-build 3ee90c
    xmlNode *request;
rpm-build 3ee90c
rpm-build 3ee90c
    /*! The current topology level being executed */
rpm-build 3ee90c
    guint level;
rpm-build 3ee90c
    /*! The current operation phase being executed */
rpm-build 3ee90c
    enum st_remap_phase phase;
rpm-build 3ee90c
rpm-build 3ee90c
    /*! Devices with automatic unfencing (always run if "on" requested, never if remapped) */
rpm-build 3ee90c
    GListPtr automatic_list;
rpm-build 3ee90c
    /*! List of all devices at the currently executing topology level */
rpm-build 3ee90c
    GListPtr devices_list;
rpm-build 3ee90c
    /*! Current entry in the topology device list */
rpm-build 3ee90c
    GListPtr devices;
rpm-build 3ee90c
rpm-build 3ee90c
    /*! List of duplicate operations attached to this operation. Once this operation
rpm-build 3ee90c
     * completes, the duplicate operations will be closed out as well. */
rpm-build 3ee90c
    GListPtr duplicates;
rpm-build 3ee90c
rpm-build 3ee90c
} remote_fencing_op_t;
rpm-build 3ee90c
rpm-build 3ee90c
/*!
rpm-build 3ee90c
 * \internal
rpm-build 3ee90c
 * \brief Broadcast the result of an operation to the peers.
rpm-build 3ee90c
 * \param op, Operation whose result should be broadcast
rpm-build 3ee90c
 * \param rc, Result of the operation
rpm-build 3ee90c
 */
rpm-build 3ee90c
void stonith_bcast_result_to_peers(remote_fencing_op_t * op, int rc);
rpm-build 3ee90c
rpm-build 3ee90c
enum st_callback_flags {
rpm-build 3ee90c
    st_callback_unknown               = 0x0000,
rpm-build 3ee90c
    st_callback_notify_fence          = 0x0001,
rpm-build 3ee90c
    st_callback_device_add            = 0x0004,
rpm-build 3ee90c
    st_callback_device_del            = 0x0010,
rpm-build 3ee90c
    st_callback_notify_history        = 0x0020,
rpm-build 3ee90c
    st_callback_notify_history_synced = 0x0040
rpm-build 3ee90c
};
rpm-build 3ee90c
rpm-build 3ee90c
/*
rpm-build 3ee90c
 * Complex fencing requirements are specified via fencing topologies.
rpm-build 3ee90c
 * A topology consists of levels; each level is a list of fencing devices.
rpm-build 3ee90c
 * Topologies are stored in a hash table by node name. When a node needs to be
rpm-build 3ee90c
 * fenced, if it has an entry in the topology table, the levels are tried
rpm-build 3ee90c
 * sequentially, and the devices in each level are tried sequentially.
rpm-build 3ee90c
 * Fencing is considered successful as soon as any level succeeds;
rpm-build 3ee90c
 * a level is considered successful if all its devices succeed.
rpm-build 3ee90c
 * Essentially, all devices at a given level are "and-ed" and the
rpm-build 3ee90c
 * levels are "or-ed".
rpm-build 3ee90c
 *
rpm-build 3ee90c
 * This structure is used for the topology table entries.
rpm-build 3ee90c
 * Topology levels start from 1, so levels[0] is unused and always NULL.
rpm-build 3ee90c
 */
rpm-build 3ee90c
typedef struct stonith_topology_s {
rpm-build 3ee90c
    int kind;
rpm-build 3ee90c
rpm-build 3ee90c
    /*! Node name regex or attribute name=value for which topology applies */
rpm-build 3ee90c
    char *target;
rpm-build 3ee90c
    char *target_value;
rpm-build 3ee90c
    char *target_pattern;
rpm-build 3ee90c
    char *target_attribute;
rpm-build 3ee90c
rpm-build 3ee90c
    /*! Names of fencing devices at each topology level */
rpm-build 3ee90c
    GListPtr levels[ST_LEVEL_MAX];
rpm-build 3ee90c
rpm-build 3ee90c
} stonith_topology_t;
rpm-build 3ee90c
rpm-build 3ee90c
void init_device_list(void);
rpm-build 3ee90c
void free_device_list(void);
rpm-build 3ee90c
void init_topology_list(void);
rpm-build 3ee90c
void free_topology_list(void);
rpm-build 3ee90c
void free_stonith_remote_op_list(void);
rpm-build 3ee90c
void init_stonith_remote_op_hash_table(GHashTable **table);
rpm-build 3ee90c
void free_metadata_cache(void);
rpm-build 3ee90c
rpm-build 3ee90c
long long get_stonith_flag(const char *name);
rpm-build 3ee90c
rpm-build 3ee90c
void stonith_command(crm_client_t * client, uint32_t id, uint32_t flags,
rpm-build 3ee90c
                            xmlNode * op_request, const char *remote_peer);
rpm-build 3ee90c
rpm-build 3ee90c
int stonith_device_register(xmlNode * msg, const char **desc, gboolean from_cib);
rpm-build 3ee90c
rpm-build 3ee90c
int stonith_device_remove(const char *id, gboolean from_cib);
rpm-build 3ee90c
rpm-build 3ee90c
char *stonith_level_key(xmlNode * msg, int mode);
rpm-build 3ee90c
int stonith_level_kind(xmlNode * msg);
rpm-build 3ee90c
int stonith_level_register(xmlNode * msg, char **desc);
rpm-build 3ee90c
rpm-build 3ee90c
int stonith_level_remove(xmlNode * msg, char **desc);
rpm-build 3ee90c
rpm-build 3ee90c
stonith_topology_t *find_topology_for_host(const char *host);
rpm-build 3ee90c
rpm-build 3ee90c
void do_local_reply(xmlNode * notify_src, const char *client_id, gboolean sync_reply,
rpm-build 3ee90c
                           gboolean from_peer);
rpm-build 3ee90c
rpm-build 3ee90c
xmlNode *stonith_construct_reply(xmlNode * request, const char *output, xmlNode * data,
rpm-build 3ee90c
                                        int rc);
rpm-build 3ee90c
rpm-build 3ee90c
void
rpm-build 3ee90c
 do_stonith_async_timeout_update(const char *client, const char *call_id, int timeout);
rpm-build 3ee90c
rpm-build 3ee90c
void do_stonith_notify(int options, const char *type, int result, xmlNode * data);
rpm-build 3ee90c
void do_stonith_notify_device(int options, const char *op, int rc, const char *desc);
rpm-build 3ee90c
void do_stonith_notify_level(int options, const char *op, int rc, const char *desc);
rpm-build 3ee90c
rpm-build 3ee90c
remote_fencing_op_t *initiate_remote_stonith_op(crm_client_t * client, xmlNode * request,
rpm-build 3ee90c
                                                       gboolean manual_ack);
rpm-build 3ee90c
rpm-build 3ee90c
int process_remote_stonith_exec(xmlNode * msg);
rpm-build 3ee90c
rpm-build 3ee90c
int process_remote_stonith_query(xmlNode * msg);
rpm-build 3ee90c
rpm-build 3ee90c
void *create_remote_stonith_op(const char *client, xmlNode * request, gboolean peer);
rpm-build 3ee90c
rpm-build 3ee90c
int stonith_fence_history(xmlNode *msg, xmlNode **output,
rpm-build 3ee90c
                          const char *remote_peer, int options);
rpm-build 3ee90c
rpm-build 3ee90c
void stonith_fence_history_trim(void);
rpm-build 3ee90c
rpm-build 3ee90c
bool fencing_peer_active(crm_node_t *peer);
rpm-build 3ee90c
rpm-build 3ee90c
int stonith_manual_ack(xmlNode * msg, remote_fencing_op_t * op);
rpm-build 3ee90c
rpm-build 3ee90c
gboolean string_in_list(GListPtr list, const char *item);
rpm-build 3ee90c
rpm-build 3ee90c
gboolean node_has_attr(const char *node, const char *name, const char *value);
rpm-build 3ee90c
rpm-build 3ee90c
extern char *stonith_our_uname;
rpm-build 3ee90c
extern gboolean stand_alone;
rpm-build 3ee90c
extern GHashTable *device_list;
rpm-build 3ee90c
extern GHashTable *topology;
rpm-build 3ee90c
extern long stonith_watchdog_timeout_ms;
rpm-build 3ee90c
rpm-build 3ee90c
extern GHashTable *stonith_remote_op_list;