From 3c6ce3b143472bb9977cf0739edefe8f49a763dc Mon Sep 17 00:00:00 2001 From: Ken Gaillot Date: Jun 10 2020 17:56:11 +0000 Subject: Refactor: controller: move erase_status_tag() to controld_based.c --- diff --git a/daemons/controld/controld_based.c b/daemons/controld/controld_based.c index e6a4612..1db5650 100644 --- a/daemons/controld/controld_based.c +++ b/daemons/controld/controld_based.c @@ -168,3 +168,41 @@ controld_action_is_recordable(const char *action) } return TRUE; } + +static void +erase_xpath_callback(xmlNode *msg, int call_id, int rc, xmlNode *output, + void *user_data) +{ + char *xpath = user_data; + + if (rc == 0) { + crm_debug("Deletion of '%s' from CIB (via CIB call %d) succeeded", + xpath, call_id); + } else { + crm_warn("Deletion of '%s' from CIB (via CIB call %d) failed: %s " + CRM_XS " rc=%d", xpath, call_id, pcmk_strerror(rc), rc); + } +} + +#define XPATH_STATUS_TAG "//node_state[@uname='%s']/%s" + +void +erase_status_tag(const char *uname, const char *tag, int options) +{ + CRM_CHECK(uname != NULL, return); + + if (fsa_cib_conn == NULL) { + crm_warn("Unable to delete CIB '%s' section for node %s: " + "no CIB connection", tag, uname); + } else { + int call_id; + char *xpath = crm_strdup_printf(XPATH_STATUS_TAG, uname, tag); + + options |= cib_quorum_override|cib_xpath; + call_id = fsa_cib_conn->cmds->remove(fsa_cib_conn, xpath, NULL, options); + crm_info("Deleting CIB '%s' section for node %s (via CIB call %d) " + CRM_XS " xpath=%s", tag, uname, call_id, xpath); + fsa_register_cib_callback(call_id, FALSE, xpath, erase_xpath_callback); + // CIB library handles freeing xpath + } +} diff --git a/daemons/controld/controld_utils.c b/daemons/controld/controld_utils.c index bb8ace9..4ed6aeb 100644 --- a/daemons/controld/controld_utils.c +++ b/daemons/controld/controld_utils.c @@ -751,43 +751,6 @@ update_dc(xmlNode * msg) return TRUE; } -static void -erase_xpath_callback(xmlNode * msg, int call_id, int rc, xmlNode * output, void *user_data) -{ - char *xpath = user_data; - - if (rc == 0) { - crm_debug("Deletion of '%s' from CIB (via CIB call %d) succeeded", - xpath, call_id); - } else { - crm_warn("Deletion of '%s' from CIB (via CIB call %d) failed: %s " - CRM_XS " rc=%d", xpath, call_id, pcmk_strerror(rc), rc); - } -} - -#define XPATH_STATUS_TAG "//node_state[@uname='%s']/%s" - -void -erase_status_tag(const char *uname, const char *tag, int options) -{ - CRM_CHECK(uname != NULL, return); - - if (fsa_cib_conn == NULL) { - crm_warn("Unable to delete CIB '%s' section for node %s: " - "no CIB connection", tag, uname); - } else { - int call_id; - char *xpath = crm_strdup_printf(XPATH_STATUS_TAG, uname, tag); - - options |= cib_quorum_override|cib_xpath; - call_id = fsa_cib_conn->cmds->remove(fsa_cib_conn, xpath, NULL, options); - crm_info("Deleting CIB '%s' section for node %s (via CIB call %d) " - CRM_XS " xpath=%s", tag, uname, call_id, xpath); - fsa_register_cib_callback(call_id, FALSE, xpath, erase_xpath_callback); - // CIB library handles freeing xpath - } -} - void crmd_peer_down(crm_node_t *peer, bool full) { if(full && peer->state == NULL) {