root/include/crm/cib.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 /**
  20  * \file
  21  * \brief Cluster Configuration
  22  * \ingroup cib
  23  */
  24 
  25 #ifndef CIB__H
  26 #  define CIB__H
  27 
  28 #  include <crm/common/ipc.h>
  29 #  include <crm/common/xml.h>
  30 
  31 #  define CIB_FEATURE_SET "2.0"
  32 
  33 /* use compare_version() for doing comparisons */
  34 
  35 enum cib_variant {
  36     cib_undefined,
  37     cib_native,
  38     cib_file,
  39     cib_remote,
  40     cib_database,
  41 };
  42 
  43 enum cib_state {
  44     cib_connected_command,
  45     cib_connected_query,
  46     cib_disconnected
  47 };
  48 
  49 enum cib_conn_type {
  50     cib_command,
  51     cib_query,
  52     cib_no_connection,
  53     cib_command_nonblocking,
  54 };
  55 
  56 /* *INDENT-OFF* */
  57 enum cib_call_options {
  58         cib_none            = 0x00000000,
  59         cib_verbose         = 0x00000001,
  60         cib_xpath           = 0x00000002,
  61         cib_multiple        = 0x00000004,
  62         cib_can_create      = 0x00000008,
  63         cib_discard_reply   = 0x00000010,
  64         cib_no_children     = 0x00000020,
  65         cib_xpath_address   = 0x00000040,
  66         cib_mixed_update    = 0x00000080,
  67         cib_scope_local     = 0x00000100,
  68         cib_dryrun          = 0x00000200,
  69         cib_sync_call       = 0x00001000,
  70         cib_no_mtime        = 0x00002000,
  71         cib_zero_copy       = 0x00004000,
  72         cib_inhibit_notify  = 0x00010000,
  73         cib_quorum_override = 0x00100000,
  74         cib_inhibit_bcast   = 0x01000000, /* TODO: Remove */
  75         cib_force_diff      = 0x10000000
  76 };
  77 
  78 #define cib_default_options = cib_none
  79 #define T_CIB_DIFF_NOTIFY       "cib_diff_notify"
  80 
  81 /* *INDENT-ON* */
  82 
  83 typedef struct cib_s cib_t;
  84 
  85 typedef struct cib_api_operations_s {
  86     int (*signon) (cib_t * cib, const char *name, enum cib_conn_type type);
  87     int (*signon_raw) (cib_t * cib, const char *name, enum cib_conn_type type, int *event_fd);
  88     int (*signoff) (cib_t * cib);
  89     int (*free) (cib_t * cib);
  90 
  91     int (*set_op_callback) (cib_t * cib, void (*callback) (const xmlNode * msg, int callid,
  92                                                            int rc, xmlNode * output));
  93 
  94     int (*add_notify_callback) (cib_t * cib, const char *event,
  95                                 void (*callback) (const char *event, xmlNode * msg));
  96 
  97     int (*del_notify_callback) (cib_t * cib, const char *event,
  98                                 void (*callback) (const char *event, xmlNode * msg));
  99 
 100     int (*set_connection_dnotify) (cib_t * cib, void (*dnotify) (gpointer user_data));
 101 
 102     int (*inputfd) (cib_t * cib);
 103 
 104     int (*noop) (cib_t * cib, int call_options);
 105     int (*ping) (cib_t * cib, xmlNode ** output_data, int call_options);
 106 
 107     int (*query) (cib_t * cib, const char *section, xmlNode ** output_data, int call_options);
 108     int (*query_from) (cib_t * cib, const char *host, const char *section,
 109                        xmlNode ** output_data, int call_options);
 110 
 111     int (*is_master) (cib_t * cib);
 112     int (*set_master) (cib_t * cib, int call_options);
 113     int (*set_slave) (cib_t * cib, int call_options);
 114     int (*set_slave_all) (cib_t * cib, int call_options);
 115 
 116     int (*sync) (cib_t * cib, const char *section, int call_options);
 117     int (*sync_from) (cib_t * cib, const char *host, const char *section, int call_options);
 118 
 119     int (*upgrade) (cib_t * cib, int call_options);
 120     int (*bump_epoch) (cib_t * cib, int call_options);
 121 
 122     int (*create) (cib_t * cib, const char *section, xmlNode * data, int call_options);
 123     int (*modify) (cib_t * cib, const char *section, xmlNode * data, int call_options);
 124     int (*update) (cib_t * cib, const char *section, xmlNode * data, int call_options);
 125     int (*replace) (cib_t * cib, const char *section, xmlNode * data, int call_options);
 126     int (*delete) (cib_t * cib, const char *section, xmlNode * data, int call_options);
 127 
 128     int (*erase) (cib_t * cib, xmlNode ** output_data, int call_options);
 129     int (*delete_absolute) (cib_t * cib, const char *section, xmlNode * data, int call_options);
 130 
 131     int (*quit) (cib_t * cib, int call_options);
 132 
 133     int (*register_notification) (cib_t * cib, const char *callback, int enabled);
 134 
 135      gboolean(*register_callback) (cib_t * cib, int call_id, int timeout, gboolean only_success,
 136                                    void *user_data, const char *callback_name,
 137                                    void (*callback) (xmlNode *, int, int, xmlNode *, void *));
 138 
 139     gboolean (*register_callback_full)(cib_t *cib, int call_id, int timeout,
 140                                        gboolean only_success, void *user_data,
 141                                        const char *callback_name,
 142                                        void (*callback)(xmlNode *, int, int,
 143                                                         xmlNode *, void *),
 144                                        void (*free_func)(void *));
 145 
 146 } cib_api_operations_t;
 147 
 148 struct cib_s {
 149     enum cib_state state;
 150     enum cib_conn_type type;
 151     enum cib_variant variant;
 152 
 153     int call_id;
 154     int call_timeout;
 155     void *variant_opaque;
 156     void *delegate_fn;
 157 
 158     GList *notify_list;
 159     void (*op_callback) (const xmlNode * msg, int call_id, int rc, xmlNode * output);
 160 
 161     cib_api_operations_t *cmds;
 162 };
 163 
 164 /* Core functions */
 165 cib_t *cib_new(void);
 166 cib_t *cib_native_new(void);
 167 cib_t *cib_file_new(const char *filename);
 168 cib_t *cib_remote_new(const char *server, const char *user, const char *passwd, int port,
 169                       gboolean encrypted);
 170 
 171 cib_t *cib_new_no_shadow(void);
 172 char *get_shadow_file(const char *name);
 173 cib_t *cib_shadow_new(const char *name);
 174 
 175 void cib_free_callbacks(cib_t *cib);
 176 void cib_delete(cib_t * cib);
 177 
 178 void cib_dump_pending_callbacks(void);
 179 int num_cib_op_callbacks(void);
 180 void remove_cib_op_callback(int call_id, gboolean all_callbacks);
 181 
 182 /* Deprecated */
 183 #  define add_cib_op_callback(cib, id, flag, data, fn) do {             \
 184         cib->cmds->register_callback(cib, id, 120, flag, data, #fn, fn); \
 185     } while(0)
 186 #  include <crm/cib/util.h>
 187 
 188 #  define CIB_LIBRARY "libcib.so.4"
 189 
 190 #endif

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