commit 3912538a8954158d44a57f23aa219c5529a170ab Author: Gao,Yan Date: Wed Jan 29 14:07:44 2014 +0800 Feature: pengine: Support id-ref in nvpair with optional "name" If "name" isn't specified, it inherits the name from the referenced nvpair. diff --git a/lib/pengine/rules.c b/lib/pengine/rules.c index f80aa47..626d7b2 100644 --- a/lib/pengine/rules.c +++ b/lib/pengine/rules.c @@ -607,7 +607,7 @@ sort_pairs(gconstpointer a, gconstpointer b) } static void -populate_hash(xmlNode * nvpair_list, GHashTable * hash, gboolean overwrite) +populate_hash(xmlNode * nvpair_list, GHashTable * hash, gboolean overwrite, xmlNode * top) { const char *name = NULL; const char *value = NULL; @@ -622,10 +622,18 @@ populate_hash(xmlNode * nvpair_list, GHashTable * hash, gboolean overwrite) for (an_attr = __xml_first_child(list); an_attr != NULL; an_attr = __xml_next(an_attr)) { if (crm_str_eq((const char *)an_attr->name, XML_CIB_TAG_NVPAIR, TRUE)) { + xmlNode *ref_nvpair = expand_idref(an_attr, top); + name = crm_element_value(an_attr, XML_NVPAIR_ATTR_NAME); + if (name == NULL) { + name = crm_element_value(ref_nvpair, XML_NVPAIR_ATTR_NAME); + } crm_trace("Setting attribute: %s", name); value = crm_element_value(an_attr, XML_NVPAIR_ATTR_VALUE); + if (value == NULL) { + value = crm_element_value(ref_nvpair, XML_NVPAIR_ATTR_VALUE); + } if (name == NULL || value == NULL) { continue; @@ -657,6 +665,7 @@ struct unpack_data_s { GHashTable *node_hash; GHashTable *hash; crm_time_t *now; + xmlNode *top; }; static void @@ -670,7 +679,7 @@ unpack_attr_set(gpointer data, gpointer user_data) } crm_trace("Adding attributes from %s", pair->name); - populate_hash(pair->attr_set, unpack_data->hash, unpack_data->overwrite); + populate_hash(pair->attr_set, unpack_data->hash, unpack_data->overwrite, unpack_data->top); } void @@ -717,6 +726,7 @@ unpack_instance_attributes(xmlNode * top, xmlNode * xml_obj, const char *set_nam data.node_hash = node_hash; data.now = now; data.overwrite = overwrite; + data.top = top; } sorted = g_list_sort(unsorted, sort_pairs); diff --git a/xml/nodes-1.3.rng b/xml/nodes-1.3.rng index c28b5df..1ded570 100644 --- a/xml/nodes-1.3.rng +++ b/xml/nodes-1.3.rng @@ -30,10 +30,10 @@ - + - + diff --git a/xml/nvset-1.3.rng b/xml/nvset-1.3.rng new file mode 100644 index 0000000..8f1696c --- /dev/null +++ b/xml/nvset-1.3.rng @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xml/resources-1.3.rng b/xml/resources-1.3.rng index a3640d1..9faf9fc 100644 --- a/xml/resources-1.3.rng +++ b/xml/resources-1.3.rng @@ -53,7 +53,7 @@ - + @@ -86,7 +86,7 @@ - + @@ -144,10 +144,10 @@ - + - +