root/crmd/crmd_lrm.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * Copyright (C) 2004 Andrew Beekhof <andrew@beekhof.net>
   3  *
   4  * This program is free software; you can redistribute it and/or
   5  * modify it under the terms of the GNU Lesser General Public
   6  * License as published by the Free Software Foundation; either
   7  * version 2 of the License, or (at your option) any later version.
   8  *
   9  * This software is distributed in the hope that it will be useful,
  10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12  * General Public License for more details.
  13  *
  14  * You should have received a copy of the GNU Lesser General Public
  15  * License along with this library; if not, write to the Free Software
  16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  17  */
  18 
  19 #include <crmd_messages.h>
  20 #include <crmd_metadata.h>
  21 
  22 extern gboolean verify_stopped(enum crmd_fsa_state cur_state, int log_level);
  23 extern void lrm_clear_last_failure(const char *rsc_id, const char *node_name,
  24                                    const char *operation, int interval);
  25 void lrm_op_callback(lrmd_event_data_t * op);
  26 lrmd_t *crmd_local_lrmd_conn(void);
  27 
  28 typedef struct resource_history_s {
  29     char *id;
  30     uint32_t last_callid;
  31     lrmd_rsc_info_t rsc;
  32     lrmd_event_data_t *last;
  33     lrmd_event_data_t *failed;
  34     GList *recurring_op_list;
  35 
  36     /* Resources must be stopped using the same
  37      * parameters they were started with.  This hashtable
  38      * holds the parameters that should be used for the next stop
  39      * cmd on this resource. */
  40     GHashTable *stop_params;
  41 } rsc_history_t;
  42 
  43 void history_free(gpointer data);
  44 
  45 /* TODO - Replace this with lrmd_event_data_t */
  46 struct recurring_op_s {
  47     int call_id;
  48     int interval;
  49     gboolean remove;
  50     gboolean cancelled;
  51     unsigned int start_time;
  52     char *rsc_id;
  53     char *op_type;
  54     char *op_key;
  55     char *user_data;
  56     GHashTable *params;
  57 };
  58 
  59 typedef struct lrm_state_s {
  60     const char *node_name;
  61     /* reserved for lrm_state.c usage only */
  62     void *conn;
  63     /* reserved for remote_lrmd_ra.c usage only */
  64     void *remote_ra_data;
  65 
  66     GHashTable *resource_history;
  67     GHashTable *pending_ops;
  68     GHashTable *deletion_ops;
  69     GHashTable *rsc_info_cache;
  70     GHashTable *metadata_cache; // key = class[:provider]:agent, value = ra_metadata_s
  71 
  72     int num_lrm_register_fails;
  73 } lrm_state_t;
  74 
  75 struct pending_deletion_op_s {
  76     char *rsc;
  77     ha_msg_input_t *input;
  78 };
  79 
  80 /*!
  81  * \brief Is this the local ipc connection to the lrmd
  82  */
  83 gboolean
  84 lrm_state_is_local(lrm_state_t *lrm_state);
  85 
  86 /*!
  87  * \brief Clear all state information from a single state entry.
  88  * \note It sometimes useful to save metadata cache when it won't go stale.
  89  * \note This does not close the lrmd connection
  90  */
  91 void lrm_state_reset_tables(lrm_state_t * lrm_state, gboolean reset_metadata);
  92 GList *lrm_state_get_list(void);
  93 
  94 /*!
  95  * \brief Initiate internal state tables
  96  */
  97 gboolean lrm_state_init_local(void);
  98 
  99 /*!
 100  * \brief Destroy all state entries and internal state tables
 101  */
 102 void lrm_state_destroy_all(void);
 103 
 104 /*!
 105  * \brief Create lrmd connection entry.
 106  */
 107 lrm_state_t *lrm_state_create(const char *node_name);
 108 
 109 /*!
 110  * \brief Destroy lrmd connection keyed of node name
 111  */
 112 void lrm_state_destroy(const char *node_name);
 113 
 114 /*!
 115  * \brief Find lrm_state data by node name
 116  */
 117 lrm_state_t *lrm_state_find(const char *node_name);
 118 
 119 /*!
 120  * \brief Either find or create a new entry
 121  */
 122 lrm_state_t *lrm_state_find_or_create(const char *node_name);
 123 
 124 /*!
 125  * The functions below are wrappers for the lrmd api calls the crmd
 126  * uses.  These wrapper functions allow us to treat the crmd's remote
 127  * lrmd connection resources the same as regular resources.  Internally
 128  * Regular resources go to the lrmd, and remote connection resources are
 129  * handled locally in the crmd.
 130  */
 131 void lrm_state_disconnect_only(lrm_state_t * lrm_state);
 132 void lrm_state_disconnect(lrm_state_t * lrm_state);
 133 int lrm_state_ipc_connect(lrm_state_t * lrm_state);
 134 int lrm_state_remote_connect_async(lrm_state_t * lrm_state, const char *server, int port,
 135                                    int timeout);
 136 int lrm_state_is_connected(lrm_state_t * lrm_state);
 137 int lrm_state_poke_connection(lrm_state_t * lrm_state);
 138 
 139 int lrm_state_get_metadata(lrm_state_t * lrm_state,
 140                            const char *class,
 141                            const char *provider,
 142                            const char *agent, char **output, enum lrmd_call_options options);
 143 int lrm_state_cancel(lrm_state_t * lrm_state, const char *rsc_id, const char *action, int interval);
 144 int lrm_state_exec(lrm_state_t * lrm_state, const char *rsc_id, const char *action, const char *userdata, int interval, /* ms */
 145                    int timeout, /* ms */
 146                    int start_delay,     /* ms */
 147                    lrmd_key_value_t * params);
 148 lrmd_rsc_info_t *lrm_state_get_rsc_info(lrm_state_t * lrm_state,
 149                                         const char *rsc_id, enum lrmd_call_options options);
 150 int lrm_state_register_rsc(lrm_state_t * lrm_state,
 151                            const char *rsc_id,
 152                            const char *class,
 153                            const char *provider, const char *agent, enum lrmd_call_options options);
 154 int lrm_state_unregister_rsc(lrm_state_t * lrm_state,
 155                              const char *rsc_id, enum lrmd_call_options options);
 156 
 157 /*! These functions are used to manage the remote lrmd connection resources */
 158 void remote_lrm_op_callback(lrmd_event_data_t * op);
 159 gboolean is_remote_lrmd_ra(const char *agent, const char *provider, const char *id);
 160 lrmd_rsc_info_t *remote_ra_get_rsc_info(lrm_state_t * lrm_state, const char *rsc_id);
 161 int remote_ra_cancel(lrm_state_t * lrm_state, const char *rsc_id, const char *action, int interval);
 162 int remote_ra_exec(lrm_state_t * lrm_state, const char *rsc_id, const char *action, const char *userdata, int interval, /* ms */
 163                    int timeout, /* ms */
 164                    int start_delay,     /* ms */
 165                    lrmd_key_value_t * params);
 166 void remote_ra_cleanup(lrm_state_t * lrm_state);
 167 void remote_ra_fail(const char *node_name);
 168 void remote_ra_process_pseudo(xmlNode *xml);
 169 gboolean remote_ra_is_in_maintenance(lrm_state_t * lrm_state);
 170 void remote_ra_process_maintenance_nodes(xmlNode *xml);
 171 
 172 gboolean process_lrm_event(lrm_state_t * lrm_state, lrmd_event_data_t * op, struct recurring_op_s *pending);

/* [previous][next][first][last][top][bottom][index][help] */