diff --git a/tools/crm_resource.c b/tools/crm_resource.c index 3bc8939..e30b9a7 100644 --- a/tools/crm_resource.c +++ b/tools/crm_resource.c @@ -152,7 +152,6 @@ gboolean restart_cb(const gchar *option_name, const gchar *optarg, gboolean wait_cb(const gchar *option_name, const gchar *optarg, gpointer data, GError **error); gboolean why_cb(const gchar *option_name, const gchar *optarg, gpointer data, GError **error); -bool BE_QUIET = FALSE; static crm_exit_t exit_code = CRM_EX_OK; static pcmk__output_t *out = NULL; @@ -639,7 +638,7 @@ attr_set_type_cb(const gchar *option_name, const gchar *optarg, gpointer data, G gboolean class_cb(const gchar *option_name, const gchar *optarg, gpointer data, GError **error) { if (!(pcmk_get_ra_caps(optarg) & pcmk_ra_cap_params)) { - if (BE_QUIET == FALSE) { + if (!out->is_quiet(out)) { g_set_error(error, G_OPTION_ERROR, CRM_EX_INVALID_PARAM, "Standard %s does not support parameters\n", optarg); } @@ -991,7 +990,7 @@ cleanup(pcmk__output_t *out, pe_resource_t *rsc) rc = cli_resource_delete(out, controld_api, options.host_uname, rsc, options.operation, options.interval_spec, TRUE, data_set, options.force); - if ((rc == pcmk_rc_ok) && !BE_QUIET) { + if ((rc == pcmk_rc_ok) && !out->is_quiet(out)) { // Show any reasons why resource might stay stopped cli_resource_check(out, cib_conn, rsc); } @@ -1011,7 +1010,7 @@ clear_constraints(pcmk__output_t *out, xmlNodePtr *cib_xml_copy) pe_node_t *dest = NULL; int rc = pcmk_rc_ok; - if (BE_QUIET == FALSE) { + if (!out->is_quiet(out)) { before = build_constraint_list(data_set->input); } @@ -1024,7 +1023,7 @@ clear_constraints(pcmk__output_t *out, xmlNodePtr *cib_xml_copy) dest = pe_find_node(data_set->nodes, options.host_uname); if (dest == NULL) { rc = pcmk_rc_node_unknown; - if (BE_QUIET == FALSE) { + if (!out->is_quiet(out)) { g_list_free(before); } return rc; @@ -1037,7 +1036,7 @@ clear_constraints(pcmk__output_t *out, xmlNodePtr *cib_xml_copy) cib_conn, options.cib_options, TRUE, options.force); } - if (BE_QUIET == FALSE) { + if (!out->is_quiet(out)) { rc = cib_conn->cmds->query(cib_conn, NULL, cib_xml_copy, cib_scope_local | cib_sync_call); rc = pcmk_legacy2rc(rc); @@ -1321,7 +1320,7 @@ refresh_resource(pcmk__output_t *out, pe_resource_t *rsc) rc = cli_resource_delete(out, controld_api, options.host_uname, rsc, NULL, 0, FALSE, data_set, options.force); - if ((rc == pcmk_rc_ok) && !BE_QUIET) { + if ((rc == pcmk_rc_ok) && !out->is_quiet(out)) { // Show any reasons why resource might stay stopped cli_resource_check(out, cib_conn, rsc); } @@ -1550,7 +1549,7 @@ main(int argc, char **argv) } options.resource_verbose = args->verbosity; - BE_QUIET = args->quiet; + out->quiet = args->quiet; crm_log_args(argc, argv); diff --git a/tools/crm_resource.h b/tools/crm_resource.h index bf99f24..0100488 100644 --- a/tools/crm_resource.h +++ b/tools/crm_resource.h @@ -22,8 +22,6 @@ #include #include -extern bool BE_QUIET; - /* ban */ int cli_resource_prefer(pcmk__output_t *out, const char *rsc_id, const char *host, const char *move_lifetime, cib_t * cib_conn, int cib_options, diff --git a/tools/crm_resource_ban.c b/tools/crm_resource_ban.c index 95e5a17..abed209 100644 --- a/tools/crm_resource_ban.c +++ b/tools/crm_resource_ban.c @@ -88,7 +88,7 @@ cli_resource_ban(pcmk__output_t *out, const char *rsc_id, const char *host, location = create_xml_node(fragment, XML_CONS_TAG_RSC_LOCATION); crm_xml_set_id(location, "cli-ban-%s-on-%s", rsc_id, host); - if (BE_QUIET == FALSE) { + if (!out->is_quiet(out)) { CMD_ERR("WARNING: Creating rsc_location constraint '%s'" " with a score of -INFINITY for resource %s" " on %s.", ID(location), rsc_id, host); diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c index 42d33bd..3e1f985 100644 --- a/tools/crm_resource_runtime.c +++ b/tools/crm_resource_runtime.c @@ -22,7 +22,7 @@ do_find_resource(pcmk__output_t *out, const char *rsc, pe_resource_t * the_rsc, for (lpc = the_rsc->running_on; lpc != NULL; lpc = lpc->next) { pe_node_t *node = (pe_node_t *) lpc->data; - if (BE_QUIET) { + if (out->is_quiet(out)) { fprintf(stdout, "%s\n", node->details->uname); } else { const char *state = ""; @@ -36,7 +36,7 @@ do_find_resource(pcmk__output_t *out, const char *rsc, pe_resource_t * the_rsc, found++; } - if (BE_QUIET == FALSE && found == 0) { + if (!out->is_quiet(out) && found == 0) { fprintf(stderr, "resource %s is NOT running\n", rsc); } @@ -220,7 +220,7 @@ find_matching_attr_resources(pcmk__output_t *out, pe_resource_t * rsc, if(rc != pcmk_rc_ok) { rsc = rsc->parent; - if (BE_QUIET == FALSE) { + if (!out->is_quiet(out)) { printf("Performing %s of '%s' on '%s', the parent of '%s'\n", cmd, attr_name, rsc->id, rsc_id); } } @@ -235,7 +235,7 @@ find_matching_attr_resources(pcmk__output_t *out, pe_resource_t * rsc, if(rc == pcmk_rc_ok) { rsc = child; - if (BE_QUIET == FALSE) { + if (!out->is_quiet(out)) { printf("A value for '%s' already exists in child '%s', performing %s on that instead of '%s'\n", attr_name, lookup_id, cmd, rsc_id); } } @@ -282,7 +282,7 @@ cli_resource_update_attribute(pcmk__output_t *out, pe_resource_t *rsc, rc = find_resource_attr(out, cib, XML_ATTR_ID, uber_parent(rsc)->id, XML_TAG_META_SETS, attr_set, attr_id, attr_name, &local_attr_id); - if (rc == pcmk_rc_ok && BE_QUIET == FALSE) { + if (rc == pcmk_rc_ok && !out->is_quiet(out)) { printf("WARNING: There is already a meta attribute for '%s' called '%s' (id=%s)\n", uber_parent(rsc)->id, attr_name, local_attr_id); printf(" Delete '%s' first or use the force option to override\n", @@ -359,7 +359,7 @@ cli_resource_update_attribute(pcmk__output_t *out, pe_resource_t *rsc, rc = cib->cmds->modify(cib, XML_CIB_TAG_RESOURCES, xml_top, cib_options); rc = pcmk_legacy2rc(rc); - if (rc == pcmk_rc_ok && BE_QUIET == FALSE) { + if (rc == pcmk_rc_ok && !out->is_quiet(out)) { printf("Set '%s' option: id=%s%s%s%s%s value=%s\n", lookup_id, local_attr_id, attr_set ? " set=" : "", attr_set ? attr_set : "", attr_name ? " name=" : "", attr_name ? attr_name : "", attr_value); @@ -466,7 +466,7 @@ cli_resource_delete_attribute(pcmk__output_t *out, pe_resource_t *rsc, rc = cib->cmds->remove(cib, XML_CIB_TAG_RESOURCES, xml_obj, cib_options); rc = pcmk_legacy2rc(rc); - if (rc == pcmk_rc_ok && BE_QUIET == FALSE) { + if (rc == pcmk_rc_ok && !out->is_quiet(out)) { printf("Deleted '%s' option: id=%s%s%s%s%s\n", lookup_id, local_attr_id, attr_set ? " set=" : "", attr_set ? attr_set : "", attr_name ? " name=" : "", attr_name ? attr_name : ""); @@ -1349,7 +1349,7 @@ cli_resource_restart(pcmk__output_t *out, pe_resource_t *rsc, const char *host, if (stop_via_ban) { /* Stop the clone or bundle instance by banning it from the host */ - BE_QUIET = TRUE; + out->quiet = true; rc = cli_resource_ban(out, rsc_id, host, move_lifetime, NULL, cib, cib_options, promoted_role_only); @@ -1631,7 +1631,7 @@ wait_till_stable(pcmk__output_t *out, int timeout_ms, cib_t * cib) int timeout_s = timeout_ms? ((timeout_ms + 999) / 1000) : WAIT_DEFAULT_TIMEOUT_S; time_t expire_time = time(NULL) + timeout_s; time_t time_diff; - bool printed_version_warning = BE_QUIET; // i.e. don't print if quiet + bool printed_version_warning = out->is_quiet(out); // i.e. don't print if quiet data_set = pe_new_working_set(); if (data_set == NULL) {