18 get_meta_attrs_from_cib(xmlNode *basenode,
pcmk__alert_t *entry,
21 GHashTable *config_hash = crm_str_table_new();
23 const char *value = NULL;
26 NULL, FALSE, now, NULL);
34 crm_trace(
"Alert %s uses default timeout of %dmsec",
37 crm_warn(
"Alert %s has invalid timeout value '%s', using default %dmsec",
42 crm_trace(
"Alert %s uses timeout of %dmsec",
45 if (entry->
timeout > *max_timeout) {
55 crm_trace(
"Alert %s uses timestamp format '%s'",
59 g_hash_table_destroy(config_hash);
67 if ((basenode == NULL) || (entry == NULL)) {
77 entry->
envvars = crm_str_table_new();
89 g_hash_table_insert(entry->
envvars, strdup(name), strdup(value));
90 crm_trace(
"Alert %s: added environment variable %s='%s'",
91 entry->
id, name, value);
99 xmlNode *event_type = NULL;
102 for (event_type = __xml_first_child_element(select); event_type != NULL;
103 event_type = __xml_next_element(event_type)) {
105 const char *tagname = crm_element_name(event_type);
107 if (tagname == NULL) {
121 const char *attr_name;
137 (nattrs + 1) *
sizeof(
char*));
147 crm_debug(
"Alert %s receives events: attributes:%s%s%s%s",
158 unpack_alert(xmlNode *alert,
pcmk__alert_t *entry, guint *max_timeout)
160 get_envvars_from_cib(alert, entry);
161 get_meta_attrs_from_cib(alert, entry, max_timeout);
162 unpack_alert_filter(alert, entry);
181 guint max_timeout = 0;
184 if (alerts == NULL) {
193 const char *alert_id =
ID(alert);
197 if ((alert_id == NULL) || (alert_path == NULL)) {
198 crm_warn(
"Ignoring invalid alert without id and path");
204 unpack_alert(alert, entry, &max_timeout);
210 crm_debug(
"Alert %s: path=%s timeout=%dms tstamp-format='%s' %u vars",
222 unpack_alert(recipient, recipient_entry, &max_timeout);
223 alert_list = g_list_prepend(alert_list, recipient_entry);
224 crm_debug(
"Alert %s has recipient %s with value %s and %d envvars",
227 g_hash_table_size(recipient_entry->
envvars) : 0));
230 if (recipients == 0) {
231 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.
void pe_free_alert_list(GListPtr alert_list)
struct crm_time_s crm_time_t
xmlNode * first_named_child(const xmlNode *parent, const char *name)
char ** select_attribute_name
#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)
GListPtr pe_unpack_alerts(xmlNode *alerts)
#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 XML_TAG_META_SETS
#define XML_ALERT_ATTR_TIMEOUT
#define XML_ALERT_ATTR_TSTAMP_FORMAT
#define XML_CIB_TAG_ALERT
crm_time_t * crm_time_new(const char *string)
#define XML_CIB_TAG_ALERT_FENCING
#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)