pacemaker  1.1.18-7fdfbbe
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
util.h File Reference

Utility functions. More...

#include <sys/types.h>
#include <stdlib.h>
#include <stdbool.h>
#include <limits.h>
#include <signal.h>
#include <sysexits.h>
#include <glib.h>
#include <libxml/tree.h>
#include <crm/lrmd.h>
Include dependency graph for util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define NORMALNODE   "normal"
 
#define ACTIVESTATUS   "active"/* fully functional, and all links are up */
 
#define DEADSTATUS   "dead"
 
#define PINGSTATUS   "ping"
 
#define JOINSTATUS   "join"
 
#define LEAVESTATUS   "leave"
 
#define ONLINESTATUS   "online"/* Status of an online client */
 
#define OFFLINESTATUS   "offline"
 
#define safe_str_eq(a, b)   crm_str_eq(a, b, FALSE)
 
#define crm_str_hash   g_str_hash_traditional
 
#define crm_atoi(text, default_text)   crm_parse_int(text, default_text)
 
#define CRM_DEFAULT_OP_TIMEOUT_S   "20s"
 

Functions

int crm_default_remote_port (void)
 Get the default remote connection TCP port on this host. More...
 
char * crm_itoa_stack (int an_int, char *buf, size_t len)
 
char * crm_itoa (int an_int)
 
gboolean crm_is_true (const char *s)
 
int crm_str_to_boolean (const char *s, int *ret)
 
int crm_parse_int (const char *text, const char *default_text)
 
char * crm_strip_trailing_newline (char *str)
 
gboolean crm_str_eq (const char *a, const char *b, gboolean use_case)
 
gboolean safe_str_neq (const char *a, const char *b)
 
guint crm_strcase_hash (gconstpointer v)
 
guint g_str_hash_traditional (gconstpointer v)
 
GHashTable * crm_str_table_dup (GHashTable *old_table)
 
void crm_build_path (const char *path_c, mode_t mode)
 Create a directory, including any parent directories needed. More...
 
long long crm_get_msec (const char *input)
 
unsigned long long crm_get_interval (const char *input)
 
int char2score (const char *score)
 
char * score2char (int score)
 
char * score2char_stack (int score, char *buf, size_t len)
 
gboolean parse_op_key (const char *key, char **rsc_id, char **op_type, int *interval)
 
gboolean decode_transition_key (const char *key, char **uuid, int *action, int *transition_id, int *target_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)
 
int rsc_op_expected_rc (lrmd_event_data_t *event)
 
gboolean did_rsc_op_fail (lrmd_event_data_t *event, int target_rc)
 
bool crm_op_needs_metadata (const char *rsc_class, const char *op)
 Check whether an operation requires resource agent meta-data. More...
 
xmlNode * crm_create_op_xml (xmlNode *parent, const char *prefix, const char *task, const char *interval, const char *timeout)
 Create a CIB XML element for an operation. More...
 
int compare_version (const char *version1, const char *version2)
 
void crm_abort (const char *file, const char *function, int line, const char *condition, gboolean do_core, gboolean do_fork)
 
char * crm_meta_name (const char *field)
 
const char * crm_meta_value (GHashTable *hash, const char *field)
 
char * crm_md5sum (const char *buffer)
 
char * crm_generate_uuid (void)
 
bool crm_is_daemon_name (const char *name)
 Check whether a string represents a cluster daemon name. More...
 
int crm_user_lookup (const char *name, uid_t *uid, gid_t *gid)
 
int crm_exit (int rc)
 
bool pcmk_acl_required (const char *user)
 
char * crm_generate_ra_key (const char *class, const char *provider, const char *type)
 
bool crm_provider_required (const char *standard)
 Check whether a resource standard requires a provider to be specified. More...
 
int crm_parse_agent_spec (const char *spec, char **standard, char **provider, char **type)
 Parse a "standard[:provider]:type" agent specification. More...
 

Detailed Description

Utility functions.

Definition in file util.h.

Macro Definition Documentation

#define ACTIVESTATUS   "active"/* fully functional, and all links are up */

Definition at line 43 of file util.h.

#define crm_atoi (   text,
  default_text 
)    crm_parse_int(text, default_text)

Definition at line 110 of file util.h.

#define CRM_DEFAULT_OP_TIMEOUT_S   "20s"

Definition at line 135 of file util.h.

#define crm_str_hash   g_str_hash_traditional

Definition at line 73 of file util.h.

#define DEADSTATUS   "dead"

Definition at line 44 of file util.h.

#define JOINSTATUS   "join"

Definition at line 48 of file util.h.

#define LEAVESTATUS   "leave"

Definition at line 50 of file util.h.

#define NORMALNODE   "normal"

Definition at line 42 of file util.h.

#define OFFLINESTATUS   "offline"

Definition at line 53 of file util.h.

#define ONLINESTATUS   "online"/* Status of an online client */

Definition at line 52 of file util.h.

#define PINGSTATUS   "ping"

Definition at line 46 of file util.h.

#define safe_str_eq (   a,
 
)    crm_str_eq(a, b, FALSE)

Definition at line 72 of file util.h.

Function Documentation

int char2score ( const char *  score)

Definition at line 230 of file utils.c.

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

Definition at line 486 of file utils.c.

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

Definition at line 656 of file utils.c.

void crm_build_path ( const char *  path_c,
mode_t  mode 
)

Create a directory, including any parent directories needed.

Parameters
[in]path_cPathname of the directory to create
[in]modePermissions to be used (with current umask) when creating
Note
This logs errors but does not return them to the caller.

Definition at line 50 of file io.c.

xmlNode* crm_create_op_xml ( xmlNode *  parent,
const char *  prefix,
const char *  task,
const char *  interval,
const char *  timeout 
)

Create a CIB XML element for an operation.

Parameters
[in]parentIf not NULL, make new XML node a child of this one
[in]prefixGenerate an ID using this prefix
[in]taskOperation task to set
[in]intervalOperation interval to set
[in]timeoutIf not NULL, operation timeout to set
Returns
New XML object on success, NULL otherwise

Definition at line 439 of file operations.c.

int crm_default_remote_port ( void  )

Get the default remote connection TCP port on this host.

Returns
Remote connection TCP port number

Definition at line 1033 of file remote.c.

int crm_exit ( int  rc)

Definition at line 83 of file utils.c.

char* crm_generate_ra_key ( const char *  class,
const char *  provider,
const char *  type 
)

Definition at line 1461 of file utils.c.

char* crm_generate_uuid ( void  )

Definition at line 1390 of file utils.c.

unsigned long long crm_get_interval ( const char *  input)

Definition at line 573 of file utils.c.

long long crm_get_msec ( const char *  input)

Definition at line 598 of file utils.c.

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

gboolean crm_is_true ( const char *  s)

Definition at line 165 of file strings.c.

char* crm_itoa ( int  an_int)

Definition at line 60 of file strings.c.

char* crm_itoa_stack ( int  an_int,
char *  buf,
size_t  len 
)

Definition at line 50 of file strings.c.

char* crm_md5sum ( const char *  buffer)

Definition at line 1424 of file utils.c.

char* crm_meta_name ( const char *  field)

Definition at line 927 of file utils.c.

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

Definition at line 949 of file utils.c.

bool crm_op_needs_metadata ( const char *  rsc_class,
const char *  op 
)

Check whether an operation requires resource agent meta-data.

Parameters
[in]rsc_classResource agent class (or NULL to skip class check)
[in]opOperation action (or NULL to skip op check)
Returns
TRUE if operation needs meta-data, FALSE otherwise
Note
At least one of rsc_class and op must be specified.

Definition at line 635 of file operations.c.

int crm_parse_agent_spec ( const char *  spec,
char **  standard,
char **  provider,
char **  type 
)

Parse a "standard[:provider]:type" agent specification.

Parameters
[in]specAgent specification
[out]standardNewly allocated memory containing agent standard (or NULL)
[out]providerNewly allocated memory containing agent provider (or NULL)
put]type Newly allocated memory containing agent type (or NULL)
Returns
pcmk_ok if the string could be parsed, -EINVAL otherwise
Note
It is acceptable for the type to contain a ':' if the standard supports that. For example, systemd supports the form "systemd:UNIT@A:B".
It is the caller's responsibility to free the returned values.

Definition at line 1512 of file utils.c.

int crm_parse_int ( const char *  text,
const char *  default_text 
)

Definition at line 125 of file strings.c.

bool crm_provider_required ( const char *  standard)

Check whether a resource standard requires a provider to be specified.

Parameters
[in]standardStandard name
Returns
TRUE if standard requires a provider, FALSE otherwise

Definition at line 1481 of file utils.c.

gboolean crm_str_eq ( const char *  a,
const char *  b,
gboolean  use_case 
)

Definition at line 213 of file strings.c.

GHashTable* crm_str_table_dup ( GHashTable *  old_table)

Definition at line 382 of file strings.c.

int crm_str_to_boolean ( const char *  s,
int *  ret 
)

Definition at line 176 of file strings.c.

guint crm_strcase_hash ( gconstpointer  v)

Definition at line 362 of file strings.c.

char* crm_strip_trailing_newline ( char *  str)

Definition at line 197 of file strings.c.

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

Definition at line 433 of file utils.c.

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

Definition at line 217 of file operations.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 174 of file operations.c.

gboolean did_rsc_op_fail ( lrmd_event_data_t event,
int  target_rc 
)

Definition at line 404 of file operations.c.

guint g_str_hash_traditional ( gconstpointer  v)

Definition at line 350 of file strings.c.

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

Definition at line 46 of file operations.c.

bool pcmk_acl_required ( const char *  user)

Definition at line 1236 of file utils.c.

int rsc_op_expected_rc ( lrmd_event_data_t event)

Definition at line 389 of file operations.c.

gboolean safe_str_neq ( const char *  a,
const char *  b 
)

Definition at line 150 of file strings.c.

char* score2char ( int  score)

Definition at line 282 of file utils.c.

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

Definition at line 268 of file utils.c.