| 127 | } |
| 128 | |
| 129 | void |
| 130 | cib_pre_notify(int options, const char *op, xmlNode * existing, xmlNode * update) |
| 131 | { |
| 132 | xmlNode *update_msg = NULL; |
| 133 | const char *type = NULL; |
| 134 | const char *id = NULL; |
| 135 | gboolean needed = FALSE; |
| 136 | |
| 137 | g_hash_table_foreach(client_list, need_pre_notify, &needed); |
| 138 | if (needed == FALSE) { |
| 139 | return; |
| 140 | } |
| 141 | |
| 142 | /* TODO: consider pre-notification for removal */ |
| 143 | update_msg = create_xml_node(NULL, "pre-notify"); |
| 144 | |
| 145 | if (update != NULL) { |
| 146 | id = crm_element_value(update, XML_ATTR_ID); |
| 147 | } |
| 148 | |
| 149 | crm_xml_add(update_msg, F_TYPE, T_CIB_NOTIFY); |
| 150 | crm_xml_add(update_msg, F_SUBTYPE, T_CIB_PRE_NOTIFY); |
| 151 | crm_xml_add(update_msg, F_CIB_OPERATION, op); |
| 152 | |
| 153 | if (id != NULL) { |
| 154 | crm_xml_add(update_msg, F_CIB_OBJID, id); |
| 155 | } |
| 156 | |
| 157 | if (update != NULL) { |
| 158 | crm_xml_add(update_msg, F_CIB_OBJTYPE, crm_element_name(update)); |
| 159 | } else if (existing != NULL) { |
| 160 | crm_xml_add(update_msg, F_CIB_OBJTYPE, crm_element_name(existing)); |
| 161 | } |
| 162 | |
| 163 | type = crm_element_value(update_msg, F_CIB_OBJTYPE); |
| 164 | attach_cib_generation(update_msg, "cib_generation", the_cib); |
| 165 | |
| 166 | if (existing != NULL) { |
| 167 | add_message_xml(update_msg, F_CIB_EXISTING, existing); |
| 168 | } |
| 169 | if (update != NULL) { |
| 170 | add_message_xml(update_msg, F_CIB_UPDATE, update); |
| 171 | } |
| 172 | |
| 173 | g_hash_table_foreach_remove(client_list, cib_notify_client, update_msg); |
| 174 | |
| 175 | if (update == NULL) { |
| 176 | crm_trace("Performing operation %s (on section=%s)", op, type); |
| 177 | |
| 178 | } else { |
| 179 | crm_trace("Performing %s on <%s%s%s>", op, type, id ? " id=" : "", id ? id : ""); |
| 180 | } |
| 181 | |
| 182 | free_xml(update_msg); |
| 183 | } |
| 184 | |
| 185 | void |
| 186 | cib_post_notify(int options, const char *op, xmlNode * update, |
no test coverage detected