[[PageOutline]] = Examples = The test programs are include as a reference how to use the pbs python module. You have to edit some test programs to reflect your PBS/Torque installation: * pbsmon.oy - ASCII xpbsmon * rack_pbsmon.py - ascii xpbsmon by rack layout * pbsnodes-a.py - pbsnodes -a * pbs_version.py - print server version * set_property.py - set some node properties * resmom_info.py - queries the pbs_mom daemon on the nodes * logpbs.py - Shows the usage of the PBS logging routines * new_interface.py - Example how to use PBSQuery module * PBSQuery.py - python /PBSQuery.py (has builtin demo) == sara_nodes.py == [source:trunk/examples/sara_nodes.py sara_nodes] is an utility that we use to set nodes offline/online. We use this instead of ''pbsnodes -N''. It can be best described with some examples. When it is executed without command line arguments: {{{ sara_nodes }}} output: {{{ Use option --help for help Nodename | State | Note -------------------------------------------------------------------------------- gb-r10n1 | offline | 17-08 15:07, 14-09 14:21 bas : Debian squeeze testen, cfengine3 target node gb-r10n2 | offline | 24-03 10:46, 03-05 10:07 dennis #2761: Debian sqeeuze testen, sali ontwikkel node gb-r13n24 | offline | 14-09 07:59, 14-09 07:59 dennis #2999: ecc memory error }}} The note field is divided in separate fields: * date reported : 24-03 10:46 * last change : 03-05 10:07 * last user that has done the change : dennis * ticket number : !#2761 * note : Debian sqeeuze testen, sali ontwikkel node Below are some example how to use sara_nodes: * To mark the nodes 1-5 in rack 1-5 offline for maintenance: {{{ sara_nodes --offline="Maintenance" ib-r[1-5]n[1-5] }}} * To put the above nodes back online again: {{{ sara_nodes --clear ib-r[1-5]n[1-5] }}} * Mark the nodes gb-r6n1 and gb-8n9 offline according to ticket 3000: {{{ sara_nodes --offline="infiniband problems" --ticket=3000 }}} You can change the output format of sara_nodes. Use the {{{ -f/--format}}} option. The format of field tag is: * % : Start if the field tag * * : The length of the string. If the string is less then the value it will be pads spaces on the right. * == Use the default value specified in the source. * The field name must be specified between {{{ () }}} * s : To specify it ia a string value A list of field tags: * %*(node)s * %*(state)s * %*(date_add)s * %*(date_edit)s * %*(user)s * %*(ticket)s * %*(remark)s ==== Sara_nodes as python module ==== You can also use {{sara_nodes}} as python module in your own python programs, see example: {{{ import sara_nodes obj_sara_nodes = sara_nodes.sara_nodes() nodenames = ['gb-r15n1','gb-r15n2','gb-r15n3','gb-r15n4','gb-r15n5','gb-r15n6'] try: # Set the specified nodes offline obj_sara_nodes.pbs_change_state_offline( nodenames, 'Maintenance' ) # Set the specified nodes offline and attach a ticket number obj_sara_nodes.pbs_change_state_offline( nodenames, 'Onderhoud', 1221 ) # Clear the nodes obj_sara_nodes.pbs_change_state_down( nodenames ) # Clear the note obj_sara_nodes.pbs_change_note_clear( nodenames ) # Change the ticket number obj_sara_nodes.pbs_change_note_ticket( nodenames, 1221 ) # Change the note obj_sara_nodes.pbs_change_note( nodenames, 'New Bios' ) # Chnage the note and ticket number obj_sara_nodes.pbs_change_note( nodenames, 'New Bios' 1221 ) except sara_nodes.sara_nodesException, msg: print msg }}}