<html><body>
<p><tt>andrew@beekhof.net wrote on 05/13/2009 21:08:36 PM:<br>
<br>
> This is missing the modification to char2score that i mentioned (which<br>
> would also simplify calculate_system_health()).</tt><br>
<tt>> ...</tt><br>
<tt>> Oh, and initialize_health_value() should probably just set a something<br>
> in data_set (which would be passed to char2score) and should obtain a<br>
> value from data_set->config_hash instead of using an xpath query.</tt><br>
<br>
<tt>Just to be clear,</tt><br>
<br>
<tt>hs21c:/usr/src/packages/BUILD # grep -r char2score pacemaker/</tt><br>
<tt>pacemaker/include/crm/common/util.h:extern int char2score(const char *score);</tt><br>
<tt>pacemaker/lib/common/utils.c:char2score(const char *score)</tt><br>
<tt>pacemaker/lib/common/xml.c:        int_value = char2score(old_value);</tt><br>
<tt>pacemaker/lib/common/xml.c:        offset = char2score(offset_s);</tt><br>
<tt>pacemaker/lib/pengine/complex.c:           (*rsc)->stickiness = char2score(value);</tt><br>
<tt>pacemaker/lib/pengine/complex.c:           (*rsc)->migration_threshold = char2score(value);</tt><br>
<tt>pacemaker/lib/pengine/complex.c:           int fail_sticky = char2score(value);</tt><br>
<tt>pacemaker/lib/pengine/rules.c:             pair->score = char2score(score);</tt><br>
<tt>pacemaker/lib/pengine/unpack.c:    data_set->default_resource_stickiness = char2score(value);</tt><br>
<tt>pacemaker/lib/pengine/utils.c:     fail_count = char2score(value);</tt><br>
<tt>pacemaker/pengine/allocate.c:              *value = char2score (attr_value);</tt><br>
<tt>pacemaker/pengine/constraints.c:   score_i = char2score(score);</tt><br>
<tt>pacemaker/pengine/constraints.c:       int score_i = char2score(score);</tt><br>
<tt>pacemaker/pengine/constraints.c:           score_f = char2score(score);</tt><br>
<tt>pacemaker/pengine/constraints.c:                   score_f = char2score(attr_score);</tt><br>
<tt>pacemaker/pengine/constraints.c:           score_f = char2score(score);</tt><br>
<tt>pacemaker/pengine/constraints.c:   local_score = char2score(score_s);</tt><br>
<tt>pacemaker/pengine/constraints.c:   score_i = char2score(score);</tt><br>
<tt>pacemaker/pengine/constraints.c:   local_score = char2score(score_s);</tt><br>
<tt>pacemaker/pengine/constraints.c:   score_i = char2score(score);</tt><br>
<tt>pacemaker/pengine/constraints.c:       score_i = char2score(score);</tt><br>
<tt>pacemaker/pengine/master.c:                score = char2score(attr_value);</tt><br>
<br>
<tt>char2score appears in many places in the code.  All char2score instances should be</tt><br>
<tt>changed to now look like:</tt><br>
<br>
<tt>char2score(const char *score, pe_working_set_t *data_set)</tt><br>
<br>
<tt>All of the above instances will just pass in NULL so that the behavior does not change.</tt><br>
<tt>If data_set is non-null, then green/yellow/red will convert into numbers using three new</tt><br>
<tt>members added to the structure.</tt><br>
<tt><br>
> For extra credit, you could also fake the configuration element and<br>
> pass it to generate_location_rule() instead of using rsc2node_new().<br>
> This is what I orginally had in mind, but may not be worth the effort.</tt><br>
<br>
<tt>One of my first attempts had something like:</tt><br>
<br>
<tt>...</tt><br>
<tt>+                       sprintf (achXML,</tt><br>
<tt>+                               "<rsc_location id=\"%s_health_location\" rsc=\"%s\">\n  <rule id=\"%s_health_rule\" score-attribute=\"#health\">\n    <expression attribute=\"#health\" id=\"%s_health_expr\" operation=\"defined\"/>\n  </rule>\n</rsc_location>",</tt><br>
<tt>+                               rsc,</tt><br>
<tt>+                               rsc,</tt><br>
<tt>+                               rsc,</tt><br>
<tt>+                               rsc);</tt><br>
<tt>+</tt><br>
<tt>+                       newXML = string2xml(achXML);</tt><br>
<tt>+</tt><br>
<tt>+                       newResources = g_list_append(newResources, newXML);</tt><br>
<tt>...</tt><br>
<tt>+       g_list_foreach(newResources, add_resource, cib_constraints);</tt><tt><br>
</tt><br>
<tt>However,</tt><br>
<br>
<tt>rsc2node_new (id, rsc, health_info->system_health, node, data_set);</tt><br>
<br>
<tt>seems cleaner.</tt><br>
<br>
--<br>
<br>
Mark</body></html>