MCPcopy Create free account
hub / github.com/ClusterLabs/pacemaker / group_unpack

Function group_unpack

lib/pengine/group.c:30–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28#include "./variant.h"
29
30gboolean
31group_unpack(resource_t * rsc, pe_working_set_t * data_set)
32{
33 resource_t *self = NULL;
34 xmlNode *xml_obj = rsc->xml;
35 xmlNode *xml_self = copy_xml(rsc->xml);
36 xmlNode *xml_native_rsc = NULL;
37 group_variant_data_t *group_data = NULL;
38 const char *group_ordered = g_hash_table_lookup(rsc->meta, XML_RSC_ATTR_ORDERED);
39 const char *group_colocated = g_hash_table_lookup(rsc->meta, "collocated");
40 const char *clone_id = NULL;
41
42 pe_rsc_trace(rsc, "Processing resource %s...", rsc->id);
43
44 group_data = calloc(1, sizeof(group_variant_data_t));
45 group_data->num_children = 0;
46 group_data->self = NULL;
47 group_data->first_child = NULL;
48 group_data->last_child = NULL;
49 rsc->variant_opaque = group_data;
50
51 group_data->ordered = TRUE;
52 group_data->colocated = TRUE;
53
54 if (group_ordered != NULL) {
55 crm_str_to_boolean(group_ordered, &(group_data->ordered));
56 }
57 if (group_colocated != NULL) {
58 crm_str_to_boolean(group_colocated, &(group_data->colocated));
59 }
60
61 /* this is a bit of a hack - but simplifies everything else */
62 xmlNodeSetName(xml_self, ((const xmlChar *)XML_CIB_TAG_RESOURCE));
63 if (common_unpack(xml_self, &self, NULL, data_set)) {
64 group_data->self = self;
65 self->restart_type = pe_restart_restart;
66
67 } else {
68 crm_log_xml_err(xml_self, "Couldnt unpack dummy child");
69 return FALSE;
70 }
71
72 clone_id = crm_element_value(rsc->xml, XML_RSC_ATTR_INCARNATION);
73
74 for (xml_native_rsc = __xml_first_child(xml_obj); xml_native_rsc != NULL;
75 xml_native_rsc = __xml_next(xml_native_rsc)) {
76 if (crm_str_eq((const char *)xml_native_rsc->name, XML_CIB_TAG_RESOURCE, TRUE)) {
77 resource_t *new_rsc = NULL;
78
79 crm_xml_add(xml_native_rsc, XML_RSC_ATTR_INCARNATION, clone_id);
80 if (common_unpack(xml_native_rsc, &new_rsc, rsc, data_set) == FALSE) {
81 pe_err("Failed unpacking resource %s", crm_element_value(xml_obj, XML_ATTR_ID));
82 if (new_rsc != NULL && new_rsc->fns != NULL) {
83 new_rsc->fns->free(new_rsc);
84 }
85 }
86
87 group_data->num_children++;

Callers

nothing calls this directly

Calls 9

copy_xmlFunction · 0.85
crm_str_to_booleanFunction · 0.85
common_unpackFunction · 0.85
crm_element_valueFunction · 0.85
__xml_first_childFunction · 0.85
__xml_nextFunction · 0.85
crm_str_eqFunction · 0.85
crm_xml_addFunction · 0.85
print_resourceFunction · 0.85

Tested by

no test coverage detected