<html><body>
<p><tt>andrew@beekhof.net wrote on 05/13/2009 21:08:36 PM:<br>
<br>
&gt; This is missing the modification to char2score that i mentioned (which<br>
&gt; would also simplify calculate_system_health()).</tt><br>
<tt>&gt; ...</tt><br>
<tt>&gt; Oh, and initialize_health_value() should probably just set a something<br>
&gt; in data_set (which would be passed to char2score) and should obtain a<br>
&gt; value from data_set-&gt;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: &nbsp; &nbsp; &nbsp; &nbsp;int_value = char2score(old_value);</tt><br>
<tt>pacemaker/lib/common/xml.c: &nbsp; &nbsp; &nbsp; &nbsp;offset = char2score(offset_s);</tt><br>
<tt>pacemaker/lib/pengine/complex.c: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (*rsc)-&gt;stickiness = char2score(value);</tt><br>
<tt>pacemaker/lib/pengine/complex.c: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (*rsc)-&gt;migration_threshold = char2score(value);</tt><br>
<tt>pacemaker/lib/pengine/complex.c: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int fail_sticky = char2score(value);</tt><br>
<tt>pacemaker/lib/pengine/rules.c: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pair-&gt;score = char2score(score);</tt><br>
<tt>pacemaker/lib/pengine/unpack.c: &nbsp; &nbsp;data_set-&gt;default_resource_stickiness = char2score(value);</tt><br>
<tt>pacemaker/lib/pengine/utils.c: &nbsp; &nbsp; fail_count = char2score(value);</tt><br>
<tt>pacemaker/pengine/allocate.c: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*value = char2score (attr_value);</tt><br>
<tt>pacemaker/pengine/constraints.c: &nbsp; score_i = char2score(score);</tt><br>
<tt>pacemaker/pengine/constraints.c: &nbsp; &nbsp; &nbsp; int score_i = char2score(score);</tt><br>
<tt>pacemaker/pengine/constraints.c: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; score_f = char2score(score);</tt><br>
<tt>pacemaker/pengine/constraints.c: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; score_f = char2score(attr_score);</tt><br>
<tt>pacemaker/pengine/constraints.c: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; score_f = char2score(score);</tt><br>
<tt>pacemaker/pengine/constraints.c: &nbsp; local_score = char2score(score_s);</tt><br>
<tt>pacemaker/pengine/constraints.c: &nbsp; score_i = char2score(score);</tt><br>
<tt>pacemaker/pengine/constraints.c: &nbsp; local_score = char2score(score_s);</tt><br>
<tt>pacemaker/pengine/constraints.c: &nbsp; score_i = char2score(score);</tt><br>
<tt>pacemaker/pengine/constraints.c: &nbsp; &nbsp; &nbsp; score_i = char2score(score);</tt><br>
<tt>pacemaker/pengine/master.c: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;score = char2score(attr_value);</tt><br>
<br>
<tt>char2score appears in many places in the code. &nbsp;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>
&gt; For extra credit, you could also fake the configuration element and<br>
&gt; pass it to generate_location_rule() instead of using rsc2node_new().<br>
&gt; 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>+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sprintf (achXML,</tt><br>
<tt>+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;rsc_location id=\&quot;%s_health_location\&quot; rsc=\&quot;%s\&quot;&gt;\n &nbsp;&lt;rule id=\&quot;%s_health_rule\&quot; score-attribute=\&quot;#health\&quot;&gt;\n &nbsp; &nbsp;&lt;expression attribute=\&quot;#health\&quot; id=\&quot;%s_health_expr\&quot; operation=\&quot;defined\&quot;/&gt;\n &nbsp;&lt;/rule&gt;\n&lt;/rsc_location&gt;&quot;,</tt><br>
<tt>+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rsc,</tt><br>
<tt>+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rsc,</tt><br>
<tt>+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rsc,</tt><br>
<tt>+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rsc);</tt><br>
<tt>+</tt><br>
<tt>+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newXML = string2xml(achXML);</tt><br>
<tt>+</tt><br>
<tt>+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newResources = g_list_append(newResources, newXML);</tt><br>
<tt>...</tt><br>
<tt>+ &nbsp; &nbsp; &nbsp; 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-&gt;system_health, node, data_set);</tt><br>
<br>
<tt>seems cleaner.</tt><br>
<br>
--<br>
<br>
Mark</body></html>