21 #include <sys/param.h> 32 unpack_action(
synapse_t * parent, xmlNode * xml_action)
36 xmlNode *rsc_xml = NULL;
39 crm_err(
"Actions must have an id!");
72 value = g_hash_table_lookup(action->
params,
"CRM_meta_timeout");
78 value = g_hash_table_lookup(action->
params,
"CRM_meta_start_delay");
83 value = g_hash_table_lookup(action->
params,
"CRM_meta_interval");
88 value = g_hash_table_lookup(action->
params,
"CRM_meta_can_fail");
117 unpack_synapse(
crm_graph_t * new_graph, xmlNode * xml_synapse)
119 const char *value = NULL;
120 xmlNode *inputs = NULL;
121 xmlNode *action_set = NULL;
124 CRM_CHECK(xml_synapse != NULL,
return NULL);
125 crm_trace(
"looking in synapse %s",
ID(xml_synapse));
127 new_synapse = calloc(1,
sizeof(
synapse_t));
140 new_synapse->
graph = new_graph;
144 for (action_set = __xml_first_child(xml_synapse); action_set != NULL;
145 action_set = __xml_next(action_set)) {
146 if (
crm_str_eq((
const char *)action_set->name,
"action_set", TRUE)) {
147 xmlNode *action = NULL;
149 for (action = __xml_first_child(action_set); action != NULL;
150 action = __xml_next(action)) {
151 crm_action_t *new_action = unpack_action(new_synapse, action);
153 if (new_action == NULL) {
159 crm_trace(
"Adding action %d to synapse %d", new_action->
id, new_synapse->
id);
161 new_synapse->
actions = g_list_append(new_synapse->
actions, new_action);
166 crm_trace(
"look for inputs in synapse %s",
ID(xml_synapse));
168 for (inputs = __xml_first_child(xml_synapse); inputs != NULL; inputs = __xml_next(inputs)) {
169 if (
crm_str_eq((
const char *)inputs->name,
"inputs", TRUE)) {
170 xmlNode *trigger = NULL;
172 for (trigger = __xml_first_child(inputs); trigger != NULL;
173 trigger = __xml_next(trigger)) {
174 xmlNode *input = NULL;
176 for (input = __xml_first_child(trigger); input != NULL; input = __xml_next(input)) {
177 crm_action_t *new_input = unpack_action(new_synapse, input);
179 if (new_input == NULL) {
183 crm_trace(
"Adding input %d to synapse %d", new_input->
id, new_synapse->
id);
185 new_synapse->
inputs = g_list_append(new_synapse->
inputs, new_input);
210 const char *t_id = NULL;
211 const char *time = NULL;
212 xmlNode *synapse = NULL;
225 new_graph->
source = strdup(reference);
227 new_graph->
source = strdup(
"unknown");
230 if (xml_graph != NULL) {
255 for (synapse = __xml_first_child(xml_graph); synapse != NULL; synapse = __xml_next(synapse)) {
256 if (
crm_str_eq((
const char *)synapse->name,
"synapse", TRUE)) {
257 synapse_t *new_synapse = unpack_synapse(new_graph, synapse);
259 if (new_synapse != NULL) {
265 crm_debug(
"Unpacked transition %d: %d actions in %d synapses",
279 g_hash_table_destroy(action->
params);
291 while (g_list_length(synapse->
actions) > 0) {
295 destroy_action(action);
298 while (g_list_length(synapse->
inputs) > 0) {
301 synapse->
inputs = g_list_remove(synapse->
inputs, action);
302 destroy_action(action);
313 while (g_list_length(graph->
synapses) > 0) {
317 destroy_synapse(synapse);
330 const char *name = NULL;
331 const char *value = NULL;
332 xmlNode *action_resource = NULL;
343 op->
rsc_id = strdup(
ID(action_resource));
349 op->
t_run = time(NULL);
355 g_hash_table_iter_init(&iter, action->
params);
356 while (g_hash_table_iter_next(&iter, (
void **)&name, (
void **)&value)) {
361 g_hash_table_insert(op->
params, strdup(name), strdup(value));
364 for (xop = __xml_first_child(resource); xop != NULL; xop = __xml_next(xop)) {
368 crm_debug(
"Got call_id=%d for %s", tmp,
ID(resource));
#define CRM_CHECK(expr, failure_action)
xmlNode * find_xml_node(xmlNode *cib, const char *node_path, gboolean must_find)
GHashTable * xml2list(xmlNode *parent)
enum transition_action completion_action
lrmd_rsc_info_t * rsc_info
long long crm_get_msec(const char *input)
#define XML_GRAPH_TAG_RSC_OP
int crm_parse_int(const char *text, const char *default_text)
char * crm_element_value_copy(xmlNode *data, const char *name)
#define XML_GRAPH_TAG_CRM_EVENT
crm_action_timer_t * timer
#define XML_GRAPH_TAG_PSEUDO_EVENT
#define XML_CIB_ATTR_PRIORITY
xmlNode * copy_xml(xmlNode *src_node)
#define XML_LRM_ATTR_TASK
#define crm_warn(fmt, args...)
#define crm_debug(fmt, args...)
#define XML_CIB_TAG_RESOURCE
#define crm_trace(fmt, args...)
#define XML_AGENT_ATTR_PROVIDER
Wrappers for and extensions to libxml2.
#define crm_log_xml_warn(xml, text)
int crm_element_value_int(xmlNode *data, const char *name, int *dest)
const char * crm_element_value(xmlNode *data, const char *name)
crm_graph_t * unpack_graph(xmlNode *xml_graph, const char *reference)
void free_xml(xmlNode *child)
gboolean crm_str_eq(const char *a, const char *b, gboolean use_case)
int crm_str_to_boolean(const char *s, int *ret)
#define crm_perror(level, fmt, args...)
Log a system error message.
#define crm_err(fmt, args...)
#define XML_LRM_ATTR_CALLID
xmlNode * first_named_child(xmlNode *parent, const char *name)
#define crm_log_xml_trace(xml, text)
void lrmd_free_rsc_info(lrmd_rsc_info_t *rsc_info)
CRM_TRACE_INIT_DATA(pe_status)
#define safe_str_eq(a, b)
void destroy_graph(crm_graph_t *graph)
void g_hash_destroy_str(gpointer data)
lrmd_event_data_t * convert_graph_action(xmlNode *resource, crm_action_t *action, int status, int rc)
#define XML_AGENT_ATTR_CLASS