Page MenuHomeClusterLabs Projects

No OneTemporary

diff --git a/daemons/based/based_common.c b/daemons/based/based_common.c
index 660a2a587b..5835d13310 100644
--- a/daemons/based/based_common.c
+++ b/daemons/based/based_common.c
@@ -1,362 +1,362 @@
/*
* Copyright 2008-2022 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
* This source code is licensed under the GNU General Public License version 2
* or later (GPLv2+) WITHOUT ANY WARRANTY.
*/
#include <crm_internal.h>
#include <sys/param.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <crm/crm.h>
#include <crm/cib.h>
#include <crm/msg_xml.h>
#include <crm/common/ipc.h>
#include <crm/cluster.h>
#include <crm/common/xml.h>
#include <pacemaker-based.h>
gboolean stand_alone = FALSE;
extern int cib_perform_command(xmlNode * request, xmlNode ** reply, xmlNode ** cib_diff,
gboolean privileged);
static xmlNode *
cib_prepare_common(xmlNode * root, const char *section)
{
xmlNode *data = NULL;
/* extract the CIB from the fragment */
if (root == NULL) {
return NULL;
} else if (pcmk__strcase_any_of(crm_element_name(root), XML_TAG_FRAGMENT,
F_CRM_DATA, F_CIB_CALLDATA, NULL)) {
data = first_named_child(root, XML_TAG_CIB);
} else {
data = root;
}
/* grab the section specified for the command */
if (section != NULL && data != NULL && pcmk__str_eq(crm_element_name(data), XML_TAG_CIB, pcmk__str_none)) {
data = pcmk_find_cib_element(data, section);
}
/* crm_log_xml_trace(root, "cib:input"); */
return data;
}
static int
cib_prepare_none(xmlNode * request, xmlNode ** data, const char **section)
{
*data = NULL;
*section = crm_element_value(request, F_CIB_SECTION);
return pcmk_ok;
}
static int
cib_prepare_data(xmlNode * request, xmlNode ** data, const char **section)
{
xmlNode *input_fragment = get_message_xml(request, F_CIB_CALLDATA);
*section = crm_element_value(request, F_CIB_SECTION);
*data = cib_prepare_common(input_fragment, *section);
/* crm_log_xml_debug(*data, "data"); */
return pcmk_ok;
}
static int
cib_prepare_sync(xmlNode * request, xmlNode ** data, const char **section)
{
*data = NULL;
*section = crm_element_value(request, F_CIB_SECTION);
return pcmk_ok;
}
static int
cib_prepare_diff(xmlNode * request, xmlNode ** data, const char **section)
{
xmlNode *input_fragment = NULL;
*data = NULL;
*section = NULL;
if (pcmk__xe_attr_is_true(request, F_CIB_GLOBAL_UPDATE)) {
input_fragment = get_message_xml(request, F_CIB_UPDATE_DIFF);
} else {
input_fragment = get_message_xml(request, F_CIB_CALLDATA);
}
CRM_CHECK(input_fragment != NULL, crm_log_xml_warn(request, "no input"));
*data = cib_prepare_common(input_fragment, NULL);
return pcmk_ok;
}
static int
cib_cleanup_query(int options, xmlNode ** data, xmlNode ** output)
{
CRM_LOG_ASSERT(*data == NULL);
if ((options & cib_no_children)
|| pcmk__str_eq(crm_element_name(*output), "xpath-query", pcmk__str_casei)) {
free_xml(*output);
}
return pcmk_ok;
}
static int
cib_cleanup_data(int options, xmlNode ** data, xmlNode ** output)
{
free_xml(*output);
*data = NULL;
return pcmk_ok;
}
static int
cib_cleanup_output(int options, xmlNode ** data, xmlNode ** output)
{
free_xml(*output);
return pcmk_ok;
}
static int
cib_cleanup_none(int options, xmlNode ** data, xmlNode ** output)
{
CRM_LOG_ASSERT(*data == NULL);
CRM_LOG_ASSERT(*output == NULL);
return pcmk_ok;
}
static cib_operation_t cib_server_ops[] = {
// Booleans are modifies_cib, needs_privileges, needs_quorum
{
NULL, FALSE, FALSE, FALSE,
cib_prepare_none, cib_cleanup_none, cib_process_default
},
{
CIB_OP_QUERY, FALSE, FALSE, FALSE,
cib_prepare_none, cib_cleanup_query, cib_process_query
},
{
CIB_OP_MODIFY, TRUE, TRUE, TRUE,
cib_prepare_data, cib_cleanup_data, cib_process_modify
},
{
CIB_OP_APPLY_DIFF, TRUE, TRUE, TRUE,
cib_prepare_diff, cib_cleanup_data, cib_server_process_diff
},
{
CIB_OP_REPLACE, TRUE, TRUE, TRUE,
cib_prepare_data, cib_cleanup_data, cib_process_replace_svr
},
{
CIB_OP_CREATE, TRUE, TRUE, TRUE,
cib_prepare_data, cib_cleanup_data, cib_process_create
},
{
CIB_OP_DELETE, TRUE, TRUE, TRUE,
cib_prepare_data, cib_cleanup_data, cib_process_delete
},
{
CIB_OP_SYNC, FALSE, TRUE, FALSE,
cib_prepare_sync, cib_cleanup_none, cib_process_sync
},
{
CIB_OP_BUMP, TRUE, TRUE, TRUE,
cib_prepare_none, cib_cleanup_output, cib_process_bump
},
{
CIB_OP_ERASE, TRUE, TRUE, TRUE,
cib_prepare_none, cib_cleanup_output, cib_process_erase
},
{
CRM_OP_NOOP, FALSE, FALSE, FALSE,
cib_prepare_none, cib_cleanup_none, cib_process_default
},
{
CIB_OP_DELETE_ALT, TRUE, TRUE, TRUE,
cib_prepare_data, cib_cleanup_data, cib_process_delete_absolute
},
{
CIB_OP_UPGRADE, TRUE, TRUE, TRUE,
cib_prepare_none, cib_cleanup_output, cib_process_upgrade_server
},
{
PCMK__CIB_REQUEST_SECONDARY, FALSE, TRUE, FALSE,
cib_prepare_none, cib_cleanup_none, cib_process_readwrite
},
{
- CIB_OP_SLAVEALL, FALSE, TRUE, FALSE,
+ PCMK__CIB_REQUEST_ALL_SECONDARY, FALSE, TRUE, FALSE,
cib_prepare_none, cib_cleanup_none, cib_process_readwrite
},
{
CIB_OP_SYNC_ONE, FALSE, TRUE, FALSE,
cib_prepare_sync, cib_cleanup_none, cib_process_sync_one
},
{
CIB_OP_MASTER, TRUE, TRUE, FALSE,
cib_prepare_data, cib_cleanup_data, cib_process_readwrite
},
{
CIB_OP_ISMASTER, FALSE, TRUE, FALSE,
cib_prepare_none, cib_cleanup_none, cib_process_readwrite
},
{
"cib_shutdown_req", FALSE, TRUE, FALSE,
cib_prepare_sync, cib_cleanup_none, cib_process_shutdown_req
},
{
CRM_OP_PING, FALSE, FALSE, FALSE,
cib_prepare_none, cib_cleanup_output, cib_process_ping
},
};
int
cib_get_operation_id(const char *op, int *operation)
{
static GHashTable *operation_hash = NULL;
if (operation_hash == NULL) {
int lpc = 0;
int max_msg_types = PCMK__NELEM(cib_server_ops);
operation_hash = pcmk__strkey_table(NULL, free);
for (lpc = 1; lpc < max_msg_types; lpc++) {
int *value = malloc(sizeof(int));
if(value) {
*value = lpc;
g_hash_table_insert(operation_hash, (gpointer) cib_server_ops[lpc].operation, value);
}
}
}
if (op != NULL) {
int *value = g_hash_table_lookup(operation_hash, op);
if (value) {
*operation = *value;
return pcmk_ok;
}
}
crm_err("Operation %s is not valid", op);
*operation = -1;
return -EINVAL;
}
xmlNode *
cib_msg_copy(xmlNode * msg, gboolean with_data)
{
int lpc = 0;
const char *field = NULL;
const char *value = NULL;
xmlNode *value_struct = NULL;
static const char *field_list[] = {
F_XML_TAGNAME,
F_TYPE,
F_CIB_CLIENTID,
F_CIB_CALLOPTS,
F_CIB_CALLID,
F_CIB_OPERATION,
F_CIB_ISREPLY,
F_CIB_SECTION,
F_CIB_HOST,
F_CIB_RC,
F_CIB_DELEGATED,
F_CIB_OBJID,
F_CIB_OBJTYPE,
F_CIB_EXISTING,
F_CIB_SEENCOUNT,
F_CIB_TIMEOUT,
F_CIB_CALLBACK_TOKEN,
F_CIB_GLOBAL_UPDATE,
F_CIB_CLIENTNAME,
F_CIB_USER,
F_CIB_NOTIFY_TYPE,
F_CIB_NOTIFY_ACTIVATE
};
static const char *data_list[] = {
F_CIB_CALLDATA,
F_CIB_UPDATE,
F_CIB_UPDATE_RESULT
};
xmlNode *copy = create_xml_node(NULL, "copy");
CRM_ASSERT(copy != NULL);
for (lpc = 0; lpc < PCMK__NELEM(field_list); lpc++) {
field = field_list[lpc];
value = crm_element_value(msg, field);
if (value != NULL) {
crm_xml_add(copy, field, value);
}
}
for (lpc = 0; with_data && lpc < PCMK__NELEM(data_list); lpc++) {
field = data_list[lpc];
value_struct = get_message_xml(msg, field);
if (value_struct != NULL) {
add_message_xml(copy, field, value_struct);
}
}
return copy;
}
cib_op_t *
cib_op_func(int call_type)
{
return &(cib_server_ops[call_type].fn);
}
gboolean
cib_op_modifies(int call_type)
{
return cib_server_ops[call_type].modifies_cib;
}
int
cib_op_can_run(int call_type, int call_options, gboolean privileged, gboolean global_update)
{
if (privileged == FALSE && cib_server_ops[call_type].needs_privileges) {
/* abort */
return -EACCES;
}
#if 0
if (rc == pcmk_ok
&& stand_alone == FALSE
&& global_update == FALSE
&& (call_options & cib_quorum_override) == 0 && cib_server_ops[call_type].needs_quorum) {
return -pcmk_err_no_quorum;
}
#endif
return pcmk_ok;
}
int
cib_op_prepare(int call_type, xmlNode * request, xmlNode ** input, const char **section)
{
crm_trace("Prepare %d", call_type);
return cib_server_ops[call_type].prepare(request, input, section);
}
int
cib_op_cleanup(int call_type, int options, xmlNode ** input, xmlNode ** output)
{
crm_trace("Cleanup %d", call_type);
return cib_server_ops[call_type].cleanup(options, input, output);
}
diff --git a/include/crm/cib/internal.h b/include/crm/cib/internal.h
index 8631b2e7f3..3871e2701f 100644
--- a/include/crm/cib/internal.h
+++ b/include/crm/cib/internal.h
@@ -1,261 +1,261 @@
/*
* Copyright 2004-2022 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
* This source code is licensed under the GNU Lesser General Public License
* version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
*/
#ifndef CIB_INTERNAL__H
# define CIB_INTERNAL__H
# include <crm/cib.h>
# include <crm/common/ipc_internal.h>
# include <crm/common/output_internal.h>
// Request types for CIB manager IPC/CPG
#define PCMK__CIB_REQUEST_SECONDARY "cib_slave"
-# define CIB_OP_SLAVEALL "cib_slave_all"
+#define PCMK__CIB_REQUEST_ALL_SECONDARY "cib_slave_all"
# define CIB_OP_MASTER "cib_master"
# define CIB_OP_SYNC "cib_sync"
# define CIB_OP_SYNC_ONE "cib_sync_one"
# define CIB_OP_ISMASTER "cib_ismaster"
# define CIB_OP_BUMP "cib_bump"
# define CIB_OP_QUERY "cib_query"
# define CIB_OP_CREATE "cib_create"
# define CIB_OP_MODIFY "cib_modify"
# define CIB_OP_DELETE "cib_delete"
# define CIB_OP_ERASE "cib_erase"
# define CIB_OP_REPLACE "cib_replace"
# define CIB_OP_APPLY_DIFF "cib_apply_diff"
# define CIB_OP_UPGRADE "cib_upgrade"
# define CIB_OP_DELETE_ALT "cib_delete_alt"
# define F_CIB_CLIENTID "cib_clientid"
# define F_CIB_CALLOPTS "cib_callopt"
# define F_CIB_CALLID "cib_callid"
# define F_CIB_CALLDATA "cib_calldata"
# define F_CIB_OPERATION "cib_op"
# define F_CIB_ISREPLY "cib_isreplyto"
# define F_CIB_SECTION "cib_section"
# define F_CIB_HOST "cib_host"
# define F_CIB_RC "cib_rc"
# define F_CIB_UPGRADE_RC "cib_upgrade_rc"
# define F_CIB_DELEGATED "cib_delegated_from"
# define F_CIB_OBJID "cib_object"
# define F_CIB_OBJTYPE "cib_object_type"
# define F_CIB_EXISTING "cib_existing_object"
# define F_CIB_SEENCOUNT "cib_seen"
# define F_CIB_TIMEOUT "cib_timeout"
# define F_CIB_UPDATE "cib_update"
# define F_CIB_CALLBACK_TOKEN "cib_async_id"
# define F_CIB_GLOBAL_UPDATE "cib_update"
# define F_CIB_UPDATE_RESULT "cib_update_result"
# define F_CIB_CLIENTNAME "cib_clientname"
# define F_CIB_NOTIFY_TYPE "cib_notify_type"
# define F_CIB_NOTIFY_ACTIVATE "cib_notify_activate"
# define F_CIB_UPDATE_DIFF "cib_update_diff"
# define F_CIB_USER "cib_user"
# define F_CIB_LOCAL_NOTIFY_ID "cib_local_notify_id"
# define F_CIB_PING_ID "cib_ping_id"
# define F_CIB_SCHEMA_MAX "cib_schema_max"
# define F_CIB_CHANGE_SECTION "cib_change_section"
# define T_CIB "cib"
# define T_CIB_NOTIFY "cib_notify"
/* notify sub-types */
# define T_CIB_PRE_NOTIFY "cib_pre_notify"
# define T_CIB_POST_NOTIFY "cib_post_notify"
# define T_CIB_UPDATE_CONFIRM "cib_update_confirmation"
# define T_CIB_REPLACE_NOTIFY "cib_refresh_notify"
enum cib_change_section_info {
cib_change_section_none = 0x00000000,
cib_change_section_nodes = 0x00000001,
cib_change_section_alerts = 0x00000002,
cib_change_section_status = 0x00000004
};
gboolean cib_diff_version_details(xmlNode * diff, int *admin_epoch, int *epoch, int *updates,
int *_admin_epoch, int *_epoch, int *_updates);
gboolean cib_read_config(GHashTable * options, xmlNode * current_cib);
void verify_cib_options(GHashTable * options);
gboolean cib_internal_config_changed(xmlNode * diff);
typedef struct cib_notify_client_s {
const char *event;
const char *obj_id; /* implement one day */
const char *obj_type; /* implement one day */
void (*callback) (const char *event, xmlNode * msg);
} cib_notify_client_t;
typedef struct cib_callback_client_s {
void (*callback) (xmlNode *, int, int, xmlNode *, void *);
const char *id;
void *user_data;
gboolean only_success;
struct timer_rec_s *timer;
void (*free_func)(void *);
} cib_callback_client_t;
struct timer_rec_s {
int call_id;
int timeout;
guint ref;
cib_t *cib;
};
#define cib__set_call_options(cib_call_opts, call_for, flags_to_set) do { \
cib_call_opts = pcmk__set_flags_as(__func__, __LINE__, \
LOG_TRACE, "CIB call", (call_for), (cib_call_opts), \
(flags_to_set), #flags_to_set); \
} while (0)
#define cib__clear_call_options(cib_call_opts, call_for, flags_to_clear) do { \
cib_call_opts = pcmk__clear_flags_as(__func__, __LINE__, \
LOG_TRACE, "CIB call", (call_for), (cib_call_opts), \
(flags_to_clear), #flags_to_clear); \
} while (0)
typedef int (*cib_op_t) (const char *, int, const char *, xmlNode *,
xmlNode *, xmlNode *, xmlNode **, xmlNode **);
cib_t *cib_new_variant(void);
int cib_perform_op(const char *op, int call_options, cib_op_t * fn, gboolean is_query,
const char *section, xmlNode * req, xmlNode * input,
gboolean manage_counters, gboolean * config_changed,
xmlNode * current_cib, xmlNode ** result_cib, xmlNode ** diff,
xmlNode ** output);
xmlNode *cib_create_op(int call_id, const char *token, const char *op, const char *host,
const char *section, xmlNode * data, int call_options,
const char *user_name);
void cib_native_callback(cib_t * cib, xmlNode * msg, int call_id, int rc);
void cib_native_notify(gpointer data, gpointer user_data);
int cib_native_register_notification(cib_t * cib, const char *callback, int enabled);
gboolean cib_client_register_callback(cib_t * cib, int call_id, int timeout, gboolean only_success,
void *user_data, const char *callback_name,
void (*callback) (xmlNode *, int, int, xmlNode *, void *));
gboolean cib_client_register_callback_full(cib_t *cib, int call_id,
int timeout, gboolean only_success,
void *user_data,
const char *callback_name,
void (*callback)(xmlNode *, int, int,
xmlNode *, void *),
void (*free_func)(void *));
int cib_process_query(const char *op, int options, const char *section, xmlNode * req,
xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
xmlNode ** answer);
int cib_process_erase(const char *op, int options, const char *section, xmlNode * req,
xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
xmlNode ** answer);
int cib_process_bump(const char *op, int options, const char *section, xmlNode * req,
xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
xmlNode ** answer);
int cib_process_replace(const char *op, int options, const char *section, xmlNode * req,
xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
xmlNode ** answer);
int cib_process_create(const char *op, int options, const char *section, xmlNode * req,
xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
xmlNode ** answer);
int cib_process_modify(const char *op, int options, const char *section, xmlNode * req,
xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
xmlNode ** answer);
int cib_process_delete(const char *op, int options, const char *section, xmlNode * req,
xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
xmlNode ** answer);
int cib_process_diff(const char *op, int options, const char *section, xmlNode * req,
xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
xmlNode ** answer);
int cib_process_upgrade(const char *op, int options, const char *section, xmlNode * req,
xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
xmlNode ** answer);
/*!
* \internal
* \brief Query or modify a CIB
*
* \param[in] op CIB_OP_* operation to be performed
* \param[in] options Flag set of \c cib_call_options
* \param[in] section XPath to query or modify
* \param[in] req unused
* \param[in] input Portion of CIB to modify (used with
* CIB_OP_CREATE, CIB_OP_MODIFY, and
* CIB_OP_REPLACE)
* \param[in] existing_cib Input CIB (used with CIB_OP_QUERY)
* \param[in,out] result_cib CIB copy to make changes in (used with
* CIB_OP_CREATE, CIB_OP_MODIFY, CIB_OP_DELETE, and
* CIB_OP_REPLACE)
* \param[out] answer Query result (used with CIB_OP_QUERY)
*
* \return Legacy Pacemaker return code
*/
int cib_process_xpath(const char *op, int options, const char *section, xmlNode * req,
xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
xmlNode ** answer);
gboolean cib_config_changed(xmlNode * last, xmlNode * next, xmlNode ** diff);
gboolean update_results(xmlNode * failed, xmlNode * target, const char *operation, int return_code);
int cib_update_counter(xmlNode * xml_obj, const char *field, gboolean reset);
int cib_internal_op(cib_t * cib, const char *op, const char *host,
const char *section, xmlNode * data,
xmlNode ** output_data, int call_options, const char *user_name);
int cib_file_read_and_verify(const char *filename, const char *sigfile,
xmlNode **root);
int cib_file_write_with_digest(xmlNode *cib_root, const char *cib_dirname,
const char *cib_filename);
void cib__set_output(cib_t *cib, pcmk__output_t *out);
cib_callback_client_t* cib__lookup_id (int call_id);
/*!
* \internal
* \brief Connect to, query, and optionally disconnect from the CIB, returning
* the resulting XML object.
*
* \param[out] cib If non-NULL, a pointer to where to store the CIB
* connection. In this case, it is up to the caller to
* disconnect from the CIB when finished.
* \param[out] cib_object A pointer to where to store the XML query result.
*
* \return A standard Pacemaker return code
*/
int cib__signon_query(cib_t **cib, xmlNode **cib_object);
int cib__clean_up_connection(cib_t **cib);
int cib__update_node_attr(pcmk__output_t *out, cib_t *cib, int call_options,
const char *section, const char *node_uuid, const char *set_type,
const char *set_name, const char *attr_id, const char *attr_name,
const char *attr_value, const char *user_name,
const char *node_type);
int cib__get_node_attrs(pcmk__output_t *out, cib_t *cib, const char *section,
const char *node_uuid, const char *set_type, const char *set_name,
const char *attr_id, const char *attr_name, const char *user_name,
xmlNode **result);
int cib__delete_node_attr(pcmk__output_t *out, cib_t *cib, int options,
const char *section, const char *node_uuid, const char *set_type,
const char *set_name, const char *attr_id, const char *attr_name,
const char *attr_value, const char *user_name);
#endif

File Metadata

Mime Type
text/x-diff
Expires
Tue, Jul 8, 6:18 PM (12 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2002572
Default Alt Text
(21 KB)

Event Timeline