Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactor: Stop using get_cib_copy() as it doesn't expose -EACCES errors

  • Loading branch information...
commit 68924ffa921f11154739e469ad723b7182011b8b 1 parent 345b400
@beekhof authored
View
6 cib/cibmon.c
@@ -242,7 +242,11 @@ cibmon_diff(const char *event, xmlNode * msg)
}
if (cib_copy == NULL) {
- cib_copy = get_cib_copy(cib);
+ rc = cib->cmds->query(cib, NULL, &cib_copy, cib_scope_local | cib_sync_call);
+ }
+
+ if(rc == -EACCES) {
+ crm_exit(rc);
}
free_xml(cib_last);
View
4 lib/cib/cib_utils.c
@@ -106,6 +106,7 @@ cib_compare_generation(xmlNode * left, xmlNode * right)
return 0;
}
+/* Deprecated - doesn't expose -EACCES */
xmlNode *
get_cib_copy(cib_t * cib)
{
@@ -137,9 +138,10 @@ get_cib_copy(cib_t * cib)
xmlNode *
cib_get_generation(cib_t * cib)
{
- xmlNode *the_cib = get_cib_copy(cib);
+ xmlNode *the_cib = NULL;
xmlNode *generation = create_xml_node(NULL, XML_CIB_TAG_GENERATION_TUPPLE);
+ cib->cmds->query(cib, NULL, &the_cib, cib_scope_local | cib_sync_call);
if (the_cib != NULL) {
copy_in_properties(generation, the_cib);
free_xml(the_cib);
View
11 lrmd/test.c
@@ -384,11 +384,14 @@ generate_params(void)
goto param_gen_bail;
}
- cib_xml_copy = get_cib_copy(cib_conn);
+ rc = cib_conn->cmds->query(cib_conn, NULL, &cib_xml_copy, cib_scope_local | cib_sync_call);
+ if (rc != pcmk_ok) {
+ crm_err("Error retrieving cib copy: %s (%d)", pcmk_strerror(rc), rc);
+ goto param_gen_bail;
- if (!cib_xml_copy) {
- crm_err("Error retrieving cib copy.");
- rc = -1;
+ } else if (cib_xml_copy == NULL) {
+ rc = -ENODATA;
+ crm_err("Error retrieving cib copy: %s (%d)", pcmk_strerror(rc), rc);
goto param_gen_bail;
}
View
10 tools/crm_mon.c
@@ -280,10 +280,12 @@ cib_connect(gboolean full)
return rc;
}
- current_cib = get_cib_copy(cib);
- mon_refresh_display(NULL);
+ rc = cib->cmds->query(cib, NULL, &current_cib, cib_scope_local | cib_sync_call);
+ if (rc == pcmk_ok) {
+ mon_refresh_display(NULL);
+ }
- if (full) {
+ if (rc == pcmk_ok && full) {
if (rc == pcmk_ok) {
rc = cib->cmds->set_connection_dnotify(cib, mon_cib_connection_destroy);
if (rc == -EPROTONOSUPPORT) {
@@ -2449,7 +2451,7 @@ crm_diff_update(const char *event, xmlNode * msg)
}
if (current_cib == NULL) {
- current_cib = get_cib_copy(cib);
+ cib->cmds->query(cib, NULL, &current_cib, cib_scope_local | cib_sync_call);
}
if (crm_mail_to || snmp_target || external_agent) {
View
8 tools/crm_simulate.c
@@ -1133,14 +1133,18 @@ setup_input(const char *input, const char *output)
rc = cib_conn->cmds->signon(cib_conn, crm_system_name, cib_command);
if (rc == pcmk_ok) {
- cib_object = get_cib_copy(cib_conn);
+ rc = cib_conn->cmds->query(cib_conn, NULL, &cib_object, cib_scope_local | cib_sync_call);
}
cib_conn->cmds->signoff(cib_conn);
cib_delete(cib_conn);
cib_conn = NULL;
- if (cib_object == NULL) {
+ if (rc != pcmk_ok) {
+ fprintf(stderr, "Live CIB query failed: %s (%d)\n", pcmk_strerror(rc), rc);
+ crm_exit(rc);
+
+ } else if (cib_object == NULL) {
fprintf(stderr, "Live CIB query failed: empty result\n");
crm_exit(ENOTCONN);
}
View
7 tools/crm_ticket.c
@@ -853,10 +853,13 @@ main(int argc, char **argv)
cib_xml_copy = filename2xml(xml_file);
} else {
- cib_xml_copy = get_cib_copy(cib_conn);
+ rc = cib_conn->cmds->query(cib_conn, NULL, &cib_xml_copy, cib_scope_local | cib_sync_call);
}
- if (cli_config_update(&cib_xml_copy, NULL, FALSE) == FALSE) {
+ if (rc != pcmk_ok) {
+ goto bail;
+
+ } else if (cli_config_update(&cib_xml_copy, NULL, FALSE) == FALSE) {
rc = -ENOKEY;
goto bail;
}
View
8 tools/crmadmin.c
@@ -309,10 +309,12 @@ do_work(void)
return -1;
}
- output = get_cib_copy(the_cib);
- do_find_node_list(output);
+ rc = the_cib->cmds->query(the_cib, NULL, &output, cib_scope_local | cib_sync_call);
+ if(rc == pcmk_ok) {
+ do_find_node_list(output);
- free_xml(output);
+ free_xml(output);
+ }
the_cib->cmds->signoff(the_cib);
crm_exit(rc);
Please sign in to comment.
Something went wrong with that request. Please try again.