Skip to content

Commit

Permalink
Merge pull request #3804 from nrwahl2/nrwahl2-refactor
Browse files Browse the repository at this point in the history
Refactor: various: Drop pcmk__xe_add_node()
  • Loading branch information
clumens authored Jan 16, 2025
2 parents 47b8613 + 6675f20 commit 4540673
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 116 deletions.
8 changes: 4 additions & 4 deletions daemons/attrd/attrd_ipc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2024 the Pacemaker project contributors
* Copyright 2004-2025 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
Expand Down Expand Up @@ -66,7 +66,7 @@ static xmlNode *build_query_reply(const char *attr, const char *host)
if (host) {
v = g_hash_table_lookup(a->values, host);
host_value = pcmk__xe_create(reply, PCMK_XE_NODE);
pcmk__xe_add_node(host_value, host, 0);
crm_xml_add(host_value, PCMK__XA_ATTR_HOST, host);
crm_xml_add(host_value, PCMK__XA_ATTR_VALUE,
(v? v->current : NULL));

Expand All @@ -77,7 +77,7 @@ static xmlNode *build_query_reply(const char *attr, const char *host)
g_hash_table_iter_init(&iter, a->values);
while (g_hash_table_iter_next(&iter, NULL, (gpointer *) &v)) {
host_value = pcmk__xe_create(reply, PCMK_XE_NODE);
pcmk__xe_add_node(host_value, v->nodename, 0);
crm_xml_add(host_value, PCMK__XA_ATTR_HOST, v->nodename);
crm_xml_add(host_value, PCMK__XA_ATTR_VALUE, v->current);
}
}
Expand Down Expand Up @@ -166,7 +166,7 @@ attrd_client_peer_remove(pcmk__request_t *request)
host_alloc = pcmk__cluster_node_name(nodeid);
host = host_alloc;
}
pcmk__xe_add_node(xml, host, 0);
crm_xml_add(xml, PCMK__XA_ATTR_HOST, host);
}
}

Expand Down
15 changes: 1 addition & 14 deletions include/crm/common/internal.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2024 the Pacemaker project contributors
* Copyright 2015-2025 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
Expand Down Expand Up @@ -64,19 +64,6 @@ int pcmk__add_mainloop_ipc(crm_ipc_t *ipc, int priority, void *userdata,
guint pcmk__mainloop_timer_get_period(const mainloop_timer_t *timer);


/* internal node-related XML utilities (from nodes.c) */

/*!
* \internal
* \brief Add local node name and ID to an XML node
*
* \param[in,out] request XML node to modify
* \param[in] node The local node's name
* \param[in] nodeid The local node's ID (can be 0)
*/
void pcmk__xe_add_node(xmlNode *xml, const char *node, int nodeid);


/* internal name/value utilities (from nvpair.c) */

int pcmk__scan_nvpair(const char *input, char **name, char **value);
Expand Down
12 changes: 6 additions & 6 deletions lib/common/ipc_attrd.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2011-2024 the Pacemaker project contributors
* Copyright 2011-2025 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
Expand Down Expand Up @@ -201,7 +201,7 @@ pcmk__attrd_api_clear_failures(pcmk_ipc_api_t *api, const char *node,
pcmk__s(resource, "all resources"), pcmk__s(node, "all nodes"));

crm_xml_add(request, PCMK_XA_TASK, PCMK__ATTRD_CMD_CLEAR_FAILURE);
pcmk__xe_add_node(request, node, 0);
crm_xml_add(request, PCMK__XA_ATTR_HOST, node);
crm_xml_add(request, PCMK__XA_ATTR_RESOURCE, resource);
crm_xml_add(request, PCMK__XA_ATTR_CLEAR_OPERATION, operation);
crm_xml_add(request, PCMK__XA_ATTR_CLEAR_INTERVAL, interval_spec);
Expand Down Expand Up @@ -257,7 +257,7 @@ pcmk__attrd_api_purge(pcmk_ipc_api_t *api, const char *node, bool reap)

crm_xml_add(request, PCMK_XA_TASK, PCMK__ATTRD_CMD_PEER_REMOVE);
pcmk__xe_set_bool_attr(request, PCMK__XA_REAP, reap);
pcmk__xe_add_node(request, node, 0);
crm_xml_add(request, PCMK__XA_ATTR_HOST, node);

rc = connect_and_send_attrd_request(api, request);

Expand Down Expand Up @@ -297,7 +297,7 @@ pcmk__attrd_api_query(pcmk_ipc_api_t *api, const char *node, const char *name,

crm_xml_add(request, PCMK__XA_ATTR_NAME, name);
crm_xml_add(request, PCMK_XA_TASK, PCMK__ATTRD_CMD_QUERY);
pcmk__xe_add_node(request, node, 0);
crm_xml_add(request, PCMK__XA_ATTR_HOST, node);

rc = connect_and_send_attrd_request(api, request);
pcmk__xml_free(request);
Expand All @@ -321,7 +321,7 @@ pcmk__attrd_api_refresh(pcmk_ipc_api_t *api, const char *node)
request = create_attrd_op(NULL);

crm_xml_add(request, PCMK_XA_TASK, PCMK__ATTRD_CMD_REFRESH);
pcmk__xe_add_node(request, node, 0);
crm_xml_add(request, PCMK__XA_ATTR_HOST, node);

rc = connect_and_send_attrd_request(api, request);

Expand Down Expand Up @@ -361,7 +361,7 @@ populate_update_op(xmlNode *op, const char *node, const char *name, const char *

crm_xml_add(op, PCMK__XA_ATTR_VALUE, value);
crm_xml_add(op, PCMK__XA_ATTR_DAMPENING, dampen);
pcmk__xe_add_node(op, node, 0);
crm_xml_add(op, PCMK__XA_ATTR_HOST, node);
crm_xml_add(op, PCMK__XA_ATTR_SET, set);
crm_xml_add_int(op, PCMK__XA_ATTR_IS_REMOTE,
pcmk_is_set(options, pcmk__node_attr_remote));
Expand Down
7 changes: 5 additions & 2 deletions lib/common/ipc_client.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2024 the Pacemaker project contributors
* Copyright 2004-2025 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
Expand Down Expand Up @@ -754,7 +754,10 @@ create_purge_node_request(const pcmk_ipc_api_t *api, const char *node_name,
crm_xml_add(request, PCMK__XA_SRC, crm_system_name);
crm_xml_add(request, PCMK_XA_TASK, PCMK__ATTRD_CMD_PEER_REMOVE);
pcmk__xe_set_bool_attr(request, PCMK__XA_REAP, true);
pcmk__xe_add_node(request, node_name, nodeid);
crm_xml_add(request, PCMK__XA_ATTR_HOST, node_name);
if (nodeid > 0) {
crm_xml_add_int(request, PCMK__XA_ATTR_HOST_ID, nodeid);
}
break;

case pcmk_ipc_controld:
Expand Down
16 changes: 1 addition & 15 deletions lib/common/nodes.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022-2024 the Pacemaker project contributors
* Copyright 2022-2025 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
Expand Down Expand Up @@ -185,20 +185,6 @@ pcmk_foreach_active_resource(pcmk_node_t *node,
return result;
}

void
pcmk__xe_add_node(xmlNode *xml, const char *node, int nodeid)
{
pcmk__assert(xml != NULL);

if (node != NULL) {
crm_xml_add(xml, PCMK__XA_ATTR_HOST, node);
}

if (nodeid > 0) {
crm_xml_add_int(xml, PCMK__XA_ATTR_HOST_ID, nodeid);
}
}

/*!
* \internal
* \brief Find a node by name in a list of nodes
Expand Down
3 changes: 1 addition & 2 deletions lib/common/tests/nodes/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2024 the Pacemaker project contributors
# Copyright 2024-2025 the Pacemaker project contributors
#
# The version control history for this file may have further details.
#
Expand All @@ -13,7 +13,6 @@ include $(top_srcdir)/mk/unittest.mk

# Add "_test" to the end of all test program names to simplify .gitignore.
check_PROGRAMS = pcmk__find_node_in_list_test \
pcmk__xe_add_node_test \
pcmk_cib_node_shutdown_test \
pcmk_foreach_active_resource_test \
pcmk_node_is_clean_test \
Expand Down
71 changes: 0 additions & 71 deletions lib/common/tests/nodes/pcmk__xe_add_node_test.c

This file was deleted.

5 changes: 3 additions & 2 deletions lib/lrmd/proxy_common.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2024 the Pacemaker project contributors
* Copyright 2015-2025 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
Expand Down Expand Up @@ -281,7 +281,8 @@ remote_proxy_cb(lrmd_t *lrmd, const char *node_name, xmlNode *msg)
PCMK__ATTRD_CMD_UPDATE,
PCMK__ATTRD_CMD_UPDATE_BOTH,
PCMK__ATTRD_CMD_UPDATE_DELAY, NULL)) {
pcmk__xe_add_node(request, proxy->node_name, 0);

crm_xml_add(request, PCMK__XA_ATTR_HOST, proxy->node_name);
}

rc = crm_ipc_send(proxy->ipc, request, flags, 5000, NULL);
Expand Down

0 comments on commit 4540673

Please sign in to comment.