From 1a3feba13547184260c4256389a2755448d87504 Mon Sep 17 00:00:00 2001 From: Chris Lumens Date: Feb 05 2021 06:22:50 +0000 Subject: Feature: tools: Use formatted output for resource output in crm_resource. This switches crm_resource away from using the old style resource printing functions and onto using formatted output. --- diff --git a/cts/cli/regression.tools.exp b/cts/cli/regression.tools.exp index 738e800..4abbb75 100644 --- a/cts/cli/regression.tools.exp +++ b/cts/cli/regression.tools.exp @@ -971,7 +971,7 @@ dummy =#=#=#= End test: List IDs of instantiated resources - OK (0) =#=#=#= * Passed: crm_resource - List IDs of instantiated resources =#=#=#= Begin test: Show XML configuration of resource =#=#=#= - dummy (ocf::pacemaker:Dummy): Stopped +dummy (ocf::pacemaker:Dummy): Stopped Resource XML: @@ -979,7 +979,6 @@ Resource XML: - =#=#=#= End test: Show XML configuration of resource - OK (0) =#=#=#= * Passed: crm_resource - Show XML configuration of resource =#=#=#= Begin test: Require a destination when migrating a resource that is stopped =#=#=#= diff --git a/lib/common/output_xml.c b/lib/common/output_xml.c index 6a6ed6e..bba21e7 100644 --- a/lib/common/output_xml.c +++ b/lib/common/output_xml.c @@ -60,6 +60,7 @@ static subst_t substitutions[] = { { "Operations", "node_history" }, { "Negative Location Constraints", "bans" }, { "Node Attributes", "node_attributes" }, + { "Resource Config", "resource_config" }, { NULL, NULL } }; diff --git a/tools/crm_resource_print.c b/tools/crm_resource_print.c index 99217aa..447c57d 100644 --- a/tools/crm_resource_print.c +++ b/tools/crm_resource_print.c @@ -223,12 +223,17 @@ int cli_resource_print(pcmk__output_t *out, pe_resource_t *rsc, pe_working_set_t *data_set, bool expanded) { - int opts = pe_print_printf | pe_print_pending; + unsigned int opts = pe_print_pending; + GListPtr all = NULL; - rsc->fns->print(rsc, NULL, opts, stdout); + all = g_list_prepend(all, strdup("*")); + out->begin_list(out, NULL, NULL, "Resource Config"); + out->message(out, crm_map_element_name(rsc->xml), opts, rsc, all, all); out->message(out, "resource-config", rsc, !expanded); + out->end_list(out); + g_list_free_full(all, free); return pcmk_rc_ok; } diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c index 3e1f985..7aae8cc 100644 --- a/tools/crm_resource_runtime.c +++ b/tools/crm_resource_runtime.c @@ -142,6 +142,8 @@ find_resource_attr(pcmk__output_t *out, cib_t * the_cib, const char *attr, crm_element_value(child, XML_NVPAIR_ATTR_VALUE), ID(child)); } + out->spacer(out); + } else if(value) { const char *tmp = crm_element_value(xml_search, attr);