| 164 | } |
| 165 | |
| 166 | gboolean |
| 167 | clone_unpack(resource_t * rsc, pe_working_set_t * data_set) |
| 168 | { |
| 169 | int lpc = 0; |
| 170 | const char *type = NULL; |
| 171 | resource_t *self = NULL; |
| 172 | int num_xml_children = 0; |
| 173 | xmlNode *a_child = NULL; |
| 174 | xmlNode *xml_tmp = NULL; |
| 175 | xmlNode *xml_self = NULL; |
| 176 | xmlNode *xml_obj = rsc->xml; |
| 177 | clone_variant_data_t *clone_data = NULL; |
| 178 | |
| 179 | const char *ordered = g_hash_table_lookup(rsc->meta, XML_RSC_ATTR_ORDERED); |
| 180 | const char *interleave = g_hash_table_lookup(rsc->meta, XML_RSC_ATTR_INTERLEAVE); |
| 181 | const char *max_clones = g_hash_table_lookup(rsc->meta, XML_RSC_ATTR_INCARNATION_MAX); |
| 182 | const char *max_clones_node = g_hash_table_lookup(rsc->meta, XML_RSC_ATTR_INCARNATION_NODEMAX); |
| 183 | |
| 184 | pe_rsc_trace(rsc, "Processing resource %s...", rsc->id); |
| 185 | |
| 186 | clone_data = calloc(1, sizeof(clone_variant_data_t)); |
| 187 | rsc->variant_opaque = clone_data; |
| 188 | clone_data->interleave = FALSE; |
| 189 | clone_data->ordered = FALSE; |
| 190 | |
| 191 | clone_data->active_clones = 0; |
| 192 | clone_data->xml_obj_child = NULL; |
| 193 | clone_data->clone_node_max = crm_parse_int(max_clones_node, "1"); |
| 194 | |
| 195 | if (max_clones) { |
| 196 | clone_data->clone_max = crm_parse_int(max_clones, "1"); |
| 197 | |
| 198 | } else if (g_list_length(data_set->nodes) > 0) { |
| 199 | clone_data->clone_max = g_list_length(data_set->nodes); |
| 200 | |
| 201 | } else { |
| 202 | clone_data->clone_max = 1; /* Handy during crm_verify */ |
| 203 | } |
| 204 | |
| 205 | if (crm_is_true(interleave)) { |
| 206 | clone_data->interleave = TRUE; |
| 207 | } |
| 208 | if (crm_is_true(ordered)) { |
| 209 | clone_data->ordered = TRUE; |
| 210 | } |
| 211 | if ((rsc->flags & pe_rsc_unique) == 0 && clone_data->clone_node_max > 1) { |
| 212 | crm_config_err("Anonymous clones (%s) may only support one copy" " per node", rsc->id); |
| 213 | clone_data->clone_node_max = 1; |
| 214 | } |
| 215 | |
| 216 | pe_rsc_trace(rsc, "Options for %s", rsc->id); |
| 217 | pe_rsc_trace(rsc, "\tClone max: %d", clone_data->clone_max); |
| 218 | pe_rsc_trace(rsc, "\tClone node max: %d", clone_data->clone_node_max); |
| 219 | pe_rsc_trace(rsc, "\tClone is unique: %s", is_set(rsc->flags, pe_rsc_unique) ? "true" : "false"); |
| 220 | |
| 221 | clone_data->xml_obj_child = find_xml_node(xml_obj, XML_CIB_TAG_GROUP, FALSE); |
| 222 | |
| 223 | if (clone_data->xml_obj_child == NULL) { |
no test coverage detected