pacemaker  1.1.16-94ff4df
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules
Macros | Functions | Variables
utils.c File Reference
#include <crm_internal.h>
#include <dlfcn.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <ctype.h>
#include <pwd.h>
#include <time.h>
#include <libgen.h>
#include <signal.h>
#include <qb/qbdefs.h>
#include <crm/crm.h>
#include <crm/lrmd.h>
#include <crm/services.h>
#include <crm/msg_xml.h>
#include <crm/cib/internal.h>
#include <crm/common/xml.h>
#include <crm/common/util.h>
#include <crm/common/ipc.h>
#include <crm/common/iso8601.h>
#include <crm/common/mainloop.h>
#include <crm/attrd.h>
#include <libxml2/libxml/relaxng.h>
#include <md5.h>
Include dependency graph for utils.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 
#define MAXLINE   512
 
#define PW_BUFFER_LEN   500
 
#define NUMCHARS   "0123456789."
 
#define WHITESPACE   " \t\n\r\f"
 
#define LOCKSTRLEN   11
 
#define FAKE_TE_ID   "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
 

Functions

 CRM_TRACE_INIT_DATA (common)
 
int crm_exit (int rc)
 
gboolean check_time (const char *value)
 
gboolean check_timer (const char *value)
 
gboolean check_boolean (const char *value)
 
gboolean check_number (const char *value)
 
gboolean check_quorum (const char *value)
 
gboolean check_script (const char *value)
 
gboolean check_utilization (const char *value)
 
int char2score (const char *score)
 
char * score2char_stack (int score, char *buf, size_t len)
 
char * score2char (int score)
 
const char * cluster_option (GHashTable *options, gboolean(*validate)(const char *), const char *name, const char *old_name, const char *def_value)
 
const char * get_cluster_pref (GHashTable *options, pe_cluster_option *option_list, int len, const char *name)
 
void config_metadata (const char *name, const char *version, const char *desc_short, const char *desc_long, pe_cluster_option *option_list, int len)
 
void verify_all_options (GHashTable *options, pe_cluster_option *option_list, int len)
 
char * generate_hash_key (const char *crm_msg_reference, const char *sys)
 
int crm_user_lookup (const char *name, uid_t *uid, gid_t *gid)
 
int compare_version (const char *version1, const char *version2)
 
unsigned long long crm_get_interval (const char *input)
 
long long crm_get_msec (const char *input)
 
char * generate_op_key (const char *rsc_id, const char *op_type, int interval)
 
gboolean parse_op_key (const char *key, char **rsc_id, char **op_type, int *interval)
 
char * generate_notify_key (const char *rsc_id, const char *notify_type, const char *op_type)
 
char * generate_transition_magic_v202 (const char *transition_key, int op_status)
 
char * generate_transition_magic (const char *transition_key, int op_status, int op_rc)
 
gboolean decode_transition_magic (const char *magic, char **uuid, int *transition_id, int *action_id, int *op_status, int *op_rc, int *target_rc)
 
char * generate_transition_key (int transition_id, int action_id, int target_rc, const char *node)
 
gboolean decode_transition_key (const char *key, char **uuid, int *transition_id, int *action_id, int *target_rc)
 
void filter_action_parameters (xmlNode *param_set, const char *version)
 
void crm_abort (const char *file, const char *function, int line, const char *assert_condition, gboolean do_core, gboolean do_fork)
 
int crm_pid_active (long pid, const char *daemon)
 
long crm_read_pidfile (const char *filename)
 
long crm_pidfile_inuse (const char *filename, long mypid, const char *daemon)
 
void crm_make_daemon (const char *name, gboolean daemonize, const char *pidfile)
 
char * crm_meta_name (const char *field)
 
const char * crm_meta_value (GHashTable *hash, const char *field)
 
void crm_set_options (const char *short_options, const char *app_usage, struct crm_option *long_options, const char *app_desc)
 
int crm_get_option (int argc, char **argv, int *index)
 
int crm_get_option_long (int argc, char **argv, int *index, const char **longname)
 
int crm_help (char cmd, int exit_code)
 
void cib_ipc_servers_init (qb_ipcs_service_t **ipcs_ro, qb_ipcs_service_t **ipcs_rw, qb_ipcs_service_t **ipcs_shm, struct qb_ipcs_service_handlers *ro_cb, struct qb_ipcs_service_handlers *rw_cb)
 
void cib_ipc_servers_destroy (qb_ipcs_service_t *ipcs_ro, qb_ipcs_service_t *ipcs_rw, qb_ipcs_service_t *ipcs_shm)
 
qb_ipcs_service_t * crmd_ipc_server_init (struct qb_ipcs_service_handlers *cb)
 
void attrd_ipc_server_init (qb_ipcs_service_t **ipcs, struct qb_ipcs_service_handlers *cb)
 
void stonith_ipc_server_init (qb_ipcs_service_t **ipcs, struct qb_ipcs_service_handlers *cb)
 
int attrd_update_delegate (crm_ipc_t *ipc, char command, const char *host, const char *name, const char *value, const char *section, const char *set, const char *dampen, const char *user_name, int options)
 
int rsc_op_expected_rc (lrmd_event_data_t *op)
 
gboolean did_rsc_op_fail (lrmd_event_data_t *op, int target_rc)
 
xmlNode * create_operation_update (xmlNode *parent, lrmd_event_data_t *op, const char *caller_version, int target_rc, const char *node, const char *origin, int level)
 
bool pcmk_acl_required (const char *user)
 
void * find_library_function (void **handle, const char *lib, const char *fn, gboolean fatal)
 
void * convert_const_pointer (const void *ptr)
 
char * crm_generate_uuid (void)
 
char * crm_md5sum (const char *buffer)
 

Variables

gboolean crm_config_error = FALSE
 
gboolean crm_config_warning = FALSE
 
char * crm_system_name = NULL
 
int node_score_red = 0
 
int node_score_green = 0
 
int node_score_yellow = 0
 
int node_score_infinity = INFINITY
 
gboolean do_stderr = FALSE
 
bool crm_is_daemon
 

Macro Definition Documentation

#define _GNU_SOURCE

Definition at line 23 of file utils.c.

#define FAKE_TE_ID   "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

Definition at line 1678 of file utils.c.

#define LOCKSTRLEN   11

Definition at line 1078 of file utils.c.

#define MAXLINE   512

Definition at line 59 of file utils.c.

#define NUMCHARS   "0123456789."

Definition at line 545 of file utils.c.

#define PW_BUFFER_LEN   500

Definition at line 67 of file utils.c.

#define WHITESPACE   " \t\n\r\f"

Definition at line 549 of file utils.c.

Function Documentation

void attrd_ipc_server_init ( qb_ipcs_service_t **  ipcs,
struct qb_ipcs_service_handlers *  cb 
)

Definition at line 1512 of file utils.c.

int attrd_update_delegate ( crm_ipc_t ipc,
char  command,
const char *  host,
const char *  name,
const char *  value,
const char *  section,
const char *  set,
const char *  dampen,
const char *  user_name,
int  options 
)

Definition at line 1536 of file utils.c.

int char2score ( const char *  score)

Definition at line 225 of file utils.c.

gboolean check_boolean ( const char *  value)

Definition at line 133 of file utils.c.

gboolean check_number ( const char *  value)

Definition at line 144 of file utils.c.

gboolean check_quorum ( const char *  value)

Definition at line 165 of file utils.c.

gboolean check_script ( const char *  value)

Definition at line 183 of file utils.c.

gboolean check_time ( const char *  value)

Definition at line 115 of file utils.c.

gboolean check_timer ( const char *  value)

Definition at line 124 of file utils.c.

gboolean check_utilization ( const char *  value)

Definition at line 210 of file utils.c.

void cib_ipc_servers_destroy ( qb_ipcs_service_t *  ipcs_ro,
qb_ipcs_service_t *  ipcs_rw,
qb_ipcs_service_t *  ipcs_shm 
)

Definition at line 1496 of file utils.c.

void cib_ipc_servers_init ( qb_ipcs_service_t **  ipcs_ro,
qb_ipcs_service_t **  ipcs_rw,
qb_ipcs_service_t **  ipcs_shm,
struct qb_ipcs_service_handlers *  ro_cb,
struct qb_ipcs_service_handlers *  rw_cb 
)

Definition at line 1479 of file utils.c.

const char* cluster_option ( GHashTable *  options,
gboolean(*)(const char *)  validate,
const char *  name,
const char *  old_name,
const char *  def_value 
)

Definition at line 289 of file utils.c.

int compare_version ( const char *  version1,
const char *  version2 
)

Definition at line 466 of file utils.c.

void config_metadata ( const char *  name,
const char *  version,
const char *  desc_short,
const char *  desc_long,
pe_cluster_option option_list,
int  len 
)

Definition at line 355 of file utils.c.

void* convert_const_pointer ( const void *  ptr)

Definition at line 2067 of file utils.c.

xmlNode* create_operation_update ( xmlNode *  parent,
lrmd_event_data_t op,
const char *  caller_version,
int  target_rc,
const char *  node,
const char *  origin,
int  level 
)

Definition at line 1755 of file utils.c.

void crm_abort ( const char *  file,
const char *  function,
int  line,
const char *  assert_condition,
gboolean  do_core,
gboolean  do_fork 
)

Definition at line 956 of file utils.c.

int crm_exit ( int  rc)

Definition at line 87 of file utils.c.

char* crm_generate_uuid ( void  )

Definition at line 2078 of file utils.c.

unsigned long long crm_get_interval ( const char *  input)

Definition at line 553 of file utils.c.

long long crm_get_msec ( const char *  input)

Definition at line 578 of file utils.c.

int crm_get_option ( int  argc,
char **  argv,
int *  index 
)

Definition at line 1353 of file utils.c.

int crm_get_option_long ( int  argc,
char **  argv,
int *  index,
const char **  longname 
)

Definition at line 1359 of file utils.c.

int crm_help ( char  cmd,
int  exit_code 
)

Definition at line 1404 of file utils.c.

void crm_make_daemon ( const char *  name,
gboolean  daemonize,
const char *  pidfile 
)

Definition at line 1180 of file utils.c.

char* crm_md5sum ( const char *  buffer)

Definition at line 2091 of file utils.c.

char* crm_meta_name ( const char *  field)

Definition at line 1227 of file utils.c.

const char* crm_meta_value ( GHashTable *  hash,
const char *  field 
)

Definition at line 1249 of file utils.c.

int crm_pid_active ( long  pid,
const char *  daemon 
)

Definition at line 1018 of file utils.c.

long crm_pidfile_inuse ( const char *  filename,
long  mypid,
const char *  daemon 
)

Definition at line 1118 of file utils.c.

long crm_read_pidfile ( const char *  filename)

Definition at line 1081 of file utils.c.

void crm_set_options ( const char *  short_options,
const char *  app_usage,
struct crm_option long_options,
const char *  app_desc 
)

Definition at line 1312 of file utils.c.

CRM_TRACE_INIT_DATA ( common  )
int crm_user_lookup ( const char *  name,
uid_t *  uid,
gid_t *  gid 
)

Definition at line 413 of file utils.c.

qb_ipcs_service_t* crmd_ipc_server_init ( struct qb_ipcs_service_handlers *  cb)

Definition at line 1506 of file utils.c.

gboolean decode_transition_key ( const char *  key,
char **  uuid,
int *  transition_id,
int *  action_id,
int *  target_rc 
)

Definition at line 821 of file utils.c.

gboolean decode_transition_magic ( const char *  magic,
char **  uuid,
int *  transition_id,
int *  action_id,
int *  op_status,
int *  op_rc,
int *  target_rc 
)

Definition at line 778 of file utils.c.

gboolean did_rsc_op_fail ( lrmd_event_data_t op,
int  target_rc 
)

Definition at line 1731 of file utils.c.

void filter_action_parameters ( xmlNode *  param_set,
const char *  version 
)

Definition at line 887 of file utils.c.

void* find_library_function ( void **  handle,
const char *  lib,
const char *  fn,
gboolean  fatal 
)

Definition at line 2037 of file utils.c.

char* generate_hash_key ( const char *  crm_msg_reference,
const char *  sys 
)

Definition at line 403 of file utils.c.

char* generate_notify_key ( const char *  rsc_id,
const char *  notify_type,
const char *  op_type 
)

Definition at line 722 of file utils.c.

char* generate_op_key ( const char *  rsc_id,
const char *  op_type,
int  interval 
)

Definition at line 633 of file utils.c.

char* generate_transition_key ( int  transition_id,
int  action_id,
int  target_rc,
const char *  node 
)

Definition at line 804 of file utils.c.

char* generate_transition_magic ( const char *  transition_key,
int  op_status,
int  op_rc 
)

Definition at line 761 of file utils.c.

char* generate_transition_magic_v202 ( const char *  transition_key,
int  op_status 
)

Definition at line 744 of file utils.c.

const char* get_cluster_pref ( GHashTable *  options,
pe_cluster_option option_list,
int  len,
const char *  name 
)

Definition at line 335 of file utils.c.

gboolean parse_op_key ( const char *  key,
char **  rsc_id,
char **  op_type,
int *  interval 
)

Definition at line 650 of file utils.c.

bool pcmk_acl_required ( const char *  user)

Definition at line 1924 of file utils.c.

int rsc_op_expected_rc ( lrmd_event_data_t op)

Definition at line 1716 of file utils.c.

char* score2char ( int  score)

Definition at line 277 of file utils.c.

char* score2char_stack ( int  score,
char *  buf,
size_t  len 
)

Definition at line 263 of file utils.c.

void stonith_ipc_server_init ( qb_ipcs_service_t **  ipcs,
struct qb_ipcs_service_handlers *  cb 
)

Definition at line 1524 of file utils.c.

void verify_all_options ( GHashTable *  options,
pe_cluster_option option_list,
int  len 
)

Definition at line 390 of file utils.c.

Variable Documentation

gboolean crm_config_error = FALSE

Definition at line 72 of file utils.c.

gboolean crm_config_warning = FALSE

Definition at line 73 of file utils.c.

bool crm_is_daemon

Definition at line 49 of file logging.c.

char* crm_system_name = NULL

Definition at line 74 of file utils.c.

gboolean do_stderr = FALSE

Definition at line 542 of file utils.c.

int node_score_green = 0

Definition at line 77 of file utils.c.

int node_score_infinity = INFINITY

Definition at line 79 of file utils.c.

int node_score_red = 0

Definition at line 76 of file utils.c.

int node_score_yellow = 0

Definition at line 78 of file utils.c.