[Linux-HA] How to control a resource with an environment variable?
max.hofer at apus.co.at
Mon Nov 26 07:03:40 MST 2007
I have'nt checked your location constraint but what you want to achieve you
can't do with environment variables. You have to use CIB attributes.
So instead of changing the environment variable you change the CIB attribute.
Using attributes instead environment variables seems more logical if you think
about the fact that attributes are propagated to all cluster nodes. Whereas
environment variables are not.
What you have to decide is if you are using "global (or rather static)
attribute" (i.e. it shows up in the <nodes> section) or if you use an
attribute of temporary nature (i.e. in the <status> section).
What kind of attribite you use, depends what you want to achieve.
Somthing like: run a resource on the node with more RAM are definietyl of
static nature (add a "RAM" attribute to each node and write a rule which
creates a score based on this value).
If you have something like: run the resource on the node where a shell
script "X_Y_Z" returns the highest value, you need a resource agent which
calls X_Y_Z periodically (if it changes over time) and maps its return value
into the CIB in the <status> section.
Naturally you have to write a rule which adpats the score based on the
Mapping the attribute can be achieved with two tools: attrd_updater or
The first tool provides a hysteresis functionality. You can dampen the value
for a certain time period (i.e. the value is propagated to the other nodes
after the dampen time - this may be handy if your value may change with a
high frequency and you want avoid a resource failover when the system has a
On Sunday 25 November 2007, Atanas Dyulgerov wrote:
> Hi all,
> I need to control a resource with an environment variable. When I set the
> variable with value "true" to increase the score for a resource.
> I did the following constraint:
> <rsc_location id="rloc_unique_id" rsc="service_ip">
> <rule score="INFINITY" boolean_op="or" id="rcloc_rule_unique_id">
> <expression id="expr:hfc:defined" attribute="my_variable"
> operation="defined"/> <expression id="expr:hfc:true"
> attribute="my_variable" operation="eq" value="true"/> </rule>
> Then I export the variable my_variable on the node where I want to move the
> resource service_ip. # export my_variable=true
> Nothing happens.
> # export OCF_RESKEY_my_variable=true
> Again nothing happens.
> So, how can I control the resource from an env variable? How to export the
> One more question. How to display all the OCF_RESKEY variable set by the
> instant resource attributes? # export -p
> # set
> do not display any OCF_RESKEY_* variables.
> Thank you in advance.
> Atanas Dyulgerov
> Оцеляваш ли? Сподели свое видео или снимки! http://robinson.btv.bg/isurvive
> Linux-HA mailing list
> Linux-HA at lists.linux-ha.org
> See also: http://linux-ha.org/ReportingProblems
APUS Software G.m.b.H.
A-8074 Raaba, Bahnhofstraße 1/1
T| +43 316 401629 11
F| +43 316 401629 9
E| max.hofer at apus.co.at
More information about the Linux-HA