pacemaker  2.1.0-7c3f660
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
pcmk_fence.c File Reference
#include <crm_internal.h>
#include <crm/common/mainloop.h>
#include <crm/common/results.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 <pcmki/pcmki_output.h>
#include <pcmki/pcmki_fence.h>
Include dependency graph for pcmk_fence.c:

Go to the source code of this file.

Functions

int pcmk__fence_action (stonith_t *st, const char *target, const char *action, const char *name, unsigned int timeout, unsigned int tolerance, int delay)
 Perform a STONITH action. More...
 
int pcmk__fence_history (pcmk__output_t *out, stonith_t *st, char *target, unsigned int timeout, int verbose, bool broadcast, bool cleanup)
 List the fencing operations that have occurred for a specific node. More...
 
int pcmk__fence_installed (pcmk__output_t *out, stonith_t *st, unsigned int timeout)
 List all installed STONITH agents. More...
 
int pcmk__fence_last (pcmk__output_t *out, const char *target, bool as_nodeid)
 When was a device last fenced? More...
 
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. More...
 
int pcmk__fence_metadata (pcmk__output_t *out, stonith_t *st, char *agent, unsigned int timeout)
 Get metadata for a resource. More...
 
int pcmk__fence_registered (pcmk__output_t *out, stonith_t *st, char *target, unsigned int timeout)
 List registered fence devices. More...
 
int pcmk__fence_register_level (stonith_t *st, char *target, int fence_level, stonith_key_value_t *devices)
 Register a fencing level for a specific node, node regex, or attribute. More...
 
int pcmk__fence_unregister_level (stonith_t *st, char *target, int fence_level)
 Unregister a fencing level for a specific node, node regex, or attribute. More...
 
int pcmk__fence_validate (pcmk__output_t *out, stonith_t *st, const char *agent, const char *id, stonith_key_value_t *params, unsigned int timeout)
 Validate a STONITH device configuration. More...
 
stonith_history_tpcmk__reduce_fence_history (stonith_history_t *history)
 Reduce the STONITH history. More...
 

Function Documentation

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

Perform a STONITH action.

Note
This is the internal version of pcmk_fence_action(). External users of the pacemaker API should use that function instead.
Parameters
[in]stA connection to the STONITH API.
[in]targetThe node receiving the action.
[in]actionThe action to perform.
[in]nameWho requested the fence action?
[in]timeoutHow long to wait for the 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 a fencing delay. Value -1 means disable also any static/random fencing delays from pcmk_delay_base/max
Returns
Standard Pacemaker return code

Definition at line 136 of file pcmk_fence.c.

int pcmk__fence_history ( pcmk__output_t out,
stonith_t st,
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]stA connection to the STONITH API.
[in]targetThe node to get history for.
[in]timeoutHow long to wait for the 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 173 of file pcmk_fence.c.

int pcmk__fence_installed ( pcmk__output_t out,
stonith_t st,
unsigned int  timeout 
)

List all installed STONITH 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]stA connection to the STONITH API.
[in]timeoutHow long to wait for the operation to complete (in ms).
Returns
Standard Pacemaker return code

Definition at line 259 of file pcmk_fence.c.

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 299 of file pcmk_fence.c.

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]stA connection to the STONITH API
[in]device_idResource ID of fence device to check
[in]timeoutHow long to wait for the operation to complete (in ms)
Returns
Standard Pacemaker return code

Definition at line 335 of file pcmk_fence.c.

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

Get metadata for a resource.

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]stA connection to the STONITH 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 380 of file pcmk_fence.c.

int pcmk__fence_register_level ( stonith_t st,
char *  target,
int  fence_level,
stonith_key_value_t 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.
  • , in which case target is a node regex.
  • Otherwise, target is a node name.
Parameters
[in]stA connection to the STONITH API.
[in]targetThe object to register a fencing level for.
[in]fence_levelIndex number of level to add.
[in]devicesDevices to use in level.
Returns
Standard Pacemaker return code

Definition at line 462 of file pcmk_fence.c.

int pcmk__fence_registered ( pcmk__output_t out,
stonith_t st,
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]stA connection to the STONITH API.
[in]targetIf not NULL, only return devices that can fence this node.
[in]timeoutHow long to wait for the operation to complete (in ms).
Returns
Standard Pacemaker return code

Definition at line 416 of file pcmk_fence.c.

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

Unregister a fencing level for a 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.
  • , in which case target is a node regex.
  • Otherwise, target is a node name.
Parameters
[in]stA connection to the STONITH 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 476 of file pcmk_fence.c.

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

Validate a STONITH 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]stA connection to the STONITH API.
[in]agentThe agent to validate (for example, "fence_xvm").
[in]idSTONITH device ID (may be NULL).
[in]paramsSTONITH device configuration parameters.
[in]timeoutHow long to wait for the operation to complete (in ms).
Returns
Standard Pacemaker return code

Definition at line 488 of file pcmk_fence.c.

stonith_history_t* pcmk__reduce_fence_history ( stonith_history_t history)

Reduce the STONITH history.

STONITH history is reduced as follows:

  • The last successful action of every action-type and target is kept
  • For failed actions, who failed is kept
  • All actions in progress are kept
Parameters
[in]historyList of STONITH actions
Returns
The reduced history

Definition at line 523 of file pcmk_fence.c.

Variable Documentation

const char* action

Definition at line 30 of file pcmk_fence.c.

int delay

Definition at line 34 of file pcmk_fence.c.

char* name

Definition at line 31 of file pcmk_fence.c.

int rc

Definition at line 35 of file pcmk_fence.c.

stonith_t* st

Definition at line 28 of file pcmk_fence.c.

const char* target

Definition at line 29 of file pcmk_fence.c.

unsigned int timeout

Definition at line 32 of file pcmk_fence.c.

unsigned int tolerance

Definition at line 33 of file pcmk_fence.c.