root/crmd/crmd_utils.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 #ifndef CRMD_UTILS__H
  19 #  define CRMD_UTILS__H
  20 
  21 #  include <crm/crm.h>
  22 #  include <crm/transition.h>
  23 #  include <crm/common/xml.h>
  24 #  include <crm/cib/internal.h> /* For CIB_OP_MODIFY */
  25 #  include "crmd_alerts.h"
  26 
  27 #  define CLIENT_EXIT_WAIT 30
  28 #  define FAKE_TE_ID    "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
  29 
  30 
  31 #  define fsa_cib_delete(section, data, options, call_id, user_name)    \
  32         if(fsa_cib_conn != NULL) {                                      \
  33             call_id = cib_internal_op(                                  \
  34                 fsa_cib_conn, CIB_OP_DELETE, NULL, section, data,       \
  35                 NULL, options, user_name);                              \
  36                                                                         \
  37         } else {                                                        \
  38                 crm_err("No CIB connection available");                 \
  39         }
  40 
  41 #  define fsa_cib_update(section, data, options, call_id, user_name)    \
  42         if(fsa_cib_conn != NULL) {                                      \
  43             call_id = cib_internal_op(                                  \
  44                 fsa_cib_conn, CIB_OP_MODIFY, NULL, section, data,       \
  45                 NULL, options, user_name);                              \
  46                                                                         \
  47         } else {                                                        \
  48                 crm_err("No CIB connection available");                 \
  49         }
  50 
  51 #  define fsa_cib_anon_update(section, data, options)                   \
  52         if(fsa_cib_conn != NULL) {                                      \
  53             fsa_cib_conn->cmds->modify(                                 \
  54                 fsa_cib_conn, section, data, options);                  \
  55                                                                         \
  56         } else {                                                        \
  57                 crm_err("No CIB connection available");                 \
  58         }
  59 
  60 extern gboolean fsa_has_quorum;
  61 extern int last_peer_update;
  62 extern int last_resource_update;
  63 
  64 enum node_update_flags {
  65     node_update_none = 0x0000,
  66     node_update_quick = 0x0001,
  67     node_update_cluster = 0x0010,
  68     node_update_peer = 0x0020,
  69     node_update_join = 0x0040,
  70     node_update_expected = 0x0100,
  71     node_update_all = node_update_cluster|node_update_peer|node_update_join|node_update_expected,
  72 };
  73 
  74 gboolean crm_timer_stop(fsa_timer_t * timer);
  75 gboolean crm_timer_start(fsa_timer_t * timer);
  76 gboolean crm_timer_popped(gpointer data);
  77 gboolean is_timer_started(fsa_timer_t * timer);
  78 
  79 int crmd_exit(int rc);
  80 int crmd_fast_exit(int rc);
  81 gboolean stop_subsystem(struct crm_subsystem_s *centry, gboolean force_quit);
  82 gboolean start_subsystem(struct crm_subsystem_s *centry);
  83 
  84 void fsa_dump_actions(long long action, const char *text);
  85 void fsa_dump_inputs(int log_level, const char *text, long long input_register);
  86 
  87 gboolean update_dc(xmlNode * msg);
  88 void crm_update_peer_join(const char *source, crm_node_t * node, enum crm_join_phase phase);
  89 xmlNode *create_node_state_update(crm_node_t *node, int flags,
  90                                   xmlNode *parent, const char *source);
  91 void populate_cib_nodes(enum node_update_flags flags, const char *source);
  92 void crm_update_quorum(gboolean quorum, gboolean force_update);
  93 void erase_status_tag(const char *uname, const char *tag, int options);
  94 void update_attrd(const char *host, const char *name, const char *value, const char *user_name, gboolean is_remote_node);
  95 void update_attrd_remote_node_removed(const char *host, const char *user_name);
  96 void update_attrd_clear_failures(const char *host, const char *rsc,
  97                                  const char *op, const char *interval,
  98                                  gboolean is_remote_node);
  99 
 100 int crmd_join_phase_count(enum crm_join_phase phase);
 101 void crmd_join_phase_log(int level);
 102 
 103 const char *get_timer_desc(fsa_timer_t * timer);
 104 void st_fail_count_reset(const char * target);
 105 void st_fail_count_increment(const char *target);
 106 void abort_for_stonith_failure(enum transition_action abort_action,
 107                                const char *target, xmlNode *reason);
 108 void crmd_peer_down(crm_node_t *peer, bool full);
 109 unsigned int cib_op_timeout(void);
 110 
 111 /* Convenience macro for registering a CIB callback
 112  * (assumes that data can be freed with free())
 113  */
 114 #  define fsa_register_cib_callback(id, flag, data, fn) do {            \
 115     CRM_ASSERT(fsa_cib_conn);                                           \
 116     fsa_cib_conn->cmds->register_callback_full(                         \
 117         fsa_cib_conn, id, cib_op_timeout(),                             \
 118             flag, data, #fn, fn, free);                                 \
 119     } while(0)
 120 
 121 #  define start_transition(state) do {                                  \
 122         switch(state) {                                                 \
 123             case S_TRANSITION_ENGINE:                                   \
 124                 register_fsa_action(A_TE_CANCEL);                       \
 125                 break;                                                  \
 126             case S_POLICY_ENGINE:                                       \
 127             case S_IDLE:                                                \
 128                 register_fsa_input(C_FSA_INTERNAL, I_PE_CALC, NULL);    \
 129                 break;                                                  \
 130             default:                                                    \
 131                 crm_debug("NOT starting a new transition in state %s",  \
 132                           fsa_state2string(fsa_state));                 \
 133                 break;                                                  \
 134         }                                                               \
 135     } while(0)
 136 
 137 #endif

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