Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #264 from gao-yan/crm-node-remove

Fix: legacy: Support "crm_node --remove" with a node name for corosync plugin (bnc#805278)
  • Loading branch information...
commit dc566ede82a2f10a1b021620f4b5f00b3fba3f39 2 parents 59a244e + 3dde3d4
@beekhof beekhof authored
Showing with 33 additions and 2 deletions.
  1. +32 −1 lib/ais/plugin.c
  2. +1 −1  tools/crm_node.c
View
33 lib/ais/plugin.c
@@ -140,6 +140,7 @@ void pcmk_quorum(void *conn, ais_void_ptr * msg);
void pcmk_cluster_id_swab(void *msg);
void pcmk_cluster_id_callback(ais_void_ptr * message, unsigned int nodeid);
void ais_remove_peer(char *node_id);
+void ais_remove_peer_by_name(const char *node_name);
static uint32_t
get_process_list(void)
@@ -1718,6 +1719,36 @@ ais_remove_peer(char *node_id)
}
}
+void
+ais_remove_peer_by_name(const char *node_name)
+{
+ GHashTableIter iter;
+ gpointer key = 0;
+ crm_node_t *node = NULL;
+ uint32_t node_id = 0;
+
+ g_hash_table_iter_init(&iter, membership_list);
+
+ while (g_hash_table_iter_next(&iter, &key, (void **)&node)) {
+ if (ais_str_eq(node_name, node->uname)) {
+ node_id = GPOINTER_TO_UINT(key);
+ break;
+ }
+ }
+
+ if (node_id) {
+ char *node_id_s = NULL;
+
+ ais_malloc0(node_id_s, 32);
+ snprintf(node_id_s, 31, "%u", node_id);
+ ais_remove_peer(node_id_s);
+ ais_free(node_id_s);
+
+ } else {
+ ais_warn("Peer %s is unkown", node_name);
+ }
+}
+
gboolean
process_ais_message(const AIS_Message * msg)
{
@@ -1734,7 +1765,7 @@ process_ais_message(const AIS_Message * msg)
if (data && len > 12 && strncmp("remove-peer:", data, 12) == 0) {
char *node = data + 12;
- ais_remove_peer(node);
+ ais_remove_peer_by_name(node);
}
ais_free(data);
View
2  tools/crm_node.c
@@ -704,7 +704,7 @@ try_openais(int command, enum cluster_type_e stack)
switch (command) {
case 'R':
send_ais_text(crm_class_rmpeer, target_uname, TRUE, NULL, crm_msg_ais);
- cib_remove_node(atoi(target_uname), NULL);
+ cib_remove_node(0, target_uname);
crm_exit(0);
case 'e':
Please sign in to comment.
Something went wrong with that request. Please try again.