pacemaker  1.1.15-e174ec8
Scalable High-Availability cluster resource manager
Macros | Functions | Variables
services.c File Reference
#include <crm_internal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <dirent.h>
#include <fcntl.h>
#include <crm/crm.h>
#include <crm/common/mainloop.h>
#include <crm/services.h>
#include <crm/msg_xml.h>
#include "services_private.h"
Include dependency graph for services.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 

Functions

svc_action_tservices_action_create (const char *name, const char *action, int interval, int timeout)
 
const char * resources_find_service_class (const char *agent)
 
svc_action_tresources_action_create (const char *name, const char *standard, const char *provider, const char *agent, const char *action, int interval, int timeout, GHashTable *params, enum svc_action_flags flags)
 Create a new resource action. More...
 
svc_action_tservices_action_create_generic (const char *exec, const char *args[])
 
void services_action_cleanup (svc_action_t *op)
 
void services_action_free (svc_action_t *op)
 
gboolean cancel_recurring_action (svc_action_t *op)
 
gboolean services_action_cancel (const char *name, const char *action, int interval)
 
gboolean services_action_kick (const char *name, const char *action, int interval)
 
void services_add_inflight_op (svc_action_t *op)
 
gboolean services_action_async (svc_action_t *op, void(*action_callback)(svc_action_t *))
 
gboolean is_op_blocked (const char *rsc)
 
void handle_blocked_ops (void)
 
gboolean services_action_sync (svc_action_t *op)
 
GList * get_directory_list (const char *root, gboolean files, gboolean executable)
 Get a list of files or directories in a given path. More...
 
GList * services_list (void)
 
GList * resources_list_standards (void)
 
GList * resources_list_providers (const char *standard)
 Get a list of providers. More...
 
GList * resources_list_agents (const char *standard, const char *provider)
 Get a list of resource agents. More...
 

Variables

GHashTable * recurring_actions = NULL
 
GList * blocked_ops = NULL
 
GList * inflight_ops = NULL
 

Macro Definition Documentation

§ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 22 of file services.c.

Function Documentation

§ cancel_recurring_action()

gboolean cancel_recurring_action ( svc_action_t op)

Definition at line 459 of file services.c.

§ get_directory_list()

GList* get_directory_list ( const char *  root,
gboolean  files,
gboolean  executable 
)

Get a list of files or directories in a given path.

Parameters
[in]rootfull path to a directory to read
[in]filesreturn list of files if TRUE or directories if FALSE
[in]executableif TRUE and files is TRUE, only return executable files
Returns
a list of what was found. The list items are char *.
Note
It is the caller's responsibility to free the result with g_list_free_full(list, free).

Definition at line 735 of file services.c.

§ handle_blocked_ops()

void handle_blocked_ops ( void  )

Definition at line 662 of file services.c.

§ is_op_blocked()

gboolean is_op_blocked ( const char *  rsc)

Definition at line 646 of file services.c.

§ resources_action_create()

svc_action_t* resources_action_create ( const char *  name,
const char *  standard,
const char *  provider,
const char *  agent,
const char *  action,
int  interval,
int  timeout,
GHashTable *  params,
enum svc_action_flags  flags 
)

Create a new resource action.

Parameters
[in]namename of resource
[in]standardresource agent standard (ocf, lsb, etc.)
[in]providerresource agent provider
[in]agentresource agent name
[in]actionaction (start, stop, monitor, etc.)
[in]intervalhow often to repeat this action, in milliseconds (if 0, execute only once)
[in]timeoutconsider action failed if it does not complete in this many milliseconds
[in]paramsaction parameters
Returns
newly allocated action instance
Postcondition
After the call, 'params' is owned, and later free'd by the svc_action_t result
Note
The caller is responsible for freeing the return value using services_action_free().

Definition at line 103 of file services.c.

§ resources_find_service_class()

const char* resources_find_service_class ( const char *  agent)

Find the first class that can provide service::${agent}

Parameters
[in]agentwhich agent to search for
Returns
NULL, or the first class that provides the named agent

Definition at line 67 of file services.c.

§ resources_list_agents()

GList* resources_list_agents ( const char *  standard,
const char *  provider 
)

Get a list of resource agents.

Parameters
[in]standardlist agents using this standard (e.g. ocf, lsb, etc.) (or NULL for all)
[in]providerlist agents from this provider (or NULL for all)
Returns
a list of resource agents. The list items are char *.
Note
The caller is responsible for freeing the result using g_list_free_full(list, free).

Definition at line 810 of file services.c.

§ resources_list_providers()

GList* resources_list_providers ( const char *  standard)

Get a list of providers.

Parameters
[in]standardlist providers of this standard (e.g. ocf, lsb, etc.)
Returns
a list of providers as char * list items (or NULL if standard does not support providers)
Note
The caller is responsible for freeing the result using g_list_free_full(list, free).

Definition at line 800 of file services.c.

§ resources_list_standards()

GList* resources_list_standards ( void  )

Get list of available standards

Returns
a list of resource standards. The list items are char *. This list must be destroyed using g_list_free_full(list, free).

Definition at line 755 of file services.c.

§ services_action_async()

gboolean services_action_async ( svc_action_t op,
void(*)(svc_action_t *)  action_callback 
)

Run an action asynchronously.

Parameters
[in]opservices action data
[in]action_callbackcallback for when the action completes
Return values
TRUEsuccesfully started execution
FALSEfailed to start execution, no callback will be received

Definition at line 618 of file services.c.

§ services_action_cancel()

gboolean services_action_cancel ( const char *  name,
const char *  action,
int  interval 
)

Definition at line 476 of file services.c.

§ services_action_cleanup()

void services_action_cleanup ( svc_action_t op)

Definition at line 381 of file services.c.

§ services_action_create()

svc_action_t* services_action_create ( const char *  name,
const char *  action,
int  interval,
int  timeout 
)

Definition at line 61 of file services.c.

§ services_action_create_generic()

svc_action_t* services_action_create_generic ( const char *  exec,
const char *  args[] 
)

Utilize services API to execute an arbitrary command.

This API has useful infrastructure in place to be able to run a command in the background and get notified via a callback when the command finishes.

Parameters
[in]execcommand to execute
[in]argsarguments to the command, NULL terminated
Returns
a svc_action_t object, used to pass to the execute function (services_action_sync() or services_action_async()) and is provided to the callback.

Definition at line 329 of file services.c.

§ services_action_free()

void services_action_free ( svc_action_t op)

Definition at line 417 of file services.c.

§ services_action_kick()

gboolean services_action_kick ( const char *  name,
const char *  action,
int  interval 
)

Kick a recurring action so it is scheduled immediately for re-execution

Definition at line 514 of file services.c.

§ services_action_sync()

gboolean services_action_sync ( svc_action_t op)

Definition at line 703 of file services.c.

§ services_add_inflight_op()

void services_add_inflight_op ( svc_action_t op)

Definition at line 603 of file services.c.

§ services_list()

GList* services_list ( void  )

Get a list of services

Returns
a list of services. The list items are gchar *. This list must be destroyed using g_list_free_full(list, free).

Definition at line 741 of file services.c.

Variable Documentation

§ blocked_ops

GList* blocked_ops = NULL

Definition at line 55 of file services.c.

§ inflight_ops

GList* inflight_ops = NULL

Definition at line 58 of file services.c.

§ recurring_actions

GHashTable* recurring_actions = NULL

Definition at line 51 of file services.c.