pacemaker  2.1.9-49aab99839
Scalable High-Availability cluster resource manager
Data Structures | Enumerations | Functions
pacemaker.h File Reference

High Level API. More...

#include <glib.h>
#include <libxml/tree.h>
#include <crm/common/scheduler.h>
#include <crm/cib/cib_types.h>
#include <crm/stonith-ng.h>
Include dependency graph for pacemaker.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  pcmk_injections_t
 Synthetic cluster events that can be injected into the cluster for running simulations. More...
 

Enumerations

enum  pcmk_sim_flags {
  pcmk_sim_none = 0, pcmk_sim_all_actions = 1 << 0, pcmk_sim_show_pending = 1 << 1, pcmk_sim_process = 1 << 2,
  pcmk_sim_show_scores = 1 << 3, pcmk_sim_show_utilization = 1 << 4, pcmk_sim_simulate = 1 << 5, pcmk_sim_sanitized = 1 << 6,
  pcmk_sim_verbose = 1 << 7
}
 Modify operation of running a cluster simulation. More...
 
enum  pcmk_rc_disp_flags { pcmk_rc_disp_none = 0, pcmk_rc_disp_code = (1 << 0), pcmk_rc_disp_name = (1 << 1), pcmk_rc_disp_desc = (1 << 2) }
 Bit flags to control which fields of result code info are displayed. More...
 

Functions

int pcmk_controller_status (xmlNodePtr *xml, const char *node_name, unsigned int message_timeout_ms)
 Get and output controller status. More...
 
int pcmk_designated_controller (xmlNodePtr *xml, unsigned int message_timeout_ms)
 Get and output designated controller node name. More...
 
void pcmk_free_injections (pcmk_injections_t *injections)
 Free a :pcmk_injections_t structure. More...
 
int pcmk_query_node_info (xmlNodePtr *xml, uint32_t *node_id, char **node_name, char **uuid, char **state, bool *have_quorum, bool *is_remote, bool show_output, unsigned int message_timeout_ms)
 Get and optionally output node info corresponding to a node ID from the controller. More...
 
int pcmk_pacemakerd_status (xmlNodePtr *xml, const char *ipc_name, unsigned int message_timeout_ms)
 Get and output pacemakerd status. More...
 
int pcmk_resource_delete (xmlNodePtr *xml, const char *rsc_id, const char *rsc_type)
 Remove a resource. More...
 
int pcmk_resource_digests (xmlNodePtr *xml, pcmk_resource_t *rsc, const pcmk_node_t *node, GHashTable *overrides)
 Calculate and output resource operation digests. More...
 
int pcmk_simulate (xmlNodePtr *xml, pcmk_scheduler_t *scheduler, const pcmk_injections_t *injections, unsigned int flags, unsigned int section_opts, const char *use_date, const char *input_file, const char *graph_file, const char *dot_file)
 Simulate a cluster's response to events. More...
 
int pcmk_verify (xmlNodePtr *xml, const char *cib_source)
 Verify that a CIB is error-free or output errors and warnings. More...
 
int pcmk_list_nodes (xmlNodePtr *xml, const char *node_types)
 Get nodes list. More...
 
int pcmk_status (xmlNodePtr *xml)
 Output cluster status formatted like crm_mon --output-as=xml More...
 
int pcmk_check_rules (xmlNodePtr *xml, xmlNodePtr input, const crm_time_t *date, const char **rule_ids)
 Check whether each rule in a list is in effect. More...
 
int pcmk_show_result_code (xmlNodePtr *xml, int code, enum pcmk_result_type type, uint32_t flags)
 Display the name and/or description of a result code. More...
 
int pcmk_list_result_codes (xmlNodePtr *xml, enum pcmk_result_type type, uint32_t flags)
 List all valid result codes in a particular family. More...
 
int pcmk_list_alternatives (xmlNodePtr *xml, const char *agent_spec)
 List available providers for the given OCF agent. More...
 
int pcmk_list_agents (xmlNodePtr *xml, char *agent_spec)
 List all agents available for the named standard and/or provider. More...
 
int pcmk_list_providers (xmlNodePtr *xml, const char *agent_spec)
 List all available OCF providers for the given agent. More...
 
int pcmk_list_standards (xmlNodePtr *xml)
 List all available resource agent standards. More...
 
int pcmk_list_cluster_options (xmlNode **xml, bool all)
 List all available cluster options. More...
 
int pcmk_list_fencing_params (xmlNode **xml, bool all)
 List common fencing resource parameters. More...
 
int pcmk_list_primitive_meta (xmlNode **xml, bool all)
 
int pcmk_ticket_constraints (xmlNodePtr *xml, const char *ticket_id)
 Return constraints that apply to the given ticket. More...
 
int pcmk_ticket_delete (xmlNodePtr *xml, const char *ticket_id, bool force)
 Delete a ticket's state from the local cluster site. More...
 
int pcmk_ticket_get_attr (xmlNodePtr *xml, const char *ticket_id, const char *attr_name, const char *attr_default)
 Return the value of a ticket's attribute. More...
 
int pcmk_ticket_info (xmlNodePtr *xml, const char *ticket_id)
 Return information about the given ticket. More...
 
int pcmk_ticket_remove_attr (xmlNodePtr *xml, const char *ticket_id, GList *attr_delete, bool force)
 Remove the given attribute(s) from a ticket. More...
 
int pcmk_ticket_set_attr (xmlNodePtr *xml, const char *ticket_id, GHashTable *attr_set, bool force)
 Set the given attribute(s) on a ticket. More...
 
int pcmk_ticket_state (xmlNodePtr *xml, const char *ticket_id)
 Return a ticket's state XML. More...
 

Detailed Description

High Level API.

Definition in file pacemaker.h.

Enumeration Type Documentation

◆ pcmk_rc_disp_flags

Bit flags to control which fields of result code info are displayed.

Enumerator
pcmk_rc_disp_none 

(Does nothing)

pcmk_rc_disp_code 

Display result code number.

pcmk_rc_disp_name 

Display result code name.

pcmk_rc_disp_desc 

Display result code description.

Definition at line 332 of file pacemaker.h.

◆ pcmk_sim_flags

Modify operation of running a cluster simulation.

Enumerator
pcmk_sim_none 
pcmk_sim_all_actions 
pcmk_sim_show_pending 
pcmk_sim_process 
pcmk_sim_show_scores 
pcmk_sim_show_utilization 
pcmk_sim_simulate 
pcmk_sim_sanitized 
pcmk_sim_verbose 

Definition at line 34 of file pacemaker.h.

Function Documentation

◆ pcmk_check_rules()

int pcmk_check_rules ( xmlNodePtr *  xml,
xmlNodePtr  input,
const crm_time_t date,
const char **  rule_ids 
)

Check whether each rule in a list is in effect.

Parameters
[in,out]xmlThe destination for the result, as an XML tree
[in]inputThe CIB XML to check (if NULL, use current CIB)
[in]dateCheck whether the rule is in effect at this date and time (if NULL, use current date and time)
[in]rule_idsThe IDs of the rules to check, as a NULL- terminated list.
Returns
Standard Pacemaker return code

Definition at line 198 of file pcmk_rule.c.

◆ pcmk_controller_status()

int pcmk_controller_status ( xmlNodePtr *  xml,
const char *  node_name,
unsigned int  message_timeout_ms 
)

Get and output controller status.

Parameters
[in,out]xmlDestination for the result, as an XML tree
[in]node_nameName of node whose status is desired (NULL for DC)
[in]message_timeout_msHow long to wait for a reply from the pacemaker-controld API. If 0, pcmk_ipc_dispatch_sync will be used. Otherwise, pcmk_ipc_dispatch_poll will be used.
Returns
Standard Pacemaker return code

Definition at line 497 of file pcmk_cluster_queries.c.

◆ pcmk_designated_controller()

int pcmk_designated_controller ( xmlNodePtr *  xml,
unsigned int  message_timeout_ms 
)

Get and output designated controller node name.

Parameters
[in,out]xmlDestination for the result, as an XML tree
[in]message_timeout_msHow long to wait for a reply from the pacemaker-controld API. If 0, pcmk_ipc_dispatch_sync will be used. Otherwise, pcmk_ipc_dispatch_poll will be used.
Returns
Standard Pacemaker return code

Definition at line 566 of file pcmk_cluster_queries.c.

◆ pcmk_free_injections()

void pcmk_free_injections ( pcmk_injections_t injections)

Free a :pcmk_injections_t structure.

Parameters
[in,out]injectionsThe structure to be freed

Definition at line 768 of file pcmk_injections.c.

◆ pcmk_list_agents()

int pcmk_list_agents ( xmlNodePtr *  xml,
char *  agent_spec 
)

List all agents available for the named standard and/or provider.

Parameters
[in,out]xmlThe destination for the result, as an XML tree
[in]agent_specSTD[:PROV]
Returns
Standard Pacemaker return code

Definition at line 121 of file pcmk_agents.c.

◆ pcmk_list_alternatives()

int pcmk_list_alternatives ( xmlNodePtr *  xml,
const char *  agent_spec 
)

List available providers for the given OCF agent.

Parameters
[in,out]xmlThe destination for the result, as an XML tree
[in]agent_specResource agent name
Returns
Standard Pacemaker return code

Definition at line 50 of file pcmk_agents.c.

◆ pcmk_list_cluster_options()

int pcmk_list_cluster_options ( xmlNode **  xml,
bool  all 
)

List all available cluster options.

These are options that affect the entire cluster.

Parameters
[in,out]xmlThe destination for the result, as an XML tree
[in]allIf true, include advanced and deprecated options (currently always treated as true)
Returns
Standard Pacemaker return code

Definition at line 48 of file pcmk_options.c.

◆ pcmk_list_fencing_params()

int pcmk_list_fencing_params ( xmlNode **  xml,
bool  all 
)

List common fencing resource parameters.

These are parameters that are available for all fencing resources, regardless of type. They are processed by Pacemaker, rather than by the fence agent or the fencing library.

Parameters
[in,out]xmlThe destination for the result, as an XML tree
[in]allIf true, include advanced and deprecated options (currently always treated as true)
Returns
Standard Pacemaker return code

Definition at line 97 of file pcmk_options.c.

◆ pcmk_list_nodes()

int pcmk_list_nodes ( xmlNodePtr *  xml,
const char *  node_types 
)

Get nodes list.

Parameters
[in,out]xmlThe destination for the result, as an XML tree
[in]node_typesNode type(s) to return (default: all)
Returns
Standard Pacemaker return code

Definition at line 887 of file pcmk_cluster_queries.c.

◆ pcmk_list_primitive_meta()

int pcmk_list_primitive_meta ( xmlNode **  xml,
bool  all 
)

Definition at line 137 of file pcmk_options.c.

◆ pcmk_list_providers()

int pcmk_list_providers ( xmlNodePtr *  xml,
const char *  agent_spec 
)

List all available OCF providers for the given agent.

Parameters
[in,out]xmlThe destination for the result, as an XML tree
[in]agent_specResource agent name
Returns
Standard Pacemaker return code

Definition at line 177 of file pcmk_agents.c.

◆ pcmk_list_result_codes()

int pcmk_list_result_codes ( xmlNodePtr *  xml,
enum pcmk_result_type  type,
uint32_t  flags 
)

List all valid result codes in a particular family.

Parameters
[in,out]xmlThe destination for the result, as an XML tree
[in]typeThe family of result codes to list. Supported values: pcmk_result_legacy, pcmk_result_rc, pcmk_result_exitcode.
[in]flagsGroup of pcmk_rc_disp_flags
Returns
Standard Pacemaker return code

Definition at line 151 of file pcmk_result_code.c.

◆ pcmk_list_standards()

int pcmk_list_standards ( xmlNodePtr *  xml)

List all available resource agent standards.

Parameters
[in,out]xmlThe destination for the result, as an XML tree
Returns
Standard Pacemaker return code

Definition at line 228 of file pcmk_agents.c.

◆ pcmk_pacemakerd_status()

int pcmk_pacemakerd_status ( xmlNodePtr *  xml,
const char *  ipc_name,
unsigned int  message_timeout_ms 
)

Get and output pacemakerd status.

Parameters
[in,out]xmlDestination for the result, as an XML tree
[in]ipc_nameIPC name for request
[in]message_timeout_msHow long to wait for a reply from the pacemakerd API. If 0, pcmk_ipc_dispatch_sync will be used. Otherwise, pcmk_ipc_dispatch_poll will be used.
Returns
Standard Pacemaker return code

Definition at line 785 of file pcmk_cluster_queries.c.

◆ pcmk_query_node_info()

int pcmk_query_node_info ( xmlNodePtr *  xml,
uint32_t *  node_id,
char **  node_name,
char **  uuid,
char **  state,
bool *  have_quorum,
bool *  is_remote,
bool  show_output,
unsigned int  message_timeout_ms 
)

Get and optionally output node info corresponding to a node ID from the controller.

Parameters
[in,out]xmlDestination for the result, as an XML tree
[in,out]node_idID of node whose name to get. If NULL or 0, get the local node name. If not NULL, store the true node ID here on success.
[out]node_nameIf not NULL, where to store the node name
[out]uuidIf not NULL, where to store the node UUID
[out]stateIf not NULL, where to store the membership state
[out]is_remoteIf not NULL, where to store whether the node is a Pacemaker Remote node
[out]have_quorumIf not NULL, where to store whether the node has quorum
[in]show_outputWhether to output the node info
[in]message_timeout_msHow long to wait for a reply from the pacemaker-controld API. If 0, pcmk_ipc_dispatch_sync will be used. Otherwise, pcmk_ipc_dispatch_poll will be used.
Returns
Standard Pacemaker return code
Note
The caller is responsible for freeing *node_name, *uuid, and *state using free().

Definition at line 689 of file pcmk_cluster_queries.c.

◆ pcmk_resource_delete()

int pcmk_resource_delete ( xmlNodePtr *  xml,
const char *  rsc_id,
const char *  rsc_type 
)

Remove a resource.

Parameters
[in,out]xmlDestination for the result, as an XML tree
[in]rsc_idResource to remove
[in]rsc_typeType of the resource ("primitive", "group", etc.)
Returns
Standard Pacemaker return code
Note
This function will return pcmk_rc_ok if rsc_id doesn't exist or if rsc_type is incorrect for rsc_id (deleting something that doesn't exist always succeeds).

Definition at line 148 of file pcmk_resource.c.

◆ pcmk_resource_digests()

int pcmk_resource_digests ( xmlNodePtr *  xml,
pcmk_resource_t rsc,
const pcmk_node_t node,
GHashTable *  overrides 
)

Calculate and output resource operation digests.

Parameters
[out]xmlWhere to store XML with result
[in,out]rscResource to calculate digests for
[in]nodeNode whose operation history should be used
[in]overridesHash table of configuration parameters to override
Returns
Standard Pacemaker return code

Definition at line 236 of file pcmk_resource.c.

◆ pcmk_show_result_code()

int pcmk_show_result_code ( xmlNodePtr *  xml,
int  code,
enum pcmk_result_type  type,
uint32_t  flags 
)

Display the name and/or description of a result code.

Parameters
[in,out]xmlThe destination for the result, as an XML tree
[in]codeThe result code
[in]typeInterpret code as this type of result code. Supported values: pcmk_result_legacy, pcmk_result_rc, pcmk_result_exitcode.
[in]flagsGroup of pcmk_rc_disp_flags
Returns
Standard Pacemaker return code

Definition at line 62 of file pcmk_result_code.c.

◆ pcmk_simulate()

int pcmk_simulate ( xmlNodePtr *  xml,
pcmk_scheduler_t scheduler,
const pcmk_injections_t injections,
unsigned int  flags,
unsigned int  section_opts,
const char *  use_date,
const char *  input_file,
const char *  graph_file,
const char *  dot_file 
)

Simulate a cluster's response to events.

This high-level function essentially implements crm_simulate(8). It operates on an input CIB file and various lists of events that can be simulated. It optionally writes out a variety of artifacts to show the results of the simulation. Output can be modified with various flags.

Parameters
[in,out]xmlThe destination for the result, as an XML tree
[in,out]schedulerScheduler data
[in]injectionsA structure containing cluster events (node up/down, tickets, injected operations)
[in]flagsA bitfield of :pcmk_sim_flags to modify operation of the simulation
[in]section_optsWhich portions of the cluster status output should be displayed?
[in]use_dateDate to set the cluster's time to (may be NULL)
[in]input_fileThe source CIB file, which may be overwritten by this function (may be NULL)
[in]graph_fileWhere to write the XML-formatted transition graph (may be NULL, in which case no file will be written)
[in]dot_fileWhere to write the dot(1) formatted transition graph (may be NULL, in which case no file will be written)
Returns
Standard Pacemaker return code

Definition at line 992 of file pcmk_simulate.c.

◆ pcmk_status()

int pcmk_status ( xmlNodePtr *  xml)

Output cluster status formatted like crm_mon --output-as=xml

Parameters
[in,out]xmlThe destination for the result, as an XML tree
Returns
Standard Pacemaker return code

Definition at line 154 of file pcmk_status.c.

◆ pcmk_ticket_constraints()

int pcmk_ticket_constraints ( xmlNodePtr *  xml,
const char *  ticket_id 
)

Return constraints that apply to the given ticket.

Parameters
[in,out]xmlThe destination for the result, as an XML tree
[in]ticket_idTicket to find constraint for, or NULL for all ticket constraints
Returns
Standard Pacemaker return code

Definition at line 145 of file pcmk_ticket.c.

◆ pcmk_ticket_delete()

int pcmk_ticket_delete ( xmlNodePtr *  xml,
const char *  ticket_id,
bool  force 
)

Delete a ticket's state from the local cluster site.

Parameters
[in,out]xmlThe destination for the result, as an XML tree
[in]ticket_idTicket to delete
[in]forceIf true, delete the ticket even if it has been granted
Returns
Standard Pacemaker return code

Definition at line 234 of file pcmk_ticket.c.

◆ pcmk_ticket_get_attr()

int pcmk_ticket_get_attr ( xmlNodePtr *  xml,
const char *  ticket_id,
const char *  attr_name,
const char *  attr_default 
)

Return the value of a ticket's attribute.

Parameters
[in,out]xmlThe destination for the result, as an XML tree
[in]ticket_idTicket to find attribute value for
[in]attr_nameAttribute's name to find value for
[in]attr_defaultIf either the ticket or the attribute do not exist, use this as the value in xml
Returns
Standard Pacemaker return code

Definition at line 291 of file pcmk_ticket.c.

◆ pcmk_ticket_info()

int pcmk_ticket_info ( xmlNodePtr *  xml,
const char *  ticket_id 
)

Return information about the given ticket.

Parameters
[in,out]xmlThe destination for the result, as an XML tree
[in]ticket_idTicket to find info value for, or NULL for all tickets
Returns
Standard Pacemaker return code

Definition at line 343 of file pcmk_ticket.c.

◆ pcmk_ticket_remove_attr()

int pcmk_ticket_remove_attr ( xmlNodePtr *  xml,
const char *  ticket_id,
GList *  attr_delete,
bool  force 
)

Remove the given attribute(s) from a ticket.

Parameters
[in,out]xmlThe destination for the result, as an XML tree
[in]ticket_idTicket to remove attributes from
[in]attr_deleteA list of attribute names
[in]forceAttempting to remove the granted attribute of ticket_id will cause this function to return EACCES unless force is set to true
Returns
Standard Pacemaker return code

Definition at line 416 of file pcmk_ticket.c.

◆ pcmk_ticket_set_attr()

int pcmk_ticket_set_attr ( xmlNodePtr *  xml,
const char *  ticket_id,
GHashTable *  attr_set,
bool  force 
)

Set the given attribute(s) on a ticket.

Parameters
[in,out]xmlThe destination for the result, as an XML tree
[in]ticket_idTicket to set attributes on
[in]attr_setA hash table of attributes, where keys are the attribute names and the values are the attribute values
[in]forceAttempting to change the granted status of ticket_id will cause this function to return EACCES unless force is set to true
Returns
Standard Pacemaker return code
Note
If no ticket_id attribute exists but attr_set is non-NULL, the ticket will be created with the given attributes.

Definition at line 484 of file pcmk_ticket.c.

◆ pcmk_ticket_state()

int pcmk_ticket_state ( xmlNodePtr *  xml,
const char *  ticket_id 
)

Return a ticket's state XML.

Parameters
[in,out]xmlThe destination for the result, as an XML tree
[in]ticket_idTicket to find state for, or NULL for all tickets
Returns
Standard Pacemaker return code
Note
If ticket_id is not NULL and more than one ticket exists with that ID, this function returns pcmk_rc_duplicate_id.

Definition at line 533 of file pcmk_ticket.c.

◆ pcmk_verify()

int pcmk_verify ( xmlNodePtr *  xml,
const char *  cib_source 
)

Verify that a CIB is error-free or output errors and warnings.

This high-level function essentially implements crm_verify(8). It operates on an input CIB file, which can be inputted through one of several ways. It writes out XML-formatted output.

Parameters
[in,out]xmlThe destination for the result, as an XML tree
[in]cib_sourceSource of the CIB: NULL -> use live cib, "-" -> stdin "<..." -> xml str, otherwise -> xml file name
Returns
Standard Pacemaker return code

Definition at line 119 of file pcmk_verify.c.