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

Function readCibXmlFile

cib/io.c:285–420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

283}
284
285xmlNode *
286readCibXmlFile(const char *dir, const char *file, gboolean discard_status)
287{
288 int seq = 0;
289 char *backup_file = NULL;
290 char *filename = NULL, *sigfile = NULL;
291 const char *name = NULL;
292 const char *value = NULL;
293 const char *validation = NULL;
294 const char *use_valgrind = getenv("HA_VALGRIND_ENABLED");
295
296 xmlNode *root = NULL;
297 xmlNode *status = NULL;
298
299 if (!crm_is_writable(dir, file, CRM_DAEMON_USER, NULL, FALSE)) {
300 cib_status = -EACCES;
301 return NULL;
302 }
303
304 filename = crm_concat(dir, file, '/');
305 sigfile = crm_concat(filename, "sig", '.');
306
307 cib_status = pcmk_ok;
308 root = retrieveCib(filename, sigfile, TRUE);
309
310 if (root == NULL) {
311 crm_warn("Primary configuration corrupt or unusable, trying backup...");
312 seq = get_last_sequence(cib_root, CIB_SERIES);
313 }
314
315 while (root == NULL) {
316 struct stat buf;
317
318 free(sigfile);
319
320 if (seq == 0) {
321 seq += cib_wrap; /* unwrap */
322 }
323
324 backup_file = generate_series_filename(cib_root, CIB_SERIES, seq - 1, FALSE);
325 sigfile = crm_concat(filename, "sig", '.');
326
327 if (stat(backup_file, &buf) != 0) {
328 crm_debug("Backup file %s not found", backup_file);
329 break;
330 }
331 crm_warn("Attempting to load: %s", backup_file);
332 root = retrieveCib(backup_file, sigfile, FALSE);
333 seq--;
334 }
335 free(backup_file);
336
337 if (root == NULL) {
338 root = createEmptyCib();
339 crm_xml_add(root, XML_ATTR_GENERATION, "0");
340 crm_xml_add(root, XML_ATTR_NUMUPDATES, "0");
341 crm_xml_add(root, XML_ATTR_GENERATION_ADMIN, "0");
342 crm_xml_add(root, XML_ATTR_VALIDATION, LATEST_SCHEMA_VERSION);

Callers 1

startCibFunction · 0.85

Calls 15

crm_is_writableFunction · 0.85
crm_concatFunction · 0.85
retrieveCibFunction · 0.85
get_last_sequenceFunction · 0.85
generate_series_filenameFunction · 0.85
createEmptyCibFunction · 0.85
crm_xml_addFunction · 0.85
crm_is_trueFunction · 0.85
find_xml_nodeFunction · 0.85
free_xmlFunction · 0.85
create_xml_nodeFunction · 0.85
crm_element_valueFunction · 0.85

Tested by

no test coverage detected