19 get_meta_attrs_from_cib(xmlNode *basenode,
pcmk__alert_t *entry,
24 const char *value = NULL;
27 NULL, FALSE, now, NULL);
35 crm_trace(
"Alert %s uses default timeout of %dmsec",
38 crm_warn(
"Alert %s has invalid timeout value '%s', using default %dmsec",
43 crm_trace(
"Alert %s uses timeout of %dmsec",
46 if (entry->
timeout > *max_timeout) {
56 crm_trace(
"Alert %s uses timestamp format '%s'",
60 g_hash_table_destroy(config_hash);
68 if ((basenode == NULL) || (entry == NULL)) {
90 g_hash_table_insert(entry->
envvars, strdup(name), strdup(value));
91 crm_trace(
"Alert %s: added environment variable %s='%s'",
92 entry->
id, name, value);
100 xmlNode *event_type = NULL;
103 for (event_type = pcmk__xe_first_child(select); event_type != NULL;
104 event_type = pcmk__xe_next(event_type)) {
106 const char *tagname = crm_element_name(event_type);
108 if (tagname == NULL) {
122 const char *attr_name;
138 (nattrs + 1) *
sizeof(
char*));
148 crm_debug(
"Alert %s receives events: attributes:%s%s%s%s",
159 unpack_alert(xmlNode *alert,
pcmk__alert_t *entry, guint *max_timeout)
161 get_envvars_from_cib(alert, entry);
162 get_meta_attrs_from_cib(alert, entry, max_timeout);
163 unpack_alert_filter(alert, entry);
182 guint max_timeout = 0;
183 GList *alert_list = NULL;
185 if (alerts == NULL) {
194 const char *alert_id =
ID(alert);
198 if ((alert_id == NULL) || (alert_path == NULL)) {
199 crm_warn(
"Ignoring invalid alert without id and path");
205 unpack_alert(alert, entry, &max_timeout);
211 crm_debug(
"Alert %s: path=%s timeout=%dms tstamp-format='%s' %u vars",
223 unpack_alert(recipient, recipient_entry, &max_timeout);
224 alert_list = g_list_prepend(alert_list, recipient_entry);
225 crm_debug(
"Alert %s has recipient %s with value %s and %d envvars",
228 g_hash_table_size(recipient_entry->
envvars) : 0));
231 if (recipients == 0) {
232 alert_list = g_list_prepend(alert_list, entry);
void pe_unpack_nvpairs(xmlNode *top, xmlNode *xml_obj, const char *set_name, GHashTable *node_hash, GHashTable *hash, const char *always_first, gboolean overwrite, crm_time_t *now, crm_time_t *next_change)
Extract nvpair blocks contained by an XML element into a hash table.
struct crm_time_s crm_time_t
xmlNode * first_named_child(const xmlNode *parent, const char *name)
char ** select_attribute_name
void pe_free_alert_list(GList *alert_list)
#define XML_CIB_TAG_ALERT_RESOURCES
long long crm_get_msec(const char *input)
Parse a time+units string and return milliseconds equivalent.
#define XML_NVPAIR_ATTR_NAME
#define XML_CIB_TAG_ALERT_ATTRIBUTES
pcmk__alert_t * pcmk__dup_alert(pcmk__alert_t *entry)
#define XML_CIB_TAG_NVPAIR
#define XML_ALERT_ATTR_REC_VALUE
void pcmk__free_alert(pcmk__alert_t *entry)
#define XML_TAG_ATTR_SETS
#define crm_warn(fmt, args...)
#define crm_debug(fmt, args...)
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define XML_CIB_TAG_ALERT_NODES
#define crm_trace(fmt, args...)
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
#define XML_TAG_META_SETS
#define XML_ALERT_ATTR_TIMEOUT
#define XML_ALERT_ATTR_TSTAMP_FORMAT
GHashTable * pcmk__strkey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
#define XML_CIB_TAG_ALERT
crm_time_t * crm_time_new(const char *string)
#define XML_CIB_TAG_ALERT_FENCING
GList * pe_unpack_alerts(xmlNode *alerts)
#define XML_NVPAIR_ATTR_VALUE
pcmk__alert_t * pcmk__alert_new(const char *id, const char *path)
Create a new alert entry structure.
#define XML_CIB_TAG_ALERT_SELECT
#define PCMK__ALERT_DEFAULT_TSTAMP_FORMAT
#define XML_ALERT_ATTR_PATH
#define XML_CIB_TAG_ALERT_ATTR
#define XML_CIB_TAG_ALERT_RECIPIENT
#define PCMK__ALERT_DEFAULT_TIMEOUT_MS
xmlNode * crm_next_same_xml(const xmlNode *sibling)
Get next instance of same XML tag.
void crm_time_free(crm_time_t *dt)