pacemaker  2.0.1-15814c6c0d
Scalable High-Availability cluster resource manager
Macros | Functions | Variables
utils.c File Reference
#include <crm_internal.h>
#include <dlfcn.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 <pwd.h>
#include <time.h>
#include <libgen.h>
#include <signal.h>
#include <qb/qbdefs.h>
#include <crm/crm.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 <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"
 

Functions

 CRM_TRACE_INIT_DATA (common)
 
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_positive_number (const char *value)
 
gboolean check_quorum (const char *value)
 
gboolean check_script (const char *value)
 
gboolean check_utilization (const char *value)
 
void crm_args_fini ()
 
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)
 
guint crm_parse_interval_spec (const char *input)
 
long long crm_get_msec (const char *input)
 
void crm_abort (const char *file, const char *function, int line, const char *assert_condition, gboolean do_core, gboolean do_fork)
 
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)
 
crm_exit_t crm_help (char cmd, crm_exit_t 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)
 
void * find_library_function (void **handle, const char *lib, const char *fn, gboolean fatal)
 
char * crm_generate_uuid (void)
 
const char * pcmk_message_name (const char *name)
 Get name to be used as identifier for cluster messages. More...
 
bool crm_is_daemon_name (const char *name)
 Check whether a string represents a cluster daemon name. More...
 
char * crm_md5sum (const char *buffer)
 
char * pcmk_hostname ()
 Get the local hostname. More...
 

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
 
gboolean do_stderr = FALSE
 
bool crm_is_daemon
 

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 12 of file utils.c.

◆ MAXLINE

#define MAXLINE   512

Definition at line 44 of file utils.c.

◆ NUMCHARS

#define NUMCHARS   "0123456789."

Definition at line 532 of file utils.c.

◆ PW_BUFFER_LEN

#define PW_BUFFER_LEN   500

Definition at line 52 of file utils.c.

◆ WHITESPACE

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

Definition at line 536 of file utils.c.

Function Documentation

◆ attrd_ipc_server_init()

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

Definition at line 1017 of file utils.c.

◆ char2score()

int char2score ( const char *  score)

Definition at line 197 of file utils.c.

◆ check_boolean()

gboolean check_boolean ( const char *  value)

Definition at line 89 of file utils.c.

◆ check_number()

gboolean check_number ( const char *  value)

Definition at line 100 of file utils.c.

◆ check_positive_number()

gboolean check_positive_number ( const char *  value)

Definition at line 121 of file utils.c.

◆ check_quorum()

gboolean check_quorum ( const char *  value)

Definition at line 130 of file utils.c.

◆ check_script()

gboolean check_script ( const char *  value)

Definition at line 148 of file utils.c.

◆ check_time()

gboolean check_time ( const char *  value)

Definition at line 71 of file utils.c.

◆ check_timer()

gboolean check_timer ( const char *  value)

Definition at line 80 of file utils.c.

◆ check_utilization()

gboolean check_utilization ( const char *  value)

Definition at line 175 of file utils.c.

◆ cib_ipc_servers_destroy()

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 1001 of file utils.c.

◆ cib_ipc_servers_init()

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 984 of file utils.c.

◆ cluster_option()

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

Definition at line 261 of file utils.c.

◆ compare_version()

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

Definition at line 453 of file utils.c.

◆ config_metadata()

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 342 of file utils.c.

◆ crm_abort()

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

Definition at line 623 of file utils.c.

◆ crm_args_fini()

void crm_args_fini ( void  )

Definition at line 190 of file utils.c.

◆ crm_generate_uuid()

char* crm_generate_uuid ( void  )

Definition at line 1075 of file utils.c.

◆ crm_get_msec()

long long crm_get_msec ( const char *  input)

Definition at line 565 of file utils.c.

◆ crm_get_option()

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

Definition at line 858 of file utils.c.

◆ crm_get_option_long()

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

Definition at line 864 of file utils.c.

◆ crm_help()

crm_exit_t crm_help ( char  cmd,
crm_exit_t  exit_code 
)

Definition at line 909 of file utils.c.

◆ crm_is_daemon_name()

bool crm_is_daemon_name ( const char *  name)

Check whether a string represents a cluster daemon name.

Parameters
[in]nameString to check
Returns
TRUE if name is standard client name used by daemons, FALSE otherwise

Definition at line 1133 of file utils.c.

◆ crm_make_daemon()

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

Definition at line 685 of file utils.c.

◆ crm_md5sum()

char* crm_md5sum ( const char *  buffer)

Definition at line 1150 of file utils.c.

◆ crm_meta_name()

char* crm_meta_name ( const char *  field)

Definition at line 732 of file utils.c.

◆ crm_meta_value()

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

Definition at line 754 of file utils.c.

◆ crm_parse_interval_spec()

guint crm_parse_interval_spec ( const char *  input)

Definition at line 540 of file utils.c.

◆ crm_set_options()

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

Definition at line 817 of file utils.c.

◆ CRM_TRACE_INIT_DATA()

CRM_TRACE_INIT_DATA ( common  )

◆ crm_user_lookup()

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

Definition at line 400 of file utils.c.

◆ crmd_ipc_server_init()

qb_ipcs_service_t* crmd_ipc_server_init ( struct qb_ipcs_service_handlers *  cb)

Definition at line 1011 of file utils.c.

◆ find_library_function()

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

Definition at line 1041 of file utils.c.

◆ generate_hash_key()

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

Definition at line 390 of file utils.c.

◆ get_cluster_pref()

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

Definition at line 323 of file utils.c.

◆ pcmk_hostname()

char* pcmk_hostname ( void  )

Get the local hostname.

Returns
Newly allocated string with name, or NULL (and set errno) on error

Definition at line 1192 of file utils.c.

◆ pcmk_message_name()

const char* pcmk_message_name ( const char *  name)

Get name to be used as identifier for cluster messages.

Parameters
[in]nameActual system name to check
Returns
Non-NULL cluster message identifier corresponding to name
Note
The Pacemaker daemons were renamed in version 2.0.0, but the old names must continue to be used as the identifier for cluster messages, so that mixed-version clusters are possible during a rolling upgrade.

Definition at line 1097 of file utils.c.

◆ score2char()

char* score2char ( int  score)

Definition at line 249 of file utils.c.

◆ score2char_stack()

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

Definition at line 235 of file utils.c.

◆ stonith_ipc_server_init()

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

Definition at line 1029 of file utils.c.

◆ verify_all_options()

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

Definition at line 377 of file utils.c.

Variable Documentation

◆ crm_config_error

gboolean crm_config_error = FALSE

Definition at line 57 of file utils.c.

◆ crm_config_warning

gboolean crm_config_warning = FALSE

Definition at line 58 of file utils.c.

◆ crm_is_daemon

bool crm_is_daemon

Definition at line 38 of file logging.c.

◆ crm_system_name

char* crm_system_name = NULL

Definition at line 59 of file utils.c.

◆ do_stderr

gboolean do_stderr = FALSE

Definition at line 529 of file utils.c.

◆ node_score_green

int node_score_green = 0

Definition at line 62 of file utils.c.

◆ node_score_red

int node_score_red = 0

Definition at line 61 of file utils.c.

◆ node_score_yellow

int node_score_yellow = 0

Definition at line 63 of file utils.c.