diff --git a/include/crm/msg_xml.h b/include/crm/msg_xml.h index 070cf84243..574b47b741 100644 --- a/include/crm/msg_xml.h +++ b/include/crm/msg_xml.h @@ -1,359 +1,356 @@ /* * Copyright 2004-2024 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 PCMK__CRM_MSG_XML__H # define PCMK__CRM_MSG_XML__H # include #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1) #include #endif #ifdef __cplusplus extern "C" { #endif /* This file defines constants for various XML syntax (mainly element and * attribute names). * * For consistency, new constants should start with "PCMK_", followed by: * * "XE" for XML element names * * "XA" for XML attribute names * * "OPT" for cluster option (property) names * * "META" for meta-attribute names * * "VALUE" for enumerated values for various options * * Old names that don't follow this policy should eventually be deprecated and * replaced with names that do. * * Symbols should be public if the user may specify them somewhere (especially * the CIB) or if they're part of a well-defined structure that a user may need * to parse. They should be internal if they're used only internally to * Pacemaker (such as daemon IPC/CPG message XML). * * Constants belong in the following locations: * * Public "XE" and "XA": msg_xml.h * * Internal "XE" and "XA": crm_internal.h * * Public "OPT", "META", and "VALUE": options.h * * Internal "OPT", "META", and "VALUE": options_internal.h * * For meta-attributes that can be specified as either XML attributes or nvpair * names, use "META" unless using both "XA" and "META" constants adds clarity. * An example is operation attributes, which can be specified either as * attributes of the PCMK_XE_OP element or as nvpairs in a meta-attribute set * beneath the PCMK_XE_OP element. */ /* * XML elements */ #define PCMK_XE_DATE_EXPRESSION "date_expression" #define PCMK_XE_OP "op" #define PCMK_XE_OPERATION "operation" #define PCMK_XE_OP_EXPRESSION "op_expression" #define PCMK_XE_RSC_EXPRESSION "rsc_expression" /* This has been deprecated as a CIB element (an alias for with * PCMK_META_PROMOTABLE set to "true") since 2.0.0. */ #define PCMK_XE_PROMOTABLE_LEGACY "master" /* * XML attributes */ #define PCMK_XA_ADMIN_EPOCH "admin_epoch" #define PCMK_XA_CIB_LAST_WRITTEN "cib-last-written" #define PCMK_XA_CLASS "class" #define PCMK_XA_CRM_DEBUG_ORIGIN "crm-debug-origin" #define PCMK_XA_CRM_FEATURE_SET "crm_feature_set" #define PCMK_XA_CRM_TIMESTAMP "crm-timestamp" #define PCMK_XA_DC_UUID "dc-uuid" #define PCMK_XA_DESCRIPTION "description" #define PCMK_XA_DEVICES "devices" #define PCMK_XA_EPOCH "epoch" #define PCMK_XA_FORMAT "format" #define PCMK_XA_HAVE_QUORUM "have-quorum" #define PCMK_XA_ID "id" #define PCMK_XA_ID_REF "id-ref" #define PCMK_XA_INDEX "index" #define PCMK_XA_NAME "name" #define PCMK_XA_NO_QUORUM_PANIC "no-quorum-panic" #define PCMK_XA_NUM_UPDATES "num_updates" #define PCMK_XA_OP "op" #define PCMK_XA_OPERATION "operation" #define PCMK_XA_ORIGIN "origin" #define PCMK_XA_PATH "path" #define PCMK_XA_PROVIDER "provider" #define PCMK_XA_REASON "reason" #define PCMK_XA_REFERENCE "reference" #define PCMK_XA_REQUEST "request" #define PCMK_XA_RESULT "result" #define PCMK_XA_TARGET "target" #define PCMK_XA_TARGET_ATTRIBUTE "target-attribute" #define PCMK_XA_TARGET_PATTERN "target-pattern" #define PCMK_XA_TARGET_VALUE "target-value" #define PCMK_XA_TYPE "type" #define PCMK_XA_UNAME "uname" #define PCMK_XA_UPDATE_CLIENT "update-client" #define PCMK_XA_UPDATE_ORIGIN "update-origin" #define PCMK_XA_UPDATE_USER "update-user" #define PCMK_XA_VALIDATE_WITH "validate-with" #define PCMK_XA_VALUE "value" #define PCMK_XA_VERSION "version" /* * Older constants that don't follow current naming */ # ifndef T_CRM # define T_CRM "crmd" # endif # ifndef T_ATTRD # define T_ATTRD "attrd" # endif # define CIB_OPTIONS_FIRST "cib-bootstrap-options" # define F_CRM_DATA "crm_xml" /*---- Common tags/attrs */ # define XML_DIFF_MARKER "__crm_diff_marker__" # define XML_TAG_CIB "cib" # define XML_TAG_FAILED "failed" # define XML_TAG_OPTIONS "options" /*---- top level tags/attrs */ # define XML_CRM_TAG_PING "ping_response" # define XML_PING_ATTR_PACEMAKERDSTATE_INIT "init" # define XML_PING_ATTR_PACEMAKERDSTATE_STARTINGDAEMONS "starting_daemons" # define XML_PING_ATTR_PACEMAKERDSTATE_WAITPING "wait_for_ping" # define XML_PING_ATTR_PACEMAKERDSTATE_RUNNING "running" # define XML_PING_ATTR_PACEMAKERDSTATE_SHUTTINGDOWN "shutting_down" # define XML_PING_ATTR_PACEMAKERDSTATE_SHUTDOWNCOMPLETE "shutdown_complete" # define XML_PING_ATTR_PACEMAKERDSTATE_REMOTE "remote" # define XML_FAIL_TAG_CIB "failed_update" /*---- CIB specific tags/attrs */ # define XML_CIB_TAG_SECTION_ALL "all" # define XML_CIB_TAG_CONFIGURATION "configuration" # define XML_CIB_TAG_STATUS "status" # define XML_CIB_TAG_RESOURCES "resources" # define XML_CIB_TAG_NODES "nodes" # define XML_CIB_TAG_CONSTRAINTS "constraints" # define XML_CIB_TAG_CRMCONFIG "crm_config" # define XML_CIB_TAG_OPCONFIG "op_defaults" # define XML_CIB_TAG_RSCCONFIG "rsc_defaults" # define XML_CIB_TAG_ACLS "acls" # define XML_CIB_TAG_ALERTS "alerts" # define XML_CIB_TAG_ALERT "alert" # define XML_CIB_TAG_ALERT_RECIPIENT "recipient" # define XML_CIB_TAG_ALERT_SELECT "select" # define XML_CIB_TAG_ALERT_ATTRIBUTES "select_attributes" # define XML_CIB_TAG_ALERT_FENCING "select_fencing" # define XML_CIB_TAG_ALERT_NODES "select_nodes" # define XML_CIB_TAG_ALERT_RESOURCES "select_resources" # define XML_CIB_TAG_ALERT_ATTR "attribute" # define XML_CIB_TAG_STATE "node_state" # define XML_CIB_TAG_NODE "node" # define XML_CIB_TAG_NVPAIR "nvpair" # define XML_CIB_TAG_PROPSET "cluster_property_set" # define XML_TAG_ATTR_SETS "instance_attributes" # define XML_TAG_META_SETS "meta_attributes" # define XML_TAG_ATTRS "attributes" # define XML_TAG_PARAMS "parameters" # define XML_TAG_PARAM "param" # define XML_TAG_UTILIZATION "utilization" # define XML_TAG_RESOURCE_REF "resource_ref" # define XML_CIB_TAG_RESOURCE "primitive" # define XML_CIB_TAG_GROUP "group" # define XML_CIB_TAG_INCARNATION "clone" # define XML_CIB_TAG_CONTAINER "bundle" # define XML_CIB_TAG_RSC_TEMPLATE "template" # define XML_OP_ATTR_ON_FAIL "on-fail" # define XML_OP_ATTR_START_DELAY "start-delay" # define XML_OP_ATTR_ORIGIN "interval-origin" # define XML_OP_ATTR_PENDING "record-pending" # define XML_OP_ATTR_DIGESTS_ALL "digests-all" # define XML_OP_ATTR_DIGESTS_SECURE "digests-secure" # define XML_CIB_TAG_LRM "lrm" # define XML_LRM_TAG_RESOURCES "lrm_resources" # define XML_LRM_TAG_RESOURCE "lrm_resource" # define XML_LRM_TAG_RSC_OP "lrm_rsc_op" -//! \deprecated Do not use (will be removed in a future release) -# define XML_CIB_ATTR_REPLACE "replace" - # define XML_CIB_ATTR_PRIORITY "priority" # define XML_NODE_IS_REMOTE "remote_node" # define XML_NODE_IS_FENCED "node_fenced" # define XML_NODE_IS_MAINTENANCE "node_in_maintenance" # define XML_CIB_ATTR_SHUTDOWN "shutdown" /* Aside from being an old name for the executor, LRM is a misnomer here because * the controller and scheduler use these to track actions, which are not always * executor operations. */ # define XML_LRM_ATTR_TASK_KEY "operation_key" # define XML_LRM_ATTR_TARGET "on_node" # define XML_LRM_ATTR_TARGET_UUID "on_node_uuid" /*! Actions to be executed on Pacemaker Remote nodes are routed through the * controller on the cluster node hosting the remote connection. That cluster * node is considered the router node for the action. */ # define XML_LRM_ATTR_ROUTER_NODE "router_node" # define XML_LRM_ATTR_RSCID "rsc-id" # define XML_LRM_ATTR_OPSTATUS "op-status" # define XML_LRM_ATTR_RC "rc-code" # define XML_LRM_ATTR_CALLID "call-id" # define XML_LRM_ATTR_OP_DIGEST "op-digest" # define XML_LRM_ATTR_OP_RESTART "op-force-restart" # define XML_LRM_ATTR_OP_SECURE "op-secure-params" # define XML_LRM_ATTR_RESTART_DIGEST "op-restart-digest" # define XML_LRM_ATTR_SECURE_DIGEST "op-secure-digest" # define XML_LRM_ATTR_EXIT_REASON "exit-reason" # define XML_RSC_OP_LAST_CHANGE "last-rc-change" # define XML_RSC_OP_T_EXEC "exec-time" # define XML_RSC_OP_T_QUEUE "queue-time" # define XML_LRM_ATTR_MIGRATE_SOURCE "migrate_source" # define XML_LRM_ATTR_MIGRATE_TARGET "migrate_target" # define XML_TAG_GRAPH "transition_graph" # define XML_GRAPH_TAG_RSC_OP "rsc_op" # define XML_GRAPH_TAG_PSEUDO_EVENT "pseudo_event" # define XML_GRAPH_TAG_CRM_EVENT "crm_event" # define XML_GRAPH_TAG_DOWNED "downed" # define XML_GRAPH_TAG_MAINTENANCE "maintenance" # define XML_TAG_RULE "rule" # define XML_RULE_ATTR_SCORE "score" # define XML_RULE_ATTR_SCORE_ATTRIBUTE "score-attribute" # define XML_RULE_ATTR_ROLE "role" # define XML_RULE_ATTR_BOOLEAN_OP "boolean-op" # define XML_TAG_EXPRESSION "expression" # define XML_EXPR_ATTR_ATTRIBUTE "attribute" # define XML_EXPR_ATTR_VALUE_SOURCE "value-source" # define XML_CONS_TAG_RSC_DEPEND "rsc_colocation" # define XML_CONS_TAG_RSC_ORDER "rsc_order" # define XML_CONS_TAG_RSC_LOCATION "rsc_location" # define XML_CONS_TAG_RSC_TICKET "rsc_ticket" # define XML_CONS_TAG_RSC_SET "resource_set" # define XML_CONS_ATTR_SYMMETRICAL "symmetrical" # define XML_LOCATION_ATTR_DISCOVERY "resource-discovery" # define XML_COLOC_ATTR_SOURCE "rsc" # define XML_COLOC_ATTR_SOURCE_ROLE "rsc-role" # define XML_COLOC_ATTR_TARGET "with-rsc" # define XML_COLOC_ATTR_TARGET_ROLE "with-rsc-role" # define XML_COLOC_ATTR_NODE_ATTR "node-attribute" # define XML_COLOC_ATTR_INFLUENCE "influence" //! \deprecated Deprecated since 2.1.5 # define XML_COLOC_ATTR_SOURCE_INSTANCE "rsc-instance" //! \deprecated Deprecated since 2.1.5 # define XML_COLOC_ATTR_TARGET_INSTANCE "with-rsc-instance" # define XML_LOC_ATTR_SOURCE "rsc" # define XML_LOC_ATTR_SOURCE_PATTERN "rsc-pattern" # define XML_ORDER_ATTR_FIRST "first" # define XML_ORDER_ATTR_THEN "then" # define XML_ORDER_ATTR_FIRST_ACTION "first-action" # define XML_ORDER_ATTR_THEN_ACTION "then-action" # define XML_ORDER_ATTR_KIND "kind" //! \deprecated Deprecated since 2.1.5 # define XML_ORDER_ATTR_FIRST_INSTANCE "first-instance" //! \deprecated Deprecated since 2.1.5 # define XML_ORDER_ATTR_THEN_INSTANCE "then-instance" # define XML_TICKET_ATTR_TICKET "ticket" # define XML_TICKET_ATTR_LOSS_POLICY "loss-policy" # define XML_NODE_ATTR_RSC_DISCOVERY "resource-discovery-enabled" # define XML_CIB_TAG_GENERATION_TUPPLE "generation_tuple" # define XML_ATTR_TE_NOWAIT "op_no_wait" # define XML_ATTR_TE_TARGET_RC "op_target_rc" # define XML_TAG_TRANSIENT_NODEATTRS "transient_attributes" //! \deprecated Do not use (will be removed in a future release) # define XML_TAG_DIFF_ADDED "diff-added" //! \deprecated Do not use (will be removed in a future release) # define XML_TAG_DIFF_REMOVED "diff-removed" # define XML_ACL_TAG_USER "acl_target" # define XML_ACL_TAG_USERv1 "acl_user" # define XML_ACL_TAG_GROUP "acl_group" # define XML_ACL_TAG_ROLE "acl_role" # define XML_ACL_TAG_PERMISSION "acl_permission" # define XML_ACL_TAG_ROLE_REF "role" # define XML_ACL_TAG_ROLE_REFv1 "role_ref" # define XML_ACL_ATTR_KIND "kind" # define XML_ACL_TAG_READ "read" # define XML_ACL_TAG_WRITE "write" # define XML_ACL_TAG_DENY "deny" # define XML_ACL_ATTR_REFv1 "ref" # define XML_ACL_ATTR_TAG "object-type" # define XML_ACL_ATTR_TAGv1 "tag" # define XML_ACL_ATTR_XPATH "xpath" # define XML_ACL_ATTR_ATTRIBUTE "attribute" # define XML_CIB_TAG_TICKETS "tickets" # define XML_CIB_TAG_TICKET_STATE "ticket_state" # define XML_CIB_TAG_TAGS "tags" # define XML_CIB_TAG_TAG "tag" # define XML_CIB_TAG_OBJ_REF "obj_ref" # define XML_TAG_FENCING_TOPOLOGY "fencing-topology" # define XML_TAG_FENCING_LEVEL "fencing-level" # define XML_TAG_DIFF "diff" # define XML_DIFF_VERSION "version" # define XML_DIFF_VSOURCE "source" # define XML_DIFF_VTARGET "target" # define XML_DIFF_CHANGE "change" # define XML_DIFF_LIST "change-list" # define XML_DIFF_ATTR "change-attr" # define XML_DIFF_RESULT "change-result" # define XML_DIFF_POSITION "position" # define ID(x) crm_element_value(x, PCMK_XA_ID) #ifdef __cplusplus } #endif #endif diff --git a/include/crm/msg_xml_compat.h b/include/crm/msg_xml_compat.h index 4a5e110767..959bf90011 100644 --- a/include/crm/msg_xml_compat.h +++ b/include/crm/msg_xml_compat.h @@ -1,512 +1,515 @@ /* * Copyright 2004-2024 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 PCMK__CRM_MSG_XML_COMPAT__H # define PCMK__CRM_MSG_XML_COMPAT__H #include // PCMK_STONITH_PROVIDES #ifdef __cplusplus extern "C" { #endif /** * \file * \brief Deprecated Pacemaker XML constants API * \ingroup core * \deprecated Do not include this header directly. The XML constants in this * header, and the header itself, will be removed in a future * release. */ //! \deprecated Use PCMK_META_CLONE_MAX instead #define XML_RSC_ATTR_INCARNATION_MAX PCMK_META_CLONE_MAX //! \deprecated Use PCMK_META_CLONE_MIN instead #define XML_RSC_ATTR_INCARNATION_MIN PCMK_META_CLONE_MIN //! \deprecated Use PCMK_META_CLONE_NODE_MAX instead #define XML_RSC_ATTR_INCARNATION_NODEMAX PCMK_META_CLONE_NODE_MAX //! \deprecated Use PCMK_META_PROMOTED_MAX instead #define XML_RSC_ATTR_PROMOTED_MAX PCMK_META_PROMOTED_MAX //! \deprecated Use PCMK_META_PROMOTED_NODE_MAX instead #define XML_RSC_ATTR_PROMOTED_NODEMAX PCMK_META_PROMOTED_NODE_MAX //! \deprecated Use PCMK_STONITH_PROVIDES instead #define XML_RSC_ATTR_PROVIDES PCMK_STONITH_PROVIDES //! \deprecated Use PCMK_XE_PROMOTABLE_LEGACY instead #define XML_CIB_TAG_MASTER PCMK_XE_PROMOTABLE_LEGACY //! \deprecated Do not use #define PCMK_XA_PROMOTED_MAX_LEGACY "master-max" //! \deprecated Do not use #define PCMK_XE_PROMOTED_MAX_LEGACY PCMK_XA_PROMOTED_MAX_LEGACY //! \deprecated Do not use #define XML_RSC_ATTR_MASTER_MAX PCMK_XA_PROMOTED_MAX_LEGACY //! \deprecated Do not use #define PCMK_XA_PROMOTED_NODE_MAX_LEGACY "master-node-max" //! \deprecated Do not use #define PCMK_XE_PROMOTED_NODE_MAX_LEGACY PCMK_XA_PROMOTED_NODE_MAX_LEGACY //! \deprecated Do not use #define XML_RSC_ATTR_MASTER_NODEMAX PCMK_XA_PROMOTED_NODE_MAX_LEGACY //! \deprecated Use PCMK_META_MIGRATION_THRESHOLD instead #define XML_RSC_ATTR_FAIL_STICKINESS PCMK_META_MIGRATION_THRESHOLD //! \deprecated Use PCMK_META_FAILURE_TIMEOUT instead #define XML_RSC_ATTR_FAIL_TIMEOUT PCMK_META_FAILURE_TIMEOUT //! \deprecated Do not use (will be removed in a future release) #define XML_ATTR_RA_VERSION "ra-version" //! \deprecated Do not use (will be removed in a future release) #define XML_TAG_FRAGMENT "cib_fragment" //! \deprecated Do not use (will be removed in a future release) #define XML_TAG_RSC_VER_ATTRS "rsc_versioned_attrs" //! \deprecated Do not use (will be removed in a future release) #define XML_TAG_OP_VER_ATTRS "op_versioned_attrs" //! \deprecated Do not use (will be removed in a future release) #define XML_TAG_OP_VER_META "op_versioned_meta" //! \deprecated Use \p PCMK_XA_ID instead #define XML_ATTR_UUID "id" //! \deprecated Do not use (will be removed in a future release) #define XML_ATTR_VERBOSE "verbose" //! \deprecated Do not use (will be removed in a future release) #define XML_CIB_TAG_DOMAINS "domains" //! \deprecated Do not use (will be removed in a future release) #define XML_CIB_ATTR_SOURCE "source" //! \deprecated Do not use #define XML_NODE_EXPECTED "expected" //! \deprecated Do not use #define XML_NODE_IN_CLUSTER "in_ccm" //! \deprecated Do not use #define XML_NODE_IS_PEER "crmd" //! \deprecated Do not use #define XML_NODE_JOIN_STATE "join" //! \deprecated Do not use (will be removed in a future release) #define XML_RSC_OP_LAST_RUN "last-run" //! \deprecated Use name member directly #define TYPE(x) (((x) == NULL)? NULL : (const char *) ((x)->name)) //! \deprecated Use \c PCMK_OPT_CLUSTER_RECHECK_INTERVAL instead #define XML_CONFIG_ATTR_RECHECK PCMK_OPT_CLUSTER_RECHECK_INTERVAL //! \deprecated Use \c PCMK_OPT_DC_DEADTIME instead #define XML_CONFIG_ATTR_DC_DEADTIME PCMK_OPT_DC_DEADTIME //! \deprecated Use \c PCMK_OPT_ELECTION_TIMEOUT instead #define XML_CONFIG_ATTR_ELECTION_FAIL PCMK_OPT_ELECTION_TIMEOUT //! \deprecated Use \c PCMK_OPT_FENCE_REACTION instead #define XML_CONFIG_ATTR_FENCE_REACTION PCMK_OPT_FENCE_REACTION //! \deprecated Use \c PCMK_OPT_HAVE_WATCHDOG instead #define XML_ATTR_HAVE_WATCHDOG PCMK_OPT_HAVE_WATCHDOG //! \deprecated Use \c PCMK_OPT_NODE_PENDING_TIMEOUT instead #define XML_CONFIG_ATTR_NODE_PENDING_TIMEOUT PCMK_OPT_NODE_PENDING_TIMEOUT //! \deprecated Use \c PCMK_OPT_PRIORITY_FENCING_DELAY instead #define XML_CONFIG_ATTR_PRIORITY_FENCING_DELAY PCMK_OPT_PRIORITY_FENCING_DELAY //! \deprecated Use \c PCMK_OPT_SHUTDOWN_ESCALATION instead #define XML_CONFIG_ATTR_FORCE_QUIT PCMK_OPT_SHUTDOWN_ESCALATION //! \deprecated Use \c PCMK_OPT_SHUTDOWN_LOCK instead #define XML_CONFIG_ATTR_SHUTDOWN_LOCK PCMK_OPT_SHUTDOWN_LOCK //! \deprecated Use \c PCMK_OPT_SHUTDOWN_LOCK_LIMIT instead #define XML_CONFIG_ATTR_SHUTDOWN_LOCK_LIMIT PCMK_OPT_SHUTDOWN_LOCK_LIMIT //! \deprecated Use \c PCMK_XA_CRM_FEATURE_SET instead #define XML_ATTR_CRM_VERSION PCMK_XA_CRM_FEATURE_SET //! \deprecated Do not use #define XML_ATTR_DIGEST "digest" //! \deprecated Use \c PCMK_XA_VALIDATE_WITH instead #define XML_ATTR_VALIDATION PCMK_XA_VALIDATE_WITH //! \deprecated Use \c PCMK_XA_NO_QUORUM_PANIC instead #define XML_ATTR_QUORUM_PANIC PCMK_XA_NO_QUORUM_PANIC //! \deprecated Use \c PCMK_XA_HAVE_QUORUM instead #define XML_ATTR_HAVE_QUORUM PCMK_XA_HAVE_QUORUM //! \deprecated Use \c PCMK_XA_EPOCH instead #define XML_ATTR_GENERATION PCMK_XA_EPOCH //! \deprecated Use \c PCMK_XA_ADMIN_EPOCH instead #define XML_ATTR_GENERATION_ADMIN PCMK_XA_ADMIN_EPOCH //! \deprecated Use \c PCMK_XA_NUM_UPDATES instead #define XML_ATTR_NUMUPDATES PCMK_XA_NUM_UPDATES //! \deprecated Use \c PCMK_XA_CRM_DEBUG_ORIGIN instead #define XML_ATTR_ORIGIN PCMK_XA_CRM_DEBUG_ORIGIN //! \deprecated Use \c PCMK_XA_CRM_TIMESTAMP instead #define XML_ATTR_TSTAMP PCMK_XA_CRM_TIMESTAMP //! \deprecated Use \c PCMK_XA_CIB_LAST_WRITTEN instead #define XML_CIB_ATTR_WRITTEN PCMK_XA_CIB_LAST_WRITTEN //! \deprecated Use \c PCMK_XA_VERSION instead #define XML_ATTR_VERSION PCMK_XA_VERSION //! \deprecated Use \c PCMK_XA_DESCRIPTION instead #define XML_ATTR_DESC PCMK_XA_DESCRIPTION //! \deprecated Use \c PCMK_XA_ID instead #define XML_ATTR_ID PCMK_XA_ID //! \deprecated Use \c PCMK_XA_ID instead #define XML_FAILCIB_ATTR_ID PCMK_XA_ID //! \deprecated Use \c PCMK_META_CONTAINER_ATTR_TARGET instead #define XML_RSC_ATTR_TARGET PCMK_META_CONTAINER_ATTR_TARGET //! \deprecated Do not use #define XML_RSC_ATTR_RESTART "restart-type" //! \deprecated Use \c PCMK_META_ORDERED instead #define XML_RSC_ATTR_ORDERED PCMK_META_ORDERED //! \deprecated Use \c PCMK_META_INTERLEAVE instead #define XML_RSC_ATTR_INTERLEAVE PCMK_META_INTERLEAVE //! \deprecated Do not use #define XML_RSC_ATTR_INCARNATION "clone" //! \deprecated Use \c PCMK_META_PROMOTABLE instead #define XML_RSC_ATTR_PROMOTABLE PCMK_META_PROMOTABLE //! \deprecated Use \c PCMK_META_IS_MANAGED instead #define XML_RSC_ATTR_MANAGED PCMK_META_IS_MANAGED //! \deprecated Use \c PCMK_META_TARGET_ROLE instead #define XML_RSC_ATTR_TARGET_ROLE PCMK_META_TARGET_ROLE //! \deprecated Use \c PCMK_META_GLOBALLY_UNIQUE instead #define XML_RSC_ATTR_UNIQUE PCMK_META_GLOBALLY_UNIQUE //! \deprecated Use \c PCMK_META_NOTIFY instead #define XML_RSC_ATTR_NOTIFY PCMK_META_NOTIFY //! \deprecated Use \c PCMK_META_RESOURCE_STICKINESS instead #define XML_RSC_ATTR_STICKINESS PCMK_META_RESOURCE_STICKINESS //! \deprecated Use \c PCMK_META_MULTIPLE_ACTIVE instead #define XML_RSC_ATTR_MULTIPLE PCMK_META_MULTIPLE_ACTIVE //! \deprecated Use \c PCMK_META_REQUIRES instead #define XML_RSC_ATTR_REQUIRES PCMK_META_REQUIRES //! \deprecated Do not use #define XML_RSC_ATTR_CONTAINER "container" //! \deprecated Do not use #define XML_RSC_ATTR_INTERNAL_RSC "internal_rsc" //! \deprecated Use \c PCMK_META_MAINTENANCE instead #define XML_RSC_ATTR_MAINTENANCE PCMK_META_MAINTENANCE //! \deprecated Use \c PCMK_META_REMOTE_NODE instead #define XML_RSC_ATTR_REMOTE_NODE PCMK_META_REMOTE_NODE //! \deprecated Do not use #define XML_RSC_ATTR_CLEAR_OP "clear_failure_op" //! \deprecated Do not use #define XML_RSC_ATTR_CLEAR_INTERVAL "clear_failure_interval" //! \deprecated Use \c PCMK_META_CRITICAL instead #define XML_RSC_ATTR_CRITICAL PCMK_META_CRITICAL //! \deprecated Use \c PCMK_META_ALLOW_MIGRATE instead #define XML_OP_ATTR_ALLOW_MIGRATE PCMK_META_ALLOW_MIGRATE //! \deprecated Use \c PCMK_VALUE_TRUE instead #define XML_BOOLEAN_YES PCMK_VALUE_TRUE //! \deprecated Use \c PCMK_VALUE_FALSE instead #define XML_BOOLEAN_NO PCMK_VALUE_FALSE //! \deprecated Use \c PCMK_REMOTE_RA_ADDR instead #define XML_RSC_ATTR_REMOTE_RA_ADDR PCMK_REMOTE_RA_ADDR //! \deprecated Use \c PCMK_REMOTE_RA_SERVER instead #define XML_RSC_ATTR_REMOTE_RA_SERVER PCMK_REMOTE_RA_SERVER //! \deprecated Use \c PCMK_REMOTE_RA_PORT instead #define XML_RSC_ATTR_REMOTE_RA_PORT PCMK_REMOTE_RA_PORT //! \deprecated Use \c PCMK_REMOTE_RA_RECONNECT_INTERVAL instead #define XML_REMOTE_ATTR_RECONNECT_INTERVAL PCMK_REMOTE_RA_RECONNECT_INTERVAL //! \deprecated Use \c PCMK_XA_NAME instead #define XML_ATTR_NAME PCMK_XA_NAME //! \deprecated Use \c PCMK_XA_NAME instead #define XML_NVPAIR_ATTR_NAME PCMK_XA_NAME //! \deprecated Use \c PCMK_XA_VALUE instead #define XML_EXPR_ATTR_VALUE PCMK_XA_VALUE //! \deprecated Use \c PCMK_XA_VALUE instead #define XML_NVPAIR_ATTR_VALUE PCMK_XA_VALUE //! \deprecated Use \c PCMK_XA_VALUE instead #define XML_ALERT_ATTR_REC_VALUE PCMK_XA_VALUE //! \deprecated Use \c PCMK_XA_ID_REF instead #define XML_ATTR_IDREF PCMK_XA_ID_REF //! \deprecated Do not use #define XML_ATTR_ID_LONG "long-id" //! \deprecated Use \c PCMK_XA_TYPE instead #define XML_ATTR_TYPE PCMK_XA_TYPE //! \deprecated Use \c PCMK_XA_TYPE instead #define XML_EXPR_ATTR_TYPE PCMK_XA_TYPE //! \deprecated Use \c PCMK_XA_PROVIDER instead #define XML_AGENT_ATTR_PROVIDER PCMK_XA_PROVIDER //! \deprecated Use \c PCMK_XA_CLASS instead #define XML_AGENT_ATTR_CLASS PCMK_XA_CLASS //! \deprecated Use \c PCMK_XE_OP instead #define XML_ATTR_OP PCMK_XE_OP //! \deprecated Use \c PCMK_XA_DC_UUID instead #define XML_ATTR_DC_UUID PCMK_XA_DC_UUID //! \deprecated Use \c PCMK_XA_UPDATE_ORIGIN instead #define XML_ATTR_UPDATE_ORIG PCMK_XA_UPDATE_ORIGIN //! \deprecated Use \c PCMK_XA_UPDATE_CLIENT instead #define XML_ATTR_UPDATE_CLIENT PCMK_XA_UPDATE_CLIENT //! \deprecated Use \c PCMK_XA_UPDATE_USER instead #define XML_ATTR_UPDATE_USER PCMK_XA_UPDATE_USER //! \deprecated Use \c PCMK_XA_REQUEST instead #define XML_ATTR_REQUEST PCMK_XA_REQUEST //! \deprecated Do not use #define XML_ATTR_RESPONSE "response" //! \deprecated Use \c PCMK_XA_UNAME instead #define XML_ATTR_UNAME PCMK_XA_UNAME //! \deprecated Use \c PCMK_XA_REFERENCE instead #define XML_ATTR_REFERENCE PCMK_XA_REFERENCE //! \deprecated Use \c PCMK_XA_REFERENCE instead #define XML_ACL_ATTR_REF PCMK_XA_REFERENCE //! \deprecated Use \c PCMK_XA_REFERENCE instead #define F_CRM_REFERENCE PCMK_XA_REFERENCE //! \deprecated Do not use #define XML_ATTR_TRANSITION_MAGIC "transition-magic" //! \deprecated Do not use #define XML_ATTR_TRANSITION_KEY "transition-key" //! \deprecated Use \c PCMK_XA_INDEX instead #define XML_ATTR_STONITH_INDEX PCMK_XA_INDEX //! \deprecated Use \c PCMK_XA_TARGET instead #define XML_ATTR_STONITH_TARGET PCMK_XA_TARGET //! \deprecated Use \c PCMK_XA_TARGET_VALUE instead #define XML_ATTR_STONITH_TARGET_VALUE PCMK_XA_TARGET_VALUE //! \deprecated Use \c PCMK_XA_TARGET_PATTERN instead #define XML_ATTR_STONITH_TARGET_PATTERN PCMK_XA_TARGET_PATTERN //! \deprecated Use \c PCMK_XA_TARGET_ATTRIBUTE instead #define XML_ATTR_STONITH_TARGET_ATTRIBUTE PCMK_XA_TARGET_ATTRIBUTE //! \deprecated Use \c PCMK_XA_DEVICES instead #define XML_ATTR_STONITH_DEVICES PCMK_XA_DEVICES #ifndef F_ORIG //! \deprecated Do not use #define F_ORIG "src" #endif //! \deprecated Do not use #define F_CRM_HOST_FROM F_ORIG #ifndef F_SEQ //! \deprecated Do not use #define F_SEQ "seq" #endif #ifndef F_SUBTYPE //! \deprecated Do not use #define F_SUBTYPE "subt" #endif //! \deprecated Do not use #define F_CRM_MSG_TYPE F_SUBTYPE #ifndef F_TYPE //! \deprecated Do not use #define F_TYPE "t" #endif #ifndef F_CLIENTNAME //! \deprecated Do not use #define F_CLIENTNAME "cn" #endif #ifndef F_XML_TAGNAME //! \deprecated Do not use #define F_XML_TAGNAME "__name__" #endif //! \deprecated Use \c PCMK_VALUE_TRUE instead #define XML_BOOLEAN_TRUE PCMK_VALUE_TRUE //! \deprecated Use \c PCMK_VALUE_FALSE instead #define XML_BOOLEAN_FALSE PCMK_VALUE_FALSE //! \deprecated Do not use #define F_CRM_TASK "crm_task" //! \deprecated Do not use #define F_CRM_HOST_TO "crm_host_to" //! \deprecated Do not use #define F_CRM_SYS_TO "crm_sys_to" //! \deprecated Do not use #define F_CRM_SYS_FROM "crm_sys_from" //! \deprecated Use \c PCMK_XA_VERSION instead #define F_CRM_VERSION PCMK_XA_VERSION //! \deprecated Use \c PCMK_XA_ORIGIN instead #define F_CRM_ORIGIN PCMK_XA_ORIGIN //! \deprecated Do not use #define F_CRM_USER "crm_user" //! \deprecated Do not use #define F_CRM_JOIN_ID "join_id" //! \deprecated Do not use #define F_CRM_DC_LEAVING "dc-leaving" //! \deprecated Do not use #define F_CRM_ELECTION_ID "election-id" //! \deprecated Do not use #define F_CRM_ELECTION_AGE_S "election-age-sec" //! \deprecated Do not use #define F_CRM_ELECTION_AGE_US "election-age-nano-sec" //! \deprecated Do not use #define F_CRM_ELECTION_OWNER "election-owner" //! \deprecated Do not use #define F_CRM_TGRAPH "crm-tgraph-file" //! \deprecated Do not use #define F_CRM_TGRAPH_INPUT "crm-tgraph-in" //! \deprecated Do not use #define F_CRM_THROTTLE_MODE "crm-limit-mode" //! \deprecated Do not use #define F_CRM_THROTTLE_MAX "crm-limit-max" //! \deprecated Use \c PCMK_XA_RESULT instead #define XML_PING_ATTR_STATUS PCMK_XA_RESULT //! \deprecated Do not use #define XML_PING_ATTR_SYSFROM "crm_subsystem" //! \deprecated Do not use #define XML_PING_ATTR_CRMDSTATE "crmd_state" //! \deprecated Do not use #define XML_PING_ATTR_PACEMAKERDSTATE "pacemakerd_state" //! \deprecated Do not use #define XML_FAILCIB_ATTR_OBJTYPE "object_type" //! \deprecated Use \c PCMK_XA_OPERATION instead #define XML_FAILCIB_ATTR_OP PCMK_XA_OPERATION //! \deprecated Use \c PCMK_XA_OPERATION instead #define XML_LRM_ATTR_TASK PCMK_XA_OPERATION //! \deprecated Use \c PCMK_XA_OPERATION instead #define XML_EXPR_ATTR_OPERATION PCMK_XA_OPERATION //! \deprecated Use \c PCMK_XA_OPERATION instead #define XML_DIFF_OP PCMK_XA_OPERATION //! \deprecated Use \c PCMK_XA_REASON instead #define XML_FAILCIB_ATTR_REASON PCMK_XA_REASON //! \deprecated Use \c PCMK_META_TIMEOUT instead #define XML_ATTR_TIMEOUT PCMK_META_TIMEOUT //! \deprecated Use \c PCMK_META_TIMEOUT instead #define XML_ALERT_ATTR_TIMEOUT PCMK_META_TIMEOUT //! \deprecated Use \c PCMK_XA_PATH instead #define XML_ALERT_ATTR_PATH PCMK_XA_PATH //! \deprecated Use \c PCMK_XA_PATH instead #define XML_DIFF_PATH PCMK_XA_PATH //! \deprecated Use \c PCMK_META_TIMESTAMP_FORMAT instead #define XML_ALERT_ATTR_TSTAMP_FORMAT PCMK_META_TIMESTAMP_FORMAT //! \deprecated Use \c PCMK_META_INTERVAL instead #define XML_LRM_ATTR_INTERVAL PCMK_META_INTERVAL //! \deprecated Use \c PCMK_META_INTERVAL instead #define XML_LRM_ATTR_INTERVAL_MS PCMK_META_INTERVAL +//! \deprecated Do not use +#define XML_CIB_ATTR_REPLACE "replace" + #ifdef __cplusplus } #endif #endif // PCMK__CRM_MSG_XML_COMPAT__H diff --git a/include/crm_internal.h b/include/crm_internal.h index 4dbfee00f7..f812b35a08 100644 --- a/include/crm_internal.h +++ b/include/crm_internal.h @@ -1,152 +1,154 @@ /* * Copyright 2006-2024 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 CRM_INTERNAL__H # define CRM_INTERNAL__H # ifndef PCMK__CONFIG_H # define PCMK__CONFIG_H # include # endif # include /* Our minimum glib dependency is 2.42. Define that as both the minimum and * maximum glib APIs that are allowed (i.e. APIs that were already deprecated * in 2.42, and APIs introduced after 2.42, cannot be used by Pacemaker code). */ #define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_42 #define GLIB_VERSION_MAX_ALLOWED GLIB_VERSION_2_42 # include # include # include /* Public API headers can guard including deprecated API headers with this * symbol, thus preventing internal code (which includes this header) from using * deprecated APIs, while still allowing external code to use them by default. */ #define PCMK_ALLOW_DEPRECATED 0 # include # include # include # include # include # include # include # include # include # include #define N_(String) (String) #ifdef ENABLE_NLS # define _(String) gettext(String) #else # define _(String) (String) #endif /* * XML attribute names used only by internal code */ #define PCMK__XA_ATTR_DAMPENING "attr_dampening" #define PCMK__XA_ATTR_FORCE "attrd_is_force_write" #define PCMK__XA_ATTR_INTERVAL "attr_clear_interval" #define PCMK__XA_ATTR_IS_PRIVATE "attr_is_private" #define PCMK__XA_ATTR_IS_REMOTE "attr_is_remote" #define PCMK__XA_ATTR_NAME "attr_name" #define PCMK__XA_ATTR_NODE_ID "attr_host_id" #define PCMK__XA_ATTR_NODE_NAME "attr_host" #define PCMK__XA_ATTR_OPERATION "attr_clear_operation" #define PCMK__XA_ATTR_PATTERN "attr_regex" #define PCMK__XA_ATTR_RESOURCE "attr_resource" #define PCMK__XA_ATTR_SECTION "attr_section" #define PCMK__XA_ATTR_SET "attr_set" #define PCMK__XA_ATTR_SET_TYPE "attr_set_type" #define PCMK__XA_ATTR_SYNC_POINT "attr_sync_point" #define PCMK__XA_ATTR_USER "attr_user" #define PCMK__XA_ATTR_UUID "attr_key" #define PCMK__XA_ATTR_VALUE "attr_value" #define PCMK__XA_ATTR_VERSION "attr_version" #define PCMK__XA_ATTR_WRITER "attr_writer" #define PCMK__XA_CONFIG_ERRORS "config-errors" #define PCMK__XA_CONFIG_WARNINGS "config-warnings" #define PCMK__XA_CONFIRM "confirm" #define PCMK__XA_CONN_HOST "connection_host" #define PCMK__XA_CRMD "crmd" #define PCMK__XA_CRMD_STATE "crmd_state" #define PCMK__XA_CRM_HOST_TO "crm_host_to" #define PCMK__XA_CRM_LIMIT_MAX "crm-limit-max" #define PCMK__XA_CRM_LIMIT_MODE "crm-limit-mode" #define PCMK__XA_CRM_SUBSYSTEM "crm_subsystem" #define PCMK__XA_CRM_SYS_FROM "crm_sys_from" #define PCMK__XA_CRM_SYS_TO "crm_sys_to" #define PCMK__XA_CRM_TASK "crm_task" #define PCMK__XA_CRM_TGRAPH_IN "crm-tgraph-in" #define PCMK__XA_CRM_USER "crm_user" #define PCMK__XA_DC_LEAVING "dc-leaving" #define PCMK__XA_DIGEST "digest" #define PCMK__XA_ELECTION_AGE_SEC "election-age-sec" #define PCMK__XA_ELECTION_AGE_NANO_SEC "election-age-nano-sec" #define PCMK__XA_ELECTION_ID "election-id" #define PCMK__XA_ELECTION_OWNER "election-owner" #define PCMK__XA_EXPECTED "expected" #define PCMK__XA_FILE "file" #define PCMK__XA_GRAPH_ERRORS "graph-errors" #define PCMK__XA_GRAPH_WARNINGS "graph-warnings" #define PCMK__XA_IN_CCM "in_ccm" #define PCMK__XA_JOIN "join" #define PCMK__XA_JOIN_ID "join_id" #define PCMK__XA_LONG_ID "long-id" #define PCMK__XA_MODE "mode" #define PCMK__XA_NODE_START_STATE "node_start_state" #define PCMK__XA_OBJECT_TYPE "object_type" #define PCMK__XA_PACEMAKERD_STATE "pacemakerd_state" #define PCMK__XA_REAP "reap" #define PCMK__XA_SCHEMA "schema" #define PCMK__XA_SCHEMAS "schemas" #define PCMK__XA_SRC "src" #define PCMK__XA_SUBT "subt" // subtype #define PCMK__XA_T "t" // type #define PCMK__XA_TASK "task" #define PCMK__XA_TRANSITION_KEY "transition-key" #define PCMK__XA_TRANSITION_MAGIC "transition-magic" #define PCMK__XA_UPTIME "uptime" +// @COMPAT Deprecated since 2.1.6 +#define PCMK__XA_REPLACE "replace" /* * IPC service names that are only used internally */ # define PCMK__SERVER_BASED_RO "cib_ro" # define PCMK__SERVER_BASED_RW "cib_rw" # define PCMK__SERVER_BASED_SHM "cib_shm" /* * IPC commands that can be sent to Pacemaker daemons */ #define PCMK__ATTRD_CMD_PEER_REMOVE "peer-remove" #define PCMK__ATTRD_CMD_UPDATE "update" #define PCMK__ATTRD_CMD_UPDATE_BOTH "update-both" #define PCMK__ATTRD_CMD_UPDATE_DELAY "update-delay" #define PCMK__ATTRD_CMD_QUERY "query" #define PCMK__ATTRD_CMD_REFRESH "refresh" #define PCMK__ATTRD_CMD_FLUSH "flush" #define PCMK__ATTRD_CMD_SYNC "sync" #define PCMK__ATTRD_CMD_SYNC_RESPONSE "sync-response" #define PCMK__ATTRD_CMD_CLEAR_FAILURE "clear-failure" #define PCMK__ATTRD_CMD_CONFIRM "confirm" #define PCMK__CONTROLD_CMD_NODES "list-nodes" #endif /* CRM_INTERNAL__H */ diff --git a/lib/cib/cib_ops.c b/lib/cib/cib_ops.c index 4c125e8640..e4e7b93411 100644 --- a/lib/cib/cib_ops.c +++ b/lib/cib/cib_ops.c @@ -1,1006 +1,1006 @@ /* * Copyright 2004-2024 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. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // @TODO: Free this via crm_exit() when libcib gets merged with libcrmcommon static GHashTable *operation_table = NULL; static const cib__operation_t cib_ops[] = { { PCMK__CIB_REQUEST_ABS_DELETE, cib__op_abs_delete, cib__op_attr_modifies|cib__op_attr_privileged }, { PCMK__CIB_REQUEST_APPLY_PATCH, cib__op_apply_patch, cib__op_attr_modifies |cib__op_attr_privileged |cib__op_attr_transaction }, { PCMK__CIB_REQUEST_BUMP, cib__op_bump, cib__op_attr_modifies |cib__op_attr_privileged |cib__op_attr_transaction }, { PCMK__CIB_REQUEST_COMMIT_TRANSACT, cib__op_commit_transact, cib__op_attr_modifies |cib__op_attr_privileged |cib__op_attr_replaces |cib__op_attr_writes_through }, { PCMK__CIB_REQUEST_CREATE, cib__op_create, cib__op_attr_modifies |cib__op_attr_privileged |cib__op_attr_transaction }, { PCMK__CIB_REQUEST_DELETE, cib__op_delete, cib__op_attr_modifies |cib__op_attr_privileged |cib__op_attr_transaction }, { PCMK__CIB_REQUEST_ERASE, cib__op_erase, cib__op_attr_modifies |cib__op_attr_privileged |cib__op_attr_replaces |cib__op_attr_transaction }, { PCMK__CIB_REQUEST_IS_PRIMARY, cib__op_is_primary, cib__op_attr_privileged }, { PCMK__CIB_REQUEST_MODIFY, cib__op_modify, cib__op_attr_modifies |cib__op_attr_privileged |cib__op_attr_transaction }, { PCMK__CIB_REQUEST_NOOP, cib__op_noop, cib__op_attr_none }, { CRM_OP_PING, cib__op_ping, cib__op_attr_none }, { // @COMPAT: Drop cib__op_attr_modifies when we drop legacy mode support PCMK__CIB_REQUEST_PRIMARY, cib__op_primary, cib__op_attr_modifies|cib__op_attr_privileged|cib__op_attr_local }, { PCMK__CIB_REQUEST_QUERY, cib__op_query, cib__op_attr_none }, { PCMK__CIB_REQUEST_REPLACE, cib__op_replace, cib__op_attr_modifies |cib__op_attr_privileged |cib__op_attr_replaces |cib__op_attr_writes_through |cib__op_attr_transaction }, { PCMK__CIB_REQUEST_SECONDARY, cib__op_secondary, cib__op_attr_privileged|cib__op_attr_local }, { PCMK__CIB_REQUEST_SHUTDOWN, cib__op_shutdown, cib__op_attr_privileged }, { PCMK__CIB_REQUEST_SYNC_TO_ALL, cib__op_sync_all, cib__op_attr_privileged }, { PCMK__CIB_REQUEST_SYNC_TO_ONE, cib__op_sync_one, cib__op_attr_privileged }, { PCMK__CIB_REQUEST_UPGRADE, cib__op_upgrade, cib__op_attr_modifies |cib__op_attr_privileged |cib__op_attr_writes_through |cib__op_attr_transaction }, { PCMK__CIB_REQUEST_SCHEMAS, cib__op_schemas, cib__op_attr_local } }; /*! * \internal * \brief Get the \c cib__operation_t object for a given CIB operation name * * \param[in] op CIB operation name * \param[out] operation Where to store CIB operation object * * \return Standard Pacemaker return code */ int cib__get_operation(const char *op, const cib__operation_t **operation) { CRM_ASSERT((op != NULL) && (operation != NULL)); if (operation_table == NULL) { operation_table = pcmk__strkey_table(NULL, NULL); for (int lpc = 0; lpc < PCMK__NELEM(cib_ops); lpc++) { const cib__operation_t *oper = &(cib_ops[lpc]); g_hash_table_insert(operation_table, (gpointer) oper->name, (gpointer) oper); } } *operation = g_hash_table_lookup(operation_table, op); if (*operation == NULL) { crm_err("Operation %s is invalid", op); return EINVAL; } return pcmk_rc_ok; } int cib_process_query(const char *op, int options, const char *section, xmlNode * req, xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib, xmlNode ** answer) { xmlNode *obj_root = NULL; int result = pcmk_ok; crm_trace("Processing %s for %s section", op, pcmk__s(section, "unspecified")); if (options & cib_xpath) { return cib_process_xpath(op, options, section, req, input, existing_cib, result_cib, answer); } CRM_CHECK(*answer == NULL, free_xml(*answer)); *answer = NULL; if (pcmk__str_eq(XML_CIB_TAG_SECTION_ALL, section, pcmk__str_casei)) { section = NULL; } obj_root = pcmk_find_cib_element(existing_cib, section); if (obj_root == NULL) { result = -ENXIO; } else if (options & cib_no_children) { xmlNode *shallow = create_xml_node(*answer, (const char *) obj_root->name); copy_in_properties(shallow, obj_root); *answer = shallow; } else { *answer = obj_root; } if (result == pcmk_ok && *answer == NULL) { crm_err("Error creating query response"); result = -ENOMSG; } return result; } static int update_counter(xmlNode *xml_obj, const char *field, bool reset) { char *new_value = NULL; char *old_value = NULL; int int_value = -1; if (!reset && crm_element_value(xml_obj, field) != NULL) { old_value = crm_element_value_copy(xml_obj, field); } if (old_value != NULL) { int_value = atoi(old_value); new_value = pcmk__itoa(++int_value); } else { new_value = strdup("1"); CRM_ASSERT(new_value != NULL); } crm_trace("Update %s from %s to %s", field, pcmk__s(old_value, "unset"), new_value); crm_xml_add(xml_obj, field, new_value); free(new_value); free(old_value); return pcmk_ok; } 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 result = pcmk_ok; crm_trace("Processing \"%s\" event", op); if (*result_cib != existing_cib) { free_xml(*result_cib); } *result_cib = createEmptyCib(0); copy_in_properties(*result_cib, existing_cib); update_counter(*result_cib, PCMK_XA_ADMIN_EPOCH, false); *answer = NULL; return result; } int cib_process_upgrade(const char *op, int options, const char *section, xmlNode * req, xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib, xmlNode ** answer) { int rc = 0; int new_version = 0; int current_version = 0; int max_version = 0; const char *max = crm_element_value(req, F_CIB_SCHEMA_MAX); const char *value = crm_element_value(existing_cib, PCMK_XA_VALIDATE_WITH); *answer = NULL; crm_trace("Processing \"%s\" event with max=%s", op, max); if (value != NULL) { current_version = get_schema_version(value); } if (max) { max_version = get_schema_version(max); } rc = update_validation(result_cib, &new_version, max_version, TRUE, !(options & cib_verbose)); if (new_version > current_version) { update_counter(*result_cib, PCMK_XA_ADMIN_EPOCH, false); update_counter(*result_cib, PCMK_XA_EPOCH, true); update_counter(*result_cib, PCMK_XA_NUM_UPDATES, true); return pcmk_ok; } return rc; } 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 result = pcmk_ok; crm_trace("Processing %s for epoch='%s'", op, pcmk__s(crm_element_value(existing_cib, PCMK_XA_EPOCH), "")); *answer = NULL; update_counter(*result_cib, PCMK_XA_EPOCH, false); return result; } 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 result = pcmk_ok; crm_trace("Processing %s for %s section", op, pcmk__s(section, "unspecified")); if (options & cib_xpath) { return cib_process_xpath(op, options, section, req, input, existing_cib, result_cib, answer); } *answer = NULL; if (input == NULL) { return -EINVAL; } if (pcmk__str_eq(XML_CIB_TAG_SECTION_ALL, section, pcmk__str_casei)) { section = NULL; } else if (pcmk__xe_is(input, section)) { section = NULL; } if (pcmk__xe_is(input, XML_TAG_CIB)) { int updates = 0; int epoch = 0; int admin_epoch = 0; int replace_updates = 0; int replace_epoch = 0; int replace_admin_epoch = 0; const char *reason = NULL; const char *peer = crm_element_value(req, PCMK__XA_SRC); const char *digest = crm_element_value(req, PCMK__XA_DIGEST); if (digest) { const char *version = crm_element_value(req, PCMK_XA_CRM_FEATURE_SET); char *digest_verify = calculate_xml_versioned_digest(input, FALSE, TRUE, version ? version : CRM_FEATURE_SET); if (!pcmk__str_eq(digest_verify, digest, pcmk__str_casei)) { crm_err("Digest mis-match on replace from %s: %s vs. %s (expected)", peer, digest_verify, digest); reason = "digest mismatch"; } else { crm_info("Digest matched on replace from %s: %s", peer, digest); } free(digest_verify); } else { crm_trace("No digest to verify"); } cib_version_details(existing_cib, &admin_epoch, &epoch, &updates); cib_version_details(input, &replace_admin_epoch, &replace_epoch, &replace_updates); if (replace_admin_epoch < admin_epoch) { reason = PCMK_XA_ADMIN_EPOCH; } else if (replace_admin_epoch > admin_epoch) { /* no more checks */ } else if (replace_epoch < epoch) { reason = PCMK_XA_EPOCH; } else if (replace_epoch > epoch) { /* no more checks */ } else if (replace_updates < updates) { reason = PCMK_XA_NUM_UPDATES; } if (reason != NULL) { crm_info("Replacement %d.%d.%d from %s not applied to %d.%d.%d:" " current %s is greater than the replacement", replace_admin_epoch, replace_epoch, replace_updates, peer, admin_epoch, epoch, updates, reason); result = -pcmk_err_old_data; } else { crm_info("Replaced %d.%d.%d with %d.%d.%d from %s", admin_epoch, epoch, updates, replace_admin_epoch, replace_epoch, replace_updates, peer); } if (*result_cib != existing_cib) { free_xml(*result_cib); } *result_cib = copy_xml(input); } else { xmlNode *obj_root = NULL; gboolean ok = TRUE; obj_root = pcmk_find_cib_element(*result_cib, section); ok = replace_xml_child(NULL, obj_root, input, FALSE); if (ok == FALSE) { crm_trace("No matching object to replace"); result = -ENXIO; } } return result; } int cib_process_delete(const char *op, int options, const char *section, xmlNode * req, xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib, xmlNode ** answer) { xmlNode *obj_root = NULL; crm_trace("Processing \"%s\" event", op); if (options & cib_xpath) { return cib_process_xpath(op, options, section, req, input, existing_cib, result_cib, answer); } if (input == NULL) { crm_err("Cannot perform modification with no data"); return -EINVAL; } obj_root = pcmk_find_cib_element(*result_cib, section); if (pcmk__xe_is(input, section)) { xmlNode *child = NULL; for (child = pcmk__xml_first_child(input); child; child = pcmk__xml_next(child)) { if (replace_xml_child(NULL, obj_root, child, TRUE) == FALSE) { crm_trace("No matching object to delete: %s=%s", child->name, ID(child)); } } } else if (replace_xml_child(NULL, obj_root, input, TRUE) == FALSE) { crm_trace("No matching object to delete: %s=%s", input->name, ID(input)); } return pcmk_ok; } int cib_process_modify(const char *op, int options, const char *section, xmlNode * req, xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib, xmlNode ** answer) { xmlNode *obj_root = NULL; crm_trace("Processing \"%s\" event", op); if (options & cib_xpath) { return cib_process_xpath(op, options, section, req, input, existing_cib, result_cib, answer); } if (input == NULL) { crm_err("Cannot perform modification with no data"); return -EINVAL; } obj_root = pcmk_find_cib_element(*result_cib, section); if (obj_root == NULL) { xmlNode *tmp_section = NULL; const char *path = pcmk_cib_parent_name_for(section); if (path == NULL) { return -EINVAL; } tmp_section = create_xml_node(NULL, section); cib_process_xpath(PCMK__CIB_REQUEST_CREATE, 0, path, NULL, tmp_section, NULL, result_cib, answer); free_xml(tmp_section); obj_root = pcmk_find_cib_element(*result_cib, section); } CRM_CHECK(obj_root != NULL, return -EINVAL); if (update_xml_child(obj_root, input) == FALSE) { if (options & cib_can_create) { add_node_copy(obj_root, input); } else { return -ENXIO; } } // @COMPAT cib_mixed_update is deprecated as of 2.1.7 if (pcmk_is_set(options, cib_mixed_update)) { int max = 0, lpc; xmlXPathObjectPtr xpathObj = xpath_search(*result_cib, "//@__delete__"); if (xpathObj) { max = numXpathResults(xpathObj); crm_log_xml_trace(*result_cib, "Mixed result"); } for (lpc = 0; lpc < max; lpc++) { xmlNode *match = getXpathResult(xpathObj, lpc); xmlChar *match_path = xmlGetNodePath(match); crm_debug("Destroying %s", match_path); free(match_path); free_xml(match); } freeXpathObject(xpathObj); } return pcmk_ok; } static int update_cib_object(xmlNode * parent, xmlNode * update) { int result = pcmk_ok; xmlNode *target = NULL; xmlNode *a_child = NULL; const char *replace = NULL; const char *object_id = NULL; const char *object_name = NULL; CRM_CHECK(update != NULL, return -EINVAL); CRM_CHECK(parent != NULL, return -EINVAL); object_name = (const char *) update->name; CRM_CHECK(object_name != NULL, return -EINVAL); object_id = ID(update); crm_trace("Processing update for <%s%s%s%s>", object_name, ((object_id == NULL)? "" : " " PCMK_XA_ID "='"), pcmk__s(object_id, ""), ((object_id == NULL)? "" : "'")); if (object_id == NULL) { /* placeholder object */ target = find_xml_node(parent, object_name, FALSE); } else { target = pcmk__xe_match(parent, object_name, PCMK_XA_ID, object_id); } if (target == NULL) { target = create_xml_node(parent, object_name); } crm_trace("Found node <%s%s%s%s> to update", object_name, ((object_id == NULL)? "" : " " PCMK_XA_ID "='"), pcmk__s(object_id, ""), ((object_id == NULL)? "" : "'")); - // @COMPAT: XML_CIB_ATTR_REPLACE is unused internally. Remove at break. - replace = crm_element_value(update, XML_CIB_ATTR_REPLACE); + // @COMPAT PCMK__XA__REPLACE is deprecated since 2.1.6 + replace = crm_element_value(update, PCMK__XA_REPLACE); if (replace != NULL) { int last = 0; int len = strlen(replace); for (int lpc = 0; lpc <= len; ++lpc) { if (replace[lpc] == ',' || replace[lpc] == 0) { if (last != lpc) { char *replace_item = strndup(replace + last, lpc - last); xmlNode *remove = find_xml_node(target, replace_item, FALSE); if (remove != NULL) { crm_trace("Replacing node <%s> in <%s>", replace_item, target->name); free_xml(remove); } free(replace_item); } last = lpc + 1; } } - xml_remove_prop(update, XML_CIB_ATTR_REPLACE); - xml_remove_prop(target, XML_CIB_ATTR_REPLACE); + xml_remove_prop(update, PCMK__XA_REPLACE); + xml_remove_prop(target, PCMK__XA_REPLACE); } copy_in_properties(target, update); if (xml_acl_denied(target)) { crm_notice("Cannot update <%s " PCMK_XA_ID "=%s>", pcmk__s(object_name, ""), pcmk__s(object_id, "")); return -EACCES; } crm_trace("Processing children of <%s%s%s%s>", object_name, ((object_id == NULL)? "" : " " PCMK_XA_ID "='"), pcmk__s(object_id, ""), ((object_id == NULL)? "" : "'")); for (a_child = pcmk__xml_first_child(update); a_child != NULL; a_child = pcmk__xml_next(a_child)) { int tmp_result = 0; crm_trace("Updating child <%s%s%s%s>", a_child->name, ((ID(a_child) == NULL)? "" : " " PCMK_XA_ID "='"), pcmk__s(ID(a_child), ""), ((ID(a_child) == NULL)? "" : "'")); tmp_result = update_cib_object(target, a_child); /* only the first error is likely to be interesting */ if (tmp_result != pcmk_ok) { crm_err("Error updating child <%s%s%s%s>", a_child->name, ((ID(a_child) == NULL)? "" : " " PCMK_XA_ID "='"), pcmk__s(ID(a_child), ""), ((ID(a_child) == NULL)? "" : "'")); if (result == pcmk_ok) { result = tmp_result; } } } crm_trace("Finished handling update for <%s%s%s%s>", object_name, ((object_id == NULL)? "" : " " PCMK_XA_ID "='"), pcmk__s(object_id, ""), ((object_id == NULL)? "" : "'")); return result; } static int add_cib_object(xmlNode * parent, xmlNode * new_obj) { const char *object_name = NULL; const char *object_id = NULL; xmlNode *equiv_node = NULL; if ((parent == NULL) || (new_obj == NULL)) { return -EINVAL; } object_name = (const char *) new_obj->name; if (object_name == NULL) { return -EINVAL; } object_id = ID(new_obj); crm_trace("Processing creation of <%s%s%s%s>", object_name, ((object_id == NULL)? "" : " " PCMK_XA_ID "='"), pcmk__s(object_id, ""), ((object_id == NULL)? "" : "'")); if (object_id == NULL) { equiv_node = find_xml_node(parent, object_name, FALSE); } else { equiv_node = pcmk__xe_match(parent, object_name, PCMK_XA_ID, object_id); } if (equiv_node != NULL) { return -EEXIST; } return update_cib_object(parent, new_obj); } static bool update_results(xmlNode *failed, xmlNode *target, const char *operation, int return_code) { xmlNode *xml_node = NULL; bool was_error = false; const char *error_msg = NULL; if (return_code != pcmk_ok) { error_msg = pcmk_strerror(return_code); was_error = true; xml_node = create_xml_node(failed, XML_FAIL_TAG_CIB); add_node_copy(xml_node, target); crm_xml_add(xml_node, PCMK_XA_ID, ID(target)); crm_xml_add(xml_node, PCMK__XA_OBJECT_TYPE, (const char *) target->name); crm_xml_add(xml_node, PCMK_XA_OPERATION, operation); crm_xml_add(xml_node, PCMK_XA_REASON, error_msg); crm_warn("Action %s failed: %s (cde=%d)", operation, error_msg, return_code); } return was_error; } int cib_process_create(const char *op, int options, const char *section, xmlNode * req, xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib, xmlNode ** answer) { xmlNode *failed = NULL; int result = pcmk_ok; xmlNode *update_section = NULL; crm_trace("Processing %s for %s section", op, pcmk__s(section, "unspecified")); if (pcmk__str_eq(XML_CIB_TAG_SECTION_ALL, section, pcmk__str_casei)) { section = NULL; } else if (pcmk__str_eq(XML_TAG_CIB, section, pcmk__str_casei)) { section = NULL; } else if (pcmk__xe_is(input, XML_TAG_CIB)) { section = NULL; } CRM_CHECK(strcmp(op, PCMK__CIB_REQUEST_CREATE) == 0, return -EINVAL); if (input == NULL) { crm_err("Cannot perform modification with no data"); return -EINVAL; } if (section == NULL) { return cib_process_modify(op, options, section, req, input, existing_cib, result_cib, answer); } failed = create_xml_node(NULL, XML_TAG_FAILED); update_section = pcmk_find_cib_element(*result_cib, section); if (pcmk__xe_is(input, section)) { xmlNode *a_child = NULL; for (a_child = pcmk__xml_first_child(input); a_child != NULL; a_child = pcmk__xml_next(a_child)) { result = add_cib_object(update_section, a_child); if (update_results(failed, a_child, op, result)) { break; } } } else { result = add_cib_object(update_section, input); update_results(failed, input, op, result); } if ((result == pcmk_ok) && (failed->children != NULL)) { result = -EINVAL; } if (result != pcmk_ok) { crm_log_xml_err(failed, "CIB Update failures"); *answer = failed; } else { free_xml(failed); } return result; } int cib_process_diff(const char *op, int options, const char *section, xmlNode * req, xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib, xmlNode ** answer) { const char *originator = NULL; if (req != NULL) { originator = crm_element_value(req, PCMK__XA_SRC); } crm_trace("Processing \"%s\" event from %s%s", op, originator, (pcmk_is_set(options, cib_force_diff)? " (global update)" : "")); if (*result_cib != existing_cib) { free_xml(*result_cib); } *result_cib = copy_xml(existing_cib); return xml_apply_patchset(*result_cib, input, TRUE); } // @COMPAT: v1-only bool cib__config_changed_v1(xmlNode *last, xmlNode *next, xmlNode **diff) { int lpc = 0, max = 0; bool config_changes = false; xmlXPathObject *xpathObj = NULL; int format = 1; CRM_ASSERT(diff != NULL); if (*diff == NULL && last != NULL && next != NULL) { *diff = diff_xml_object(last, next, FALSE); } if (*diff == NULL) { goto done; } crm_element_value_int(*diff, PCMK_XA_FORMAT, &format); CRM_LOG_ASSERT(format == 1); xpathObj = xpath_search(*diff, "//" XML_CIB_TAG_CONFIGURATION); if (numXpathResults(xpathObj) > 0) { config_changes = true; goto done; } freeXpathObject(xpathObj); /* * Do not check XML_TAG_DIFF_ADDED "//" XML_TAG_CIB * This always contains every field and would produce a false positive * every time if the checked value existed */ xpathObj = xpath_search(*diff, "//" XML_TAG_DIFF_REMOVED "//" XML_TAG_CIB); max = numXpathResults(xpathObj); for (lpc = 0; lpc < max; lpc++) { xmlNode *top = getXpathResult(xpathObj, lpc); if (crm_element_value(top, PCMK_XA_EPOCH) != NULL) { config_changes = true; goto done; } if (crm_element_value(top, PCMK_XA_ADMIN_EPOCH) != NULL) { config_changes = true; goto done; } if (crm_element_value(top, PCMK_XA_VALIDATE_WITH) != NULL) { config_changes = true; goto done; } if (crm_element_value(top, PCMK_XA_CRM_FEATURE_SET) != NULL) { config_changes = true; goto done; } if (crm_element_value(top, "remote-clear-port") != NULL) { config_changes = true; goto done; } if (crm_element_value(top, "remote-tls-port") != NULL) { config_changes = true; goto done; } } done: freeXpathObject(xpathObj); return config_changes; } int cib_process_xpath(const char *op, int options, const char *section, const xmlNode *req, xmlNode *input, xmlNode *existing_cib, xmlNode **result_cib, xmlNode **answer) { int lpc = 0; int max = 0; int rc = pcmk_ok; bool is_query = pcmk__str_eq(op, PCMK__CIB_REQUEST_QUERY, pcmk__str_none); xmlXPathObjectPtr xpathObj = NULL; crm_trace("Processing \"%s\" event", op); if (is_query) { xpathObj = xpath_search(existing_cib, section); } else { xpathObj = xpath_search(*result_cib, section); } max = numXpathResults(xpathObj); if ((max < 1) && pcmk__str_eq(op, PCMK__CIB_REQUEST_DELETE, pcmk__str_none)) { crm_debug("%s was already removed", section); } else if (max < 1) { crm_debug("%s: %s does not exist", op, section); rc = -ENXIO; } else if (is_query) { if (max > 1) { *answer = create_xml_node(NULL, "xpath-query"); } } if (pcmk_is_set(options, cib_multiple) && pcmk__str_eq(op, PCMK__CIB_REQUEST_DELETE, pcmk__str_none)) { dedupXpathResults(xpathObj); } for (lpc = 0; lpc < max; lpc++) { xmlChar *path = NULL; xmlNode *match = getXpathResult(xpathObj, lpc); if (match == NULL) { continue; } path = xmlGetNodePath(match); crm_debug("Processing %s op for %s with %s", op, section, path); free(path); if (pcmk__str_eq(op, PCMK__CIB_REQUEST_DELETE, pcmk__str_none)) { if (match == *result_cib) { /* Attempting to delete the whole "/cib" */ crm_warn("Cannot perform %s for %s: The xpath is addressing the whole /cib", op, section); rc = -EINVAL; break; } free_xml(match); if ((options & cib_multiple) == 0) { break; } } else if (pcmk__str_eq(op, PCMK__CIB_REQUEST_MODIFY, pcmk__str_none)) { if (update_xml_child(match, input) == FALSE) { rc = -ENXIO; } else if ((options & cib_multiple) == 0) { break; } } else if (pcmk__str_eq(op, PCMK__CIB_REQUEST_CREATE, pcmk__str_none)) { add_node_copy(match, input); break; } else if (pcmk__str_eq(op, PCMK__CIB_REQUEST_QUERY, pcmk__str_none)) { if (options & cib_no_children) { xmlNode *shallow = create_xml_node(*answer, (const char *) match->name); copy_in_properties(shallow, match); if (*answer == NULL) { *answer = shallow; } } else if (options & cib_xpath_address) { char *path = NULL; xmlNode *parent = match; while (parent && parent->type == XML_ELEMENT_NODE) { const char *id = crm_element_value(parent, PCMK_XA_ID); char *new_path = NULL; if (id) { new_path = crm_strdup_printf("/%s[@" PCMK_XA_ID "='%s']" "%s", parent->name, id, pcmk__s(path, "")); } else { new_path = crm_strdup_printf("/%s%s", parent->name, pcmk__s(path, "")); } free(path); path = new_path; parent = parent->parent; } crm_trace("Got: %s", path); if (*answer == NULL) { *answer = create_xml_node(NULL, "xpath-query"); } parent = create_xml_node(*answer, "xpath-query-path"); crm_xml_add(parent, PCMK_XA_ID, path); free(path); } else if (*answer) { add_node_copy(*answer, match); } else { *answer = match; } } else if (pcmk__str_eq(op, PCMK__CIB_REQUEST_REPLACE, pcmk__str_none)) { xmlNode *parent = match->parent; free_xml(match); if (input != NULL) { add_node_copy(parent, input); } if ((options & cib_multiple) == 0) { break; } } } freeXpathObject(xpathObj); return rc; }