tutorial.rst 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. Brief tutorial about common library API
  2. =======================================
  3. Most of the examples below show specific calls to the library functions,
  4. there are typically many more derivations possible, check the :ref:`full API documentation <full-api>`
  5. for details.
  6. Importing the library
  7. ---------------------
  8. Because the library may leverage SWIG-wrappers it is preferred to import all so that the pbs_ifl module imports all IFL symbols as shown below:
  9. ::
  10. from ptl.lib.pbs_testlib import *
  11. Instantiating a Server
  12. ----------------------
  13. Instantiate a Server object and populate it's attributes values after stat'ing the PBS server.
  14. ::
  15. server = Server('remotehost')
  16. OR
  17. server = Server() # no hostname defaults to the FQDN of the current host
  18. Adding a user as manager
  19. ------------------------
  20. ::
  21. server.manager(MGR_CMD_SET, SERVER, {ATTR_managers: (INCR, 'user@host')})
  22. Reverting server's configuration to defaults
  23. --------------------------------------------
  24. ::
  25. server.revert_to_defaults()
  26. Instantiating a Job
  27. -------------------
  28. ::
  29. job = Job()
  30. Setting job attributes
  31. ----------------------
  32. ::
  33. job.set_attributes({'Resource_List.select':'2:ncpus=1','Resource_List.place':'scatter'})
  34. Submitting a job
  35. ----------------
  36. ::
  37. server.submit(job)
  38. Stat'ing a server
  39. -----------------
  40. ::
  41. server.status()
  42. Stat'ing all jobs job_state attribute
  43. -------------------------------------
  44. ::
  45. server.status(JOB, 'job_state')
  46. Counting all vnodes by state
  47. ----------------------------
  48. ::
  49. server.counter(NODE, 'state')
  50. Expecting a job to be running
  51. -----------------------------
  52. ::
  53. server.expect(JOB, {'job_state':'R','substate':42}, attrop=PTL_AND, id=jid)
  54. where `jid` is the result of a server.submit(job)
  55. Each attribute can be given an operand, one of LT, LE, EQ, GE, GT, NE
  56. For example to expect a job to be in state R and substate != 41::
  57. server.expect(JOB, {'job_state':(EQ,'R'), 'substate':(NE,41)}, id=jid)
  58. Instantiating a Scheduler object
  59. --------------------------------
  60. ::
  61. sched = Scheduler('hostname')
  62. OR
  63. sched = Scheduler() # no hostname defaults to the FQDN of the current host
  64. Setting scheduler configuration
  65. -------------------------------
  66. ::
  67. sched.set_sched_config({'backfill':'true ALL'})
  68. Reverting scheduler's configuration to defaults
  69. -----------------------------------------------
  70. ::
  71. sched.revert_to_defaults()
  72. Instantiating a MoM
  73. -------------------
  74. ::
  75. mom = MoM('hostname')
  76. Creating a vnode definition file
  77. --------------------------------
  78. ::
  79. attrs = {'resources_available.ncpus':8,'resources_available.mem':'8gb'}
  80. vdef = node.create_vnode_def('vn', attrs, 10)
  81. Inserting a vnode definition to a MoM
  82. -------------------------------------
  83. ::
  84. mom.insert_vnode_def(vdef)
  85. Reverting mom's configuration to defaults
  86. -----------------------------------------
  87. ::
  88. mom.revert_to_defaults()