Hi, I have been using heartbeat 2 for a while and tend to prefer scripts over GUIs or XML so I have created some helper scripts (that I call Resource Scripts) to configure/modify resources and their constraints from the command line that I would like to share with others.
I only have a few of these scripts developed and they might not in themselves be particularly useful to others, but the main shell library and the idea probably would be. With the library as a start, you can easily create resource scripts for the types of resource that you use. A Resource Script is named after the type of resource or resource group that it will create and can be invoked with very simple options causing resources to be defined in the heartbeat CIB. Example: Add two new resources, example_A & example_B, which must be colocated, and example_B must start after example_A, and example_A should have a preference for machine foo: example + A +c example_B +l foo example + B +a example_A This will generate the XML required to create both example_A and example_B along with the constraints specified and invoke cibadmin with the appropriate switches to process this XML, while first clearing any matching entries from the CIB. Just to get a glimpse of how much easier this method is for simple stuff, here is the equivalent of the first command above (example + A +c example_B +l foo): echo '<rsc_colocation id="example_A_colocation_example_B" from="example_A" to="example_B" score="INFINITY"/>' |\ cibadmin -V -D -o constraints -p echo '<rsc_colocation id="example_A_colocation_example_B" from="example_A" to="example_B" score="INFINITY"/>' |\ cibadmin -V -C -o constraints -p echo '<rsc_location id="example_A_location" rsc="example_A"> <rule id="example_A_location_machine" score="100"> <expression id="example_A_location_machine_exp" attribute="#uname" operation="eq" value="foo"/> </rule> </rsc_location>' |\ cibadmin -V -D -o constraints -p echo '<rsc_location id="example_A_location" rsc="example_A"> <rule id="example_A_location_machine" score="100"> <expression id="example_A_location_machine_exp" attribute="#uname" operation="eq" value="foo"/> </rule> </rsc_location>' |\ cibadmin -V -C -o constraints -p echo '<primitive id="example_A" class="ocf" provider="heartbeat" type="Stateful"> <instance_attributes id="example_A_ia"> <attributes> <nvpair id="example_A_state" name="state" value="A"/> </attributes> </instance_attributes> </primitive>' |\ cibadmin -V -D -o resources -p echo '<primitive id="example_A" class="ocf" provider="heartbeat" type="Stateful"> <instance_attributes id="example_A_ia"> <attributes> <nvpair id="example_A_state" name="state" value="A"/> </attributes> </instance_attributes> </primitive>' |\ cibadmin -V -C -o resources -p If you later decide that you would be prefer example_A to start after example_B and you want the preferred machine to instead be bar, you can easily change this by issuing the following commands: example = B -a example_A example = A +a example_A -l foo +l bar I hope this gives you an idea of what I have implemented (it's not much, but it makes my life a lot easier!). There is more info about this and the scripts are available for downloading here: http://www.theficks.name/Hacks/Heartbeat-ResourceScripts If this can help anyone, or interest anyone in adding more resource scripts to mine that would be great! If this simply gives people a new way to look at things that would be good too. Thanks, -Martin ____________________________________________________________________________________ No need to miss a message. Get email on-the-go with Yahoo! Mail for Mobile. Get started. http://mobile.yahoo.com/mail _______________________________________________ Linux-HA mailing list Linux-HA@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha See also: http://linux-ha.org/ReportingProblems