pacemaker 3.0.1-16e74fc4da
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
pcmk_fence.c File Reference
#include <crm_internal.h>
#include <crm/common/mainloop.h>
#include <crm/common/results.h>
#include <crm/common/output.h>
#include <crm/common/output_internal.h>
#include <crm/stonith-ng.h>
#include <crm/fencing/internal.h>
#include <glib.h>
#include <libxml/tree.h>
#include <pacemaker.h>
#include <pacemaker-internal.h>
#include "libpacemaker_private.h"
Include dependency graph for pcmk_fence.c:

Go to the source code of this file.

Functions

int pcmk__request_fencing (stonith_t *st, const char *target, const char *action, const char *name, unsigned int timeout, unsigned int tolerance, int delay, char **reason)
 Ask the cluster to perform fencing.
 
int pcmk_request_fencing (xmlNodePtr *xml, const char *target, const char *action, const char *name, unsigned int timeout, unsigned int tolerance, int delay, char **reason)
 Ask the cluster to perform fencing.
 
int pcmk__fence_history (pcmk__output_t *out, stonith_t *st, const char *target, unsigned int timeout, int verbose, bool broadcast, bool cleanup)
 List the fencing operations that have occurred for a specific node.
 
int pcmk_fence_history (xmlNodePtr *xml, const char *target, unsigned int timeout, bool quiet, int verbose, bool broadcast, bool cleanup)
 List the fencing operations that have occurred for a specific node.
 
int pcmk__fence_installed (pcmk__output_t *out, stonith_t *st)
 List all installed fence agents.
 
int pcmk_fence_installed (xmlNodePtr *xml, unsigned int timeout)
 List all installed fence agents.
 
int pcmk__fence_last (pcmk__output_t *out, const char *target, bool as_nodeid)
 When was a device last fenced?
 
int pcmk_fence_last (xmlNodePtr *xml, const char *target, bool as_nodeid)
 When was a device last fenced?
 
int pcmk__fence_list_targets (pcmk__output_t *out, stonith_t *st, const char *device_id, unsigned int timeout)
 List nodes that can be fenced.
 
int pcmk_fence_list_targets (xmlNodePtr *xml, const char *device_id, unsigned int timeout)
 List nodes that can be fenced.
 
int pcmk__fence_metadata (pcmk__output_t *out, stonith_t *st, const char *agent, unsigned int timeout)
 Get metadata for a fence agent.
 
int pcmk_fence_metadata (xmlNodePtr *xml, const char *agent, unsigned int timeout)
 Get metadata for a fence agent.
 
int pcmk__fence_registered (pcmk__output_t *out, stonith_t *st, const char *target, unsigned int timeout)
 List registered fence devices.
 
int pcmk_fence_registered (xmlNodePtr *xml, const char *target, unsigned int timeout)
 List registered fence devices.
 
int pcmk__fence_register_level (stonith_t *st, const char *target, int fence_level, GList *devices)
 Register a fencing level for a specific node, node regex, or attribute.
 
int pcmk_fence_register_level (xmlNodePtr *xml, const char *target, int fence_level, GList *devices)
 Register a fencing topology level.
 
int pcmk__fence_unregister_level (stonith_t *st, const char *target, int fence_level)
 Unregister a fencing level for specific node, node regex, or attribute.
 
int pcmk_fence_unregister_level (xmlNodePtr *xml, const char *target, int fence_level)
 Unregister a fencing topology level.
 
int pcmk__fence_validate (pcmk__output_t *out, stonith_t *st, const char *agent, const char *id, GHashTable *params, unsigned int timeout)
 Validate a fence device configuration.
 
int pcmk_fence_validate (xmlNodePtr *xml, const char *agent, const char *id, GHashTable *params, unsigned int timeout)
 Validate a fence device configuration.
 
int pcmk__get_fencing_history (stonith_t *st, stonith_history_t **stonith_history, enum pcmk__fence_history fence_history)
 Fetch fencing history, optionally reducing it.
 

Function Documentation

◆ pcmk__fence_history()

int pcmk__fence_history ( pcmk__output_t * out,
stonith_t * st,
const char * target,
unsigned int timeout,
int verbose,
bool broadcast,
bool cleanup )

List the fencing operations that have occurred for a specific node.

Note
This is the internal version of pcmk_fence_history(). External users of the pacemaker API should use that function instead.
out should be initialized with pcmk__output_new() before calling this function and destroyed with out->finish and pcmk__output_free() before reusing it with any other functions in this library.
Parameters
[in,out]outThe output functions structure
[in,out]stA connection to the fencer API
[in]targetThe node to get history for
[in]timeoutHow long to wait for operation to complete (in ms)
[in]verboseInclude additional output
[in]broadcastGather fencing history from all nodes
[in]cleanupClean up fencing history after listing
Returns
Standard Pacemaker return code

Definition at line 254 of file pcmk_fence.c.

◆ pcmk__fence_installed()

int pcmk__fence_installed ( pcmk__output_t * out,
stonith_t * st )

List all installed fence agents.

Note
This is the internal version of pcmk_fence_installed(). External users of the pacemaker API should use that function instead.
out should be initialized with pcmk__output_new() before calling this function and destroyed with out->finish and pcmk__output_free() before reusing it with any other functions in this library.
Parameters
[in,out]outThe output functions structure
[in,out]stA connection to the fencer API
Returns
Standard Pacemaker return code

Definition at line 354 of file pcmk_fence.c.

◆ pcmk__fence_last()

int pcmk__fence_last ( pcmk__output_t * out,
const char * target,
bool as_nodeid )

When was a device last fenced?

Note
This is the internal version of pcmk_fence_last(). External users of the pacemaker API should use that function instead.
out should be initialized with pcmk__output_new() before calling this function and destroyed with out->finish and pcmk__output_free() before reusing it with any other functions in this library.
Parameters
[in,out]outThe output functions structure.
[in]targetThe node that was fenced.
[in]as_nodeid
Returns
Standard Pacemaker return code

Definition at line 397 of file pcmk_fence.c.

◆ pcmk__fence_list_targets()

int pcmk__fence_list_targets ( pcmk__output_t * out,
stonith_t * st,
const char * device_id,
unsigned int timeout )

List nodes that can be fenced.

Note
This is the internal version of pcmk_fence_list_targets(). External users of the pacemaker API should use that function instead.
out should be initialized with pcmk__output_new() before calling this function and destroyed with out->finish and pcmk__output_free() before reusing it with any other functions in this library.
Parameters
[in,out]outThe output functions structure
[in,out]stA connection to the fencer API
[in]device_idResource ID of fence device to check
[in]timeoutHow long to wait for operation to complete (in ms)
Returns
Standard Pacemaker return code

Definition at line 433 of file pcmk_fence.c.

◆ pcmk__fence_metadata()

int pcmk__fence_metadata ( pcmk__output_t * out,
stonith_t * st,
const char * agent,
unsigned int timeout )

Get metadata for a fence agent.

Note
This is the internal version of pcmk_fence_metadata(). External users of the pacemaker API should use that function instead.
out should be initialized with pcmk__output_new() before calling this function and destroyed with out->finish and pcmk__output_free() before reusing it with any other functions in this library.
Parameters
[in,out]outThe output functions structure
[in,out]stA connection to the fencer API
[in]agentThe fence agent to get metadata for
[in]timeoutHow long to wait for the operation to complete (in ms)
Returns
Standard Pacemaker return code

Definition at line 479 of file pcmk_fence.c.

◆ pcmk__fence_register_level()

int pcmk__fence_register_level ( stonith_t * st,
const char * target,
int fence_level,
GList * devices )

Register a fencing level for a specific node, node regex, or attribute.

Note
This is the internal version of pcmk_fence_register_level(). External users of the pacemaker API should use that function instead.

target can take three different forms:

  • name=value, in which case target is an attribute.
  • @pattern, in which case target is a node regex.
  • Otherwise, target is a node name.
Parameters
[in,out]stA connection to the fencer API
[in]targetThe object to register a fencing level for
[in]fence_levelIndex number of level to add
[in]devicesDevices to use in level as a list of char *
Returns
Standard Pacemaker return code

Definition at line 564 of file pcmk_fence.c.

◆ pcmk__fence_registered()

int pcmk__fence_registered ( pcmk__output_t * out,
stonith_t * st,
const char * target,
unsigned int timeout )

List registered fence devices.

Note
This is the internal version of pcmk_fence_metadata(). External users of the pacemaker API should use that function instead.
out should be initialized with pcmk__output_new() before calling this function and destroyed with out->finish and pcmk__output_free() before reusing it with any other functions in this library.
Parameters
[in,out]outThe output functions structure
[in,out]stA connection to the fencer API
[in]targetIf not NULL, return only devices that can fence this
[in]timeoutHow long to wait for the operation to complete (in ms)
Returns
Standard Pacemaker return code

Definition at line 516 of file pcmk_fence.c.

◆ pcmk__fence_unregister_level()

int pcmk__fence_unregister_level ( stonith_t * st,
const char * target,
int fence_level )

Unregister a fencing level for specific node, node regex, or attribute.

Note
This is the internal version of pcmk_fence_unregister_level(). External users of the pacemaker API should use that function instead.

target can take three different forms:

  • name=value, in which case target is an attribute.
  • @pattern, in which case target is a node regex.
  • Otherwise, target is a node name.
Parameters
[in,out]stA connection to the fencer API
[in]targetThe object to unregister a fencing level for
[in]fence_levelIndex number of level to remove
Returns
Standard Pacemaker return code

Definition at line 592 of file pcmk_fence.c.

◆ pcmk__fence_validate()

int pcmk__fence_validate ( pcmk__output_t * out,
stonith_t * st,
const char * agent,
const char * id,
GHashTable * params,
unsigned int timeout )

Validate a fence device configuration.

Note
This is the internal version of pcmk_stonith_validate(). External users of the pacemaker API should use that function instead.
out should be initialized with pcmk__output_new() before calling this function and destroyed with out->finish and pcmk__output_free() before reusing it with any other functions in this library.
Parameters
[in,out]outThe output functions structure
[in,out]stA connection to the fencer API
[in]agentThe agent to validate (for example, "fence_xvm")
[in]idFence device ID (may be NULL)
[in]paramsFence device configuration parameters
[in]timeoutHow long to wait for the operation to complete (in ms)
Returns
Standard Pacemaker return code

Definition at line 618 of file pcmk_fence.c.

◆ pcmk__get_fencing_history()

int pcmk__get_fencing_history ( stonith_t * st,
stonith_history_t ** stonith_history,
enum pcmk__fence_history fence_history )

Fetch fencing history, optionally reducing it.

Parameters
[in,out]stA connection to the fencer API
[out]stonith_historyDestination for storing the history
[in]fence_historyHow much of the fencing history to display
Returns
Standard Pacemaker return code

Definition at line 653 of file pcmk_fence.c.

◆ pcmk__request_fencing()

int pcmk__request_fencing ( stonith_t * st,
const char * target,
const char * action,
const char * name,
unsigned int timeout,
unsigned int tolerance,
int delay,
char ** reason )

Ask the cluster to perform fencing.

Note
This is the internal version of pcmk_request_fencing(). External users of the pacemaker API should use that function instead.
Parameters
[in,out]stA connection to the fencer API
[in]targetThe node that should be fenced
[in]actionThe fencing action (on, off, reboot) to perform
[in]nameWho requested the fence action?
[in]timeoutHow long to wait for operation to complete (in ms)
[in]toleranceIf a successful action for target happened within this many milliseconds, return success without performing the action again
[in]delayApply this delay (in milliseconds) before initiating fencing action (a value of -1 applies no delay and disables any fencing delay from pcmk_delay_base and pcmk_delay_max)
[out]reasonIf not NULL, where to put descriptive failure reason
Returns
Standard Pacemaker return code
Note
If reason is not NULL, the caller is responsible for freeing its returned value.
Todo
delay is eventually used with pcmk__create_timer() and should be guint

Definition at line 195 of file pcmk_fence.c.

◆ pcmk_fence_history()

int pcmk_fence_history ( xmlNodePtr * xml,
const char * target,
unsigned int timeout,
bool quiet,
int verbose,
bool broadcast,
bool cleanup )

List the fencing operations that have occurred for a specific node.

Note
If xml is not NULL, it will be freed first and the previous contents lost.
Parameters
[in,out]xmlThe destination for the result, as an XML tree
[in]targetThe node to get history for
[in]timeoutHow long to wait for operation to complete (in ms)
[in]quietSuppress most output
[in]verboseInclude additional output
[in]broadcastGather fencing history from all nodes
[in]cleanupClean up fencing history after listing
Returns
Standard Pacemaker return code

Definition at line 330 of file pcmk_fence.c.

◆ pcmk_fence_installed()

int pcmk_fence_installed ( xmlNodePtr * xml,
unsigned int timeout )

List all installed fence agents.

Parameters
[in,out]xmlThe destination for the result, as an XML tree (if not NULL, previous contents will be freed and lost)
[in]timeoutIgnored
Returns
Standard Pacemaker return code

Definition at line 377 of file pcmk_fence.c.

◆ pcmk_fence_last()

int pcmk_fence_last ( xmlNodePtr * xml,
const char * target,
bool as_nodeid )

When was a device last fenced?

Parameters
[in,out]xmlThe destination for the result, as an XML tree (if not NULL, previous contents will be freed and lost)
[in]targetThe node that was fenced
[in]as_nodeidIf true, target has node ID rather than name
Returns
Standard Pacemaker return code

Definition at line 415 of file pcmk_fence.c.

◆ pcmk_fence_list_targets()

int pcmk_fence_list_targets ( xmlNodePtr * xml,
const char * device_id,
unsigned int timeout )

List nodes that can be fenced.

Parameters
[in,out]xmlThe destination for the result, as an XML tree (if not NULL, previous contents will be freed and lost)
[in]device_idResource ID of fence device to check
[in]timeoutHow long to wait for operation to complete (in ms)
Returns
Standard Pacemaker return code

Definition at line 459 of file pcmk_fence.c.

◆ pcmk_fence_metadata()

int pcmk_fence_metadata ( xmlNodePtr * xml,
const char * agent,
unsigned int timeout )

Get metadata for a fence agent.

Note
If xml is not NULL, it will be freed first and the previous contents lost.
Parameters
[in,out]xmlThe destination for the result, as an XML tree (if not NULL, previous contents will be freed and lost)
[in]agentThe fence agent to get metadata for
[in]timeoutHow long to wait for operation to complete (in ms)
Returns
Standard Pacemaker return code

Definition at line 496 of file pcmk_fence.c.

◆ pcmk_fence_register_level()

int pcmk_fence_register_level ( xmlNodePtr * xml,
const char * target,
int fence_level,
GList * devices )

Register a fencing topology level.

Parameters
[in,out]xmlThe destination for the result, as an XML tree (if not NULL, previous contents will be freed and lost)
[in]targetWhat fencing level targets (as "name=value" to target by given node attribute, or "@pattern" to target by node name pattern, or a node name)
[in]fence_levelIndex number of level to add
[in]devicesDevices to use in level as a list of char *
Returns
Standard Pacemaker return code

Definition at line 571 of file pcmk_fence.c.

◆ pcmk_fence_registered()

int pcmk_fence_registered ( xmlNodePtr * xml,
const char * target,
unsigned int timeout )

List registered fence devices.

Parameters
[in,out]xmlThe destination for the result, as an XML tree (if not NULL, previous contents will be freed and lost)
[in]targetIf not NULL, return only devices that can fence this
[in]timeoutHow long to wait for operation to complete (in ms)
Returns
Standard Pacemaker return code

Definition at line 544 of file pcmk_fence.c.

◆ pcmk_fence_unregister_level()

int pcmk_fence_unregister_level ( xmlNodePtr * xml,
const char * target,
int fence_level )

Unregister a fencing topology level.

Parameters
[in,out]xmlThe destination for the result, as an XML tree (if not NULL, previous contents will be freed and lost)
[in]targetWhat fencing level targets (as "name=value" to target by given node attribute, or "@pattern" to target by node name pattern, or a node name)
[in]fence_levelIndex number of level to remove
Returns
Standard Pacemaker return code

Definition at line 598 of file pcmk_fence.c.

◆ pcmk_fence_validate()

int pcmk_fence_validate ( xmlNodePtr * xml,
const char * agent,
const char * id,
GHashTable * params,
unsigned int timeout )

Validate a fence device configuration.

Parameters
[in,out]xmlThe destination for the result, as an XML tree (if not NULL, previous contents will be freed and lost)
[in]agentThe agent to validate (for example, "fence_xvm")
[in]idFence device ID (may be NULL)
[in]paramsFence device configuration parameters
[in]timeoutHow long to wait for operation to complete (in ms)
Returns
Standard Pacemaker return code

Definition at line 632 of file pcmk_fence.c.

◆ pcmk_request_fencing()

int pcmk_request_fencing ( xmlNodePtr * xml,
const char * target,
const char * action,
const char * name,
unsigned int timeout,
unsigned int tolerance,
int delay,
char ** reason )

Ask the cluster to perform fencing.

Parameters
[in,out]xmlThe destination for the result, as an XML tree
[in]targetThe node that should be fenced
[in]actionThe fencing action (on, off, reboot) to perform
[in]nameWho requested the fence action?
[in]timeoutHow long to wait for operation to complete (in ms)
[in]toleranceIf a successful action for target happened within this many ms, return 0 without performing the action again
[in]delayApply this delay (in milliseconds) before initiating fencing action (-1 applies no delay and also disables any fencing delay from pcmk_delay_base and pcmk_delay_max)
[out]reasonIf not NULL, where to put descriptive failure reason
Returns
Standard Pacemaker return code
Note
If reason is not NULL, the caller is responsible for freeing its returned value.

Definition at line 231 of file pcmk_fence.c.

Variable Documentation

◆ action

const char* action

Definition at line 32 of file pcmk_fence.c.

◆ delay

int delay

Definition at line 36 of file pcmk_fence.c.

◆ name

char* name

Definition at line 33 of file pcmk_fence.c.

◆ result

Definition at line 37 of file pcmk_fence.c.

◆ st

stonith_t* st

Definition at line 30 of file pcmk_fence.c.

◆ target

const char* target

Definition at line 31 of file pcmk_fence.c.

◆ timeout

unsigned int timeout

Definition at line 34 of file pcmk_fence.c.

◆ tolerance

unsigned int tolerance

Definition at line 35 of file pcmk_fence.c.