root/include/crm/common/alerts_internal.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. crm_alert_flag2text

   1 /*
   2  * Copyright (C) 2015 Andrew Beekhof <andrew@beekhof.net>
   3  *
   4  * This program is free software; you can redistribute it and/or
   5  * modify it under the terms of the GNU Lesser General Public
   6  * License as published by the Free Software Foundation; either
   7  * version 2 of the License, or (at your option) any later version.
   8  *
   9  * This software is distributed in the hope that it will be useful,
  10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12  * General Public License for more details.
  13  *
  14  * You should have received a copy of the GNU Lesser General Public
  15  * License along with this library; if not, write to the Free Software
  16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  17  */
  18 
  19 #ifndef ALERT_INTERNAL_H
  20 #define ALERT_INTERNAL_H
  21 
  22 #include <glib.h>
  23 #include <stdbool.h>
  24 
  25 /* Default-Timeout to use before killing a alerts script (in milliseconds) */
  26 #  define CRM_ALERT_DEFAULT_TIMEOUT_MS (30000)
  27 
  28 /* Default-Format-String used to pass timestamps to the alerts scripts */
  29 #  define CRM_ALERT_DEFAULT_TSTAMP_FORMAT "%H:%M:%S.%06N"
  30 
  31 typedef struct {
  32     char *name;
  33     char *value;
  34 }  crm_alert_envvar_t;
  35 
  36 enum crm_alert_flags {
  37     crm_alert_none         = 0x0000,
  38     crm_alert_node         = 0x0001,
  39     crm_alert_fencing      = 0x0002,
  40     crm_alert_resource     = 0x0004,
  41     crm_alert_attribute    = 0x0008,
  42     crm_alert_default      = crm_alert_node|crm_alert_fencing|crm_alert_resource
  43 };
  44 
  45 typedef struct {
  46     char *id;
  47     char *path;
  48     char *tstamp_format;
  49     char *recipient;
  50     char **select_attribute_name;
  51     GHashTable *envvars;
  52     int timeout;
  53     uint32_t flags;
  54 } crm_alert_entry_t;
  55 
  56 enum crm_alert_keys_e {
  57     CRM_alert_recipient = 0,
  58     CRM_alert_node,
  59     CRM_alert_nodeid,
  60     CRM_alert_rsc,
  61     CRM_alert_task,
  62     CRM_alert_interval,
  63     CRM_alert_desc,
  64     CRM_alert_status,
  65     CRM_alert_target_rc,
  66     CRM_alert_rc,
  67     CRM_alert_kind,
  68     CRM_alert_version,
  69     CRM_alert_node_sequence,
  70     CRM_alert_timestamp,
  71     CRM_alert_attribute_name,
  72     CRM_alert_attribute_value,
  73     CRM_alert_select_kind,
  74     CRM_alert_select_attribute_name
  75 };
  76 
  77 #define CRM_ALERT_INTERNAL_KEY_MAX 16
  78 #define CRM_ALERT_NODE_SEQUENCE "CRM_alert_node_sequence"
  79 
  80 extern const char *crm_alert_keys[CRM_ALERT_INTERNAL_KEY_MAX][3];
  81 
  82 crm_alert_entry_t *crm_dup_alert_entry(crm_alert_entry_t *entry);
  83 crm_alert_envvar_t *crm_dup_alert_envvar(crm_alert_envvar_t *src);
  84 crm_alert_entry_t *crm_alert_entry_new(const char *id, const char *path);
  85 void crm_free_alert_entry(crm_alert_entry_t *entry);
  86 void crm_free_alert_envvar(crm_alert_envvar_t *entry);
  87 void crm_insert_alert_key(GHashTable *table, enum crm_alert_keys_e name,
  88                           const char *value);
  89 void crm_insert_alert_key_int(GHashTable *table, enum crm_alert_keys_e name,
  90                               int value);
  91 void crm_unset_alert_keys(void);
  92 void crm_set_envvar_list(crm_alert_entry_t *entry);
  93 void crm_unset_envvar_list(crm_alert_entry_t *entry);
  94 bool crm_patchset_contains_alert(xmlNode *msg, bool config);
  95 
  96 static inline const char *
  97 crm_alert_flag2text(enum crm_alert_flags flag)
     /* [previous][next][first][last][top][bottom][index][help] */
  98 {
  99     switch (flag) {
 100         case crm_alert_node:
 101             return "node";
 102         case crm_alert_fencing:
 103             return "fencing";
 104         case crm_alert_resource:
 105             return "resource";
 106         case crm_alert_attribute:
 107             return "attribute";
 108         default:
 109             return "unknown";
 110     }
 111 }
 112 #endif

/* [previous][next][first][last][top][bottom][index][help] */